Add dark theme

This commit is contained in:
Max Bucknell 2017-01-25 13:23:13 +00:00
parent 18428929da
commit ebb2cab9bc
9 changed files with 182 additions and 61 deletions

View file

@ -1,6 +1,8 @@
import json
import os
import re
from os import path
from collections import OrderedDict
def find_in_parent(filename, starting_dir=None):
'''Look up the directory tree until you find a file.'''
@ -69,3 +71,99 @@ def get_namespace(dirname):
return namespace + convert_path(remainder)
def format_method(snip):
'''Convert expanded snippet into method name and args.'''
params = get_params_map(snip)
if len(params) is 0:
return
sorted_params = sort_params(params.values())
delete_param_tags(snip, params)
place_to_insert_params = snip.snippet_start[0] + params.keys()[0]
snip.buffer[place_to_insert_params:place_to_insert_params] = sorted_params
arguments = generate_arguments(sorted_params)
arguments[-1] = arguments[-1].replace(',', '')
args_line = snip.snippet_end[0] - 3
snip.buffer[args_line:args_line + 1] = arguments
def delete_param_tags(snip, params):
'''Sort @param PHPDoc tags so optional ones come later.'''
for idx, relative_line_number in enumerate(params.keys()):
# Have to subtract idx, because we are removing a line each time.
line_number = relative_line_number + snip.snippet_start[0] - idx
snip.buffer[line_number:line_number + 1] = []
def get_params_map(snip):
'''Get a map of @param PHPDoc tags, line_number: line.'''
lines = get_snippet_lines(snip)
return OrderedDict([[k, v] for k, v in enumerate(lines) if '@param' in v])
def generate_arguments(params):
'''Generate the function arguments from PHPDoc @params.'''
return [get_argument_line(x) for x in params]
def sort_params(params):
'''Sort params to put optional arguments at the end.'''
def sorter(left, right):
[left_is_optional, right_is_optional] = \
[is_union_with_null(x) for x in [left, right]]
if (left_is_optional and not right_is_optional):
return 1
if (not left_is_optional and right_is_optional):
return -1
return 0
return sorted(params, sorter)
def get_snippet_lines(snip):
'''Get the relevant slice of a snippet buffer.'''
start_line = snip.snippet_start[0]
finish_line = snip.snippet_end[0]
return snip.buffer[start_line:finish_line]
def get_argument_line(param):
'''Convert line from @param tag to method parameter.'''
expression = '\s*\*\s+@param\s+([^\s]+)\s+(\$[^\s]+).*'
result = re.search(expression, param)
type = map_type(result.group(1))
name = result.group(2)
return format_argument_line(type, name)
def map_type(type):
'''Convert PHPDoc type declaration into a PHP type hint.'''
if (is_union_with_null(type)):
return map_type(type.replace('|null', ''))
if (is_union_type(type)):
# PHP doesn't support union type hints yet.
return None
if (is_array_type(type)):
# PHP doesn't have complex generics yet.
return 'array'
# A plain type
return type
def is_union_with_null(type):
'''Test if PHPDoc type has a null option.'''
return '|null' in type
def is_union_type(type):
'''Test if PHPDoc type is any kind of union.'''
return '|' in type
def is_array_type(type):
'''Test if PHPDoc type is an array...'''
return '[]' in type
def format_argument_line(type, name):
if (type is None):
return ' {},'.format(name)
else:
return ' {} {},'.format(type, name)

View file

@ -119,12 +119,9 @@ install_vim_plugins () {
local PLUGINS=(
"joonty/vdebug"
"scrooloose/syntastic"
"groenewege/vim-less"
"vim-syntastic/syntastic"
"pangloss/vim-javascript"
"sirver/ultisnips"
"JulesWang/css.vim"
"mxw/vim-jsx"
)
local BASE_DIR="$DOTFILES_ROOT/vim/vim.symlink/bundle"
local GIT_HOST="git@github.com"

View file

@ -1,5 +1,5 @@
global !p
from mbutils import get_namespace
from mbutils import get_namespace, format_method
import os
def full_path(filename):
@ -49,10 +49,18 @@ function ${1}(
\}
endsnippet
post_jump "if (snip.tabstop == 0): format_method(snip)"
snippet pubf
public function ${1}(
${2}
) \{
/**
* ${2:Short description...}
*
* ${3:A slightly longer description of what you want to do. This will automatically be wrapped}
*
* ${4:@tags}
*/
public function ${1:methodName}(
...\$args
):returnType \{
$0
\}
endsnippet
@ -72,3 +80,7 @@ private function ${1}(
$0
\}
endsnippet
snippet @param
@param ${1:Type}${2:|null} \$${3:name} ${4:Description}
endsnippet

View file

@ -1,4 +1,4 @@
set background=dark
set background=light
hi clear
if exists("syntax_on")
@ -55,6 +55,14 @@ hi ZshSubstDelim cterm=NONE ctermfg=0 ctermbg=NONE
hi xmlProcessingDelim cterm=NONE ctermfg=0 ctermbg=NONE
hi xmlAttribPunct cterm=NONE ctermfg=0 ctermbg=NONE
" Residual Markdown colors
hi markdownH1 cterm=NONE ctermbg=NONE ctermfg=0
hi markdownH2 cterm=NONE ctermbg=NONE ctermfg=0
hi markdownH3 cterm=NONE ctermbg=NONE ctermfg=0
hi markdownH4 cterm=NONE ctermbg=NONE ctermfg=0
hi markdownH5 cterm=NONE ctermbg=NONE ctermfg=0
hi markdownH6 cterm=NONE ctermbg=NONE ctermfg=0
" Miscellaneous leftovers
hi helpNote cterm=NONE ctermfg=0 ctermbg=NONE
hi MatchParen cterm=NONE ctermfg=0 ctermbg=5
@ -128,15 +136,3 @@ hi SyntasticWarningSign cterm=NONE ctermbg=1 ctermfg=1
"""""""""""
hi snipLeadingSpaces cterm=NONE ctermbg=NONE ctermfg=NONE
""""""""""
" Markdown
""""""""""
hi markdownH1 cterm=NONE ctermbg=NONE ctermfg=0
hi markdownH2 cterm=NONE ctermbg=NONE ctermfg=0
hi markdownH3 cterm=NONE ctermbg=NONE ctermfg=0
hi markdownH4 cterm=NONE ctermbg=NONE ctermfg=0
hi markdownH5 cterm=NONE ctermbg=NONE ctermfg=0
hi markdownH6 cterm=NONE ctermbg=NONE ctermfg=0

View file

@ -0,0 +1,56 @@
set background=dark
hi clear
if exists("syntax on")
syntax reset
endif
runtime "colors/maxbucknell.vim"
let g:colors_name = "maxbucknell_dark"
" Make everything white by default
hi Normal cterm=NONE ctermfg=7 ctermbg=NONE
hi Type cterm=NONE ctermfg=7 ctermbg=NONE
hi Keyword cterm=NONE ctermfg=7 ctermbg=NONE
hi Operator cterm=NONE ctermfg=7 ctermbg=NONE
hi Special cterm=NONE ctermfg=7 ctermbg=NONE
hi Statement cterm=NONE ctermfg=7 ctermbg=NONE
hi Identifier cterm=NONE ctermfg=7 ctermbg=NONE
hi Constant cterm=NONE ctermfg=7 ctermbg=NONE
hi Define cterm=NONE ctermfg=7 ctermbg=NONE
hi Include cterm=NONE ctermfg=7 ctermbg=NONE
hi Macro cterm=NONE ctermfg=7 ctermbg=NONE
" Residual Less colors
hi lessFunction cterm=NONE ctermfg=7 ctermbg=NONE
hi lessCssAttribute cterm=NONE ctermfg=7 ctermbg=NONE
" Residual Vim colors
hi VimSet cterm=NONE ctermfg=7 ctermbg=NONE
hi VimOption cterm=NONE ctermfg=7 ctermbg=NONE
hi VimHiAttrib cterm=NONE ctermfg=7 ctermbg=NONE
" Residual Zsh colors
hi ZshDeref cterm=NONE ctermfg=7 ctermbg=NONE
hi ZshShortDeref cterm=NONE ctermfg=7 ctermbg=NONE
hi ZshSubstDelim cterm=NONE ctermfg=7 ctermbg=NONE
" Residual XML colors
hi xmlProcessingDelim cterm=NONE ctermfg=7 ctermbg=NONE
hi xmlAttribPunct cterm=NONE ctermfg=7 ctermbg=NONE
" Miscellaneous leftovers
hi helpNote cterm=NONE ctermfg=7 ctermbg=NONE
hi MatchParen cterm=NONE ctermfg=7 ctermbg=5
" Line numbers are grey
hi LineNr cterm=NONE ctermfg=8 ctermbg=NONE
"
" Residual Markdown colors
hi markdownH1 cterm=NONE ctermbg=NONE ctermfg=7
hi markdownH2 cterm=NONE ctermbg=NONE ctermfg=7
hi markdownH3 cterm=NONE ctermbg=NONE ctermfg=7
hi markdownH4 cterm=NONE ctermbg=NONE ctermfg=7
hi markdownH5 cterm=NONE ctermbg=NONE ctermfg=7
hi markdownH6 cterm=NONE ctermbg=NONE ctermfg=7

View file

@ -388,7 +388,7 @@ let g:UltiSnipsJumpBackwardTrigger="<S-tab>"
""""""""
let g:vdebug_options={}
let g:vdebug_options['break_on_open']=0
let g:vdebug_options['break_on_open']=1
let g:vdebug_options['ide_key']='docker'
let g:vdebug_options['port']=9000
let g:vdebug_options['timeout']=300

View file

@ -1,8 +1,3 @@
! Remove caps lock
remove Lock = Caps_Lock
keysym Caps_Lock = Control_L
add Control = Control_L
! Fix some lingering keyboard layout issues
keycode 94 = grave asciitilde

@ -1 +1 @@
Subproject commit 8318b8a3b42a236c3c7c1d37c3e256655fd6967d
Subproject commit fb28eaf1d6c3c697f1e9721ee9ec911b8d0118ec

View file

@ -119,39 +119,6 @@ autoload -U colors && colors
# We set the prompt in the line editor function.
## SSH Agent
# Start SSH Agent and set relevant variables
function start-agent {
echo "Initialising new SSH Agent..."
rm ~/.ssh/redbox-docker-socket
ssh-agent -s -a $HOME/.ssh/redbox-docker-socket | sed 's/^echo/# echo/' > "$SSH_ENV"
echo "Success!"
chmod 600 "$SSH_ENV"
. $SSH_ENV > /dev/null
ssh-add "$HOME/.ssh/id_$(nice-hostname)"
}
# If we may have loaded config, let's just check that
function test-identities {
if ! ssh-add -l > /dev/null; then
start-agent
fi
}
# Start SSH Agent if it's not already running.
#
# Also add the id_(nice-hostname) identity.
export SSH_ENV="$HOME/.ssh/environment"
if [[ -f $SSH_ENV ]]; then
. $SSH_ENV > /dev/null
test-identities
else
start-agent
fi
## Line Editing
# Use Vi key bindings rather than emacs.
bindkey -v