From 7caa0e55150a556a37a27081e30e348bfbd2af63 Mon Sep 17 00:00:00 2001 From: Max Bucknell Date: Mon, 4 Mar 2019 21:08:35 +0000 Subject: [PATCH] Vim reset --- script/bootstrap.sh | 30 -- vim/vim.symlink/UltiSnips/all.snippets | 0 vim/vim.symlink/UltiSnips/javascript.snippets | 0 .../UltiSnips/javascript_mocha.snippets | 37 -- .../UltiSnips/javascript_module.snippets | 10 - .../UltiSnips/javascript_react.snippets | 50 -- .../UltiSnips/json_magento.snippets | 20 - vim/vim.symlink/UltiSnips/less.snippets | 3 - vim/vim.symlink/UltiSnips/php.snippets | 0 vim/vim.symlink/UltiSnips/php_class.snippets | 65 --- vim/vim.symlink/UltiSnips/php_field.snippets | 22 - .../UltiSnips/php_magento.snippets | 87 --- .../UltiSnips/php_methods.snippets | 98 ---- .../UltiSnips/php_phpunit.snippets | 29 - vim/vim.symlink/UltiSnips/xml.snippets | 55 -- vim/vim.symlink/autoload/pathogen.vim | 347 ------------ vim/vim.symlink/colors/maxbucknell.vim | 162 ------ vim/vim.symlink/indent/xml.vim | 96 ---- vim/vimrc.symlink | 502 ------------------ 19 files changed, 1613 deletions(-) delete mode 100644 vim/vim.symlink/UltiSnips/all.snippets delete mode 100644 vim/vim.symlink/UltiSnips/javascript.snippets delete mode 100644 vim/vim.symlink/UltiSnips/javascript_mocha.snippets delete mode 100644 vim/vim.symlink/UltiSnips/javascript_module.snippets delete mode 100644 vim/vim.symlink/UltiSnips/javascript_react.snippets delete mode 100644 vim/vim.symlink/UltiSnips/json_magento.snippets delete mode 100644 vim/vim.symlink/UltiSnips/less.snippets delete mode 100644 vim/vim.symlink/UltiSnips/php.snippets delete mode 100644 vim/vim.symlink/UltiSnips/php_class.snippets delete mode 100644 vim/vim.symlink/UltiSnips/php_field.snippets delete mode 100644 vim/vim.symlink/UltiSnips/php_magento.snippets delete mode 100644 vim/vim.symlink/UltiSnips/php_methods.snippets delete mode 100644 vim/vim.symlink/UltiSnips/php_phpunit.snippets delete mode 100644 vim/vim.symlink/UltiSnips/xml.snippets delete mode 100644 vim/vim.symlink/autoload/pathogen.vim delete mode 100644 vim/vim.symlink/colors/maxbucknell.vim delete mode 100644 vim/vim.symlink/indent/xml.vim diff --git a/script/bootstrap.sh b/script/bootstrap.sh index f00336f..72f7757 100755 --- a/script/bootstrap.sh +++ b/script/bootstrap.sh @@ -114,35 +114,6 @@ install_dotfiles () { done } -install_vim_plugins () { - info "installing vim plugins" - - local PLUGINS=( - "joonty/vdebug" - "w0rp/ale" - "pangloss/vim-javascript" - "sirver/ultisnips" - "tpope/vim-surround" - "tpope/vim-fugitive" - "airblade/vim-gitgutter" - ) - local BASE_DIR="$DOTFILES_ROOT/vim/vim.symlink/bundle" - local GIT_HOST="git@github.com" - - rm -fr "$BASE_DIR" - success "remove existing plugins" - - mkdir -p "$BASE_DIR" - - for i in "${PLUGINS[@]}" - do - info "installing $i" - local BASE_NAME="$(basename $i)" - git clone "$GIT_HOST:$i" "$BASE_DIR/$BASE_NAME" &> /dev/null - success "installed $i" - done -} - install_zsh_plugins () { info "installing bash plugins" @@ -167,7 +138,6 @@ install_zsh_plugins () { done } -install_vim_plugins install_zsh_plugins install_dotfiles diff --git a/vim/vim.symlink/UltiSnips/all.snippets b/vim/vim.symlink/UltiSnips/all.snippets deleted file mode 100644 index e69de29..0000000 diff --git a/vim/vim.symlink/UltiSnips/javascript.snippets b/vim/vim.symlink/UltiSnips/javascript.snippets deleted file mode 100644 index e69de29..0000000 diff --git a/vim/vim.symlink/UltiSnips/javascript_mocha.snippets b/vim/vim.symlink/UltiSnips/javascript_mocha.snippets deleted file mode 100644 index 9a335c1..0000000 --- a/vim/vim.symlink/UltiSnips/javascript_mocha.snippets +++ /dev/null @@ -1,37 +0,0 @@ -snippet ttest -/* eslint-env node, mocha */ -/* eslint-disable no-unused-expressions */ - -import chai from 'chai'; - -import sinon from 'sinon'; - -import sinonChai from 'sinon-chai'; -chai.use(sinonChai); - -const expect = chai.expect; - -$0 -endsnippet - -snippet tdescribe -describe('${1:Description}', () => { - ${2:// specs} -});$0 -endsnippet - -snippet tbefore -beforeEach(() => { - ${1:// do stuff} -});$0 -endsnippet - -snippet tit -it('should ${1:do something exciting}', () => { - ${2:// spec} -});$0 -endsnippet - -snippet texpect -expect(${1:value}).to.${2:be.true};$0 -endsnippet diff --git a/vim/vim.symlink/UltiSnips/javascript_module.snippets b/vim/vim.symlink/UltiSnips/javascript_module.snippets deleted file mode 100644 index d20bcff..0000000 --- a/vim/vim.symlink/UltiSnips/javascript_module.snippets +++ /dev/null @@ -1,10 +0,0 @@ -snippet mimport -import ${1:${2:default}, }${2:\{ - ${3:...things} -\}} from ${4:'${5:module}'}; -$0 -endsnippet - -snippet mdep -${1:dependency}${2: as ${3:alias}}, -endsnippet diff --git a/vim/vim.symlink/UltiSnips/javascript_react.snippets b/vim/vim.symlink/UltiSnips/javascript_react.snippets deleted file mode 100644 index e2c36f9..0000000 --- a/vim/vim.symlink/UltiSnips/javascript_react.snippets +++ /dev/null @@ -1,50 +0,0 @@ -snippet action -export const type = '${1:`!p snip.rv = snip.basename`}'; - -export default (${2:...args}) => (\{ - type,${3: - payload: \{ - ${2/,?( |$)/,\n $1$1/g}\},} -\});$0 -endsnippet - -snippet testaction -import test from 'tape'; - -import ${1/-(\w)/\u$1/g}, \{ - type, -\} from '../../src/actions/${1:`!p snip.rv = snip.basename`}'; - -test('${1/-(\w)/\u$1/g} is a function', (t) => \{ - const actual = typeof ${1/-(\w)/\u$1/g}; - const expected = 'function'; - - t.equal( - actual, expected, - '${1/-(\w)/\u$1/g} should be a function' - ); - - t.end(); -\}); - -test('${1/-(\w)/\u$1/g} returns the correct action', (t) => \{ - const actual = ${1/-(\w)/\u$1/g}(); - const expected = \{ type \}; - - t.deepEqual( - actual, expected, - 'Action not of expected shape' - ); - t.end(); -\}); -endsnippet - -snippet impaction -import ${1/-(\w)/\u$1/g}, \{ - type as ${1/-(\w)/\u$1/g}Type, -\} from './${1:action-file-name}'; - -${1/-(\w)/\u$1/g}.type = ${1/-(\w)/\u$1/g}Type; - -export \{ ${1/-(\w)/\u$1/g} \}; -endsnippet diff --git a/vim/vim.symlink/UltiSnips/json_magento.snippets b/vim/vim.symlink/UltiSnips/json_magento.snippets deleted file mode 100644 index 51a2de8..0000000 --- a/vim/vim.symlink/UltiSnips/json_magento.snippets +++ /dev/null @@ -1,20 +0,0 @@ -snippet mcomposer -\{ - "name": "${1:vendor}/${2:module}-${3:module-name}", - "description": "${4:Elevator pitch}", - "require": \{ - "php": "~5.6.0|~7.0.0"$0 - \}, - "type": "magento2-$2", - "license": "${5:proprietary}", - "autoload": \{ - "files": [ - "registration.php" - ], - "psr-4": \{ - "${1/(^|-)(\w)/\u$2/g}\\\\${3/(^|-)(\w)/\u$2/g}\\\\": "" - \} - \} -\} -endsnippet - diff --git a/vim/vim.symlink/UltiSnips/less.snippets b/vim/vim.symlink/UltiSnips/less.snippets deleted file mode 100644 index a300f65..0000000 --- a/vim/vim.symlink/UltiSnips/less.snippets +++ /dev/null @@ -1,3 +0,0 @@ -snippet mrem -unit($1px / @font-size__s) * 1rem$0 -endsnippet diff --git a/vim/vim.symlink/UltiSnips/php.snippets b/vim/vim.symlink/UltiSnips/php.snippets deleted file mode 100644 index e69de29..0000000 diff --git a/vim/vim.symlink/UltiSnips/php_class.snippets b/vim/vim.symlink/UltiSnips/php_class.snippets deleted file mode 100644 index 5c8f0fe..0000000 --- a/vim/vim.symlink/UltiSnips/php_class.snippets +++ /dev/null @@ -1,65 +0,0 @@ -# Python -# -# `mbutils` is a collection of tooling I've built to do some intelligent -# stuff around PHP tooling. -# Found in lib/python/mbutils.py -global !p -import mbutils -import os - -def full_path(filename): - cwd = os.getcwd() - filepath = os.path.join(cwd, filename) - - return os.path.dirname(filepath) -endglobal - -snippet class -resultFactory = $resultFactory; - \} - - /** - * @return \Magento\Framework\Controller\ResultInterface - */ - public function execute() - \{ - ${0:// Implementation...} - \} -\} -endsnippet - -snippet mblock - - - - $0 - - -endsnippet - -snippet mdixml - - - $0 - -endsnippet - -snippet mwidgets - - - $0 - -endsnippet - -snippet mwidget - - - $7 - - $0 - - -endsnippet - -snippet mwidgetparam - - - $7 - -endsnippet diff --git a/vim/vim.symlink/autoload/pathogen.vim b/vim/vim.symlink/autoload/pathogen.vim deleted file mode 100644 index a13ae08..0000000 --- a/vim/vim.symlink/autoload/pathogen.vim +++ /dev/null @@ -1,347 +0,0 @@ -" pathogen.vim - path option manipulation -" Maintainer: Tim Pope -" Version: 2.3 - -" Install in ~/.vim/autoload (or ~\vimfiles\autoload). -" -" For management of individually installed plugins in ~/.vim/bundle (or -" ~\vimfiles\bundle), adding `execute pathogen#infect()` to the top of your -" .vimrc is the only other setup necessary. -" -" The API is documented inline below. - -if exists("g:loaded_pathogen") || &cp - finish -endif -let g:loaded_pathogen = 1 - -" Point of entry for basic default usage. Give a relative path to invoke -" pathogen#interpose() (defaults to "bundle/{}"), or an absolute path to invoke -" pathogen#surround(). Curly braces are expanded with pathogen#expand(): -" "bundle/{}" finds all subdirectories inside "bundle" inside all directories -" in the runtime path. -function! pathogen#infect(...) abort - for path in a:0 ? filter(reverse(copy(a:000)), 'type(v:val) == type("")') : ['bundle/{}'] - if path =~# '^\%({\=[$~\\/]\|{\=\w:[\\/]\).*[{}*]' - call pathogen#surround(path) - elseif path =~# '^\%([$~\\/]\|\w:[\\/]\)' - call s:warn('Change pathogen#infect('.string(path).') to pathogen#infect('.string(path.'/{}').')') - call pathogen#surround(path . '/{}') - elseif path =~# '[{}*]' - call pathogen#interpose(path) - else - call s:warn('Change pathogen#infect('.string(path).') to pathogen#infect('.string(path.'/{}').')') - call pathogen#interpose(path . '/{}') - endif - endfor - call pathogen#cycle_filetype() - if pathogen#is_disabled($MYVIMRC) - return 'finish' - endif - return '' -endfunction - -" Split a path into a list. -function! pathogen#split(path) abort - if type(a:path) == type([]) | return a:path | endif - if empty(a:path) | return [] | endif - let split = split(a:path,'\\\@]','\\&','') - endif -endfunction - -" Like findfile(), but hardcoded to use the runtimepath. -function! pathogen#runtime_findfile(file,count) abort "{{{1 - let rtp = pathogen#join(1,pathogen#split(&rtp)) - let file = findfile(a:file,rtp,a:count) - if file ==# '' - return '' - else - return fnamemodify(file,':p') - endif -endfunction - -" Section: Deprecated - -function! s:warn(msg) abort - echohl WarningMsg - echomsg a:msg - echohl NONE -endfunction - -" Prepend all subdirectories of path to the rtp, and append all 'after' -" directories in those subdirectories. Deprecated. -function! pathogen#runtime_prepend_subdirectories(path) abort - call s:warn('Change pathogen#runtime_prepend_subdirectories('.string(a:path).') to pathogen#infect('.string(a:path.'/{}').')') - return pathogen#surround(a:path . pathogen#slash() . '{}') -endfunction - -function! pathogen#incubate(...) abort - let name = a:0 ? a:1 : 'bundle/{}' - call s:warn('Change pathogen#incubate('.(a:0 ? string(a:1) : '').') to pathogen#infect('.string(name).')') - return pathogen#interpose(name) -endfunction - -" Deprecated alias for pathogen#interpose(). -function! pathogen#runtime_append_all_bundles(...) abort - if a:0 - call s:warn('Change pathogen#runtime_append_all_bundles('.string(a:1).') to pathogen#infect('.string(a:1.'/{}').')') - else - call s:warn('Change pathogen#runtime_append_all_bundles() to pathogen#infect()') - endif - return pathogen#interpose(a:0 ? a:1 . '/{}' : 'bundle/{}') -endfunction - -if exists(':Vedit') - finish -endif - -let s:vopen_warning = 0 - -function! s:find(count,cmd,file,lcd) - let rtp = pathogen#join(1,pathogen#split(&runtimepath)) - let file = pathogen#runtime_findfile(a:file,a:count) - if file ==# '' - return "echoerr 'E345: Can''t find file \"".a:file."\" in runtimepath'" - endif - if !s:vopen_warning - let s:vopen_warning = 1 - let warning = '|echohl WarningMsg|echo "Install scriptease.vim to continue using :V'.a:cmd.'"|echohl NONE' - else - let warning = '' - endif - if a:lcd - let path = file[0:-strlen(a:file)-2] - execute 'lcd `=path`' - return a:cmd.' '.pathogen#fnameescape(a:file) . warning - else - return a:cmd.' '.pathogen#fnameescape(file) . warning - endif -endfunction - -function! s:Findcomplete(A,L,P) - let sep = pathogen#slash() - let cheats = { - \'a': 'autoload', - \'d': 'doc', - \'f': 'ftplugin', - \'i': 'indent', - \'p': 'plugin', - \'s': 'syntax'} - if a:A =~# '^\w[\\/]' && has_key(cheats,a:A[0]) - let request = cheats[a:A[0]].a:A[1:-1] - else - let request = a:A - endif - let pattern = substitute(request,'/\|\'.sep,'*'.sep,'g').'*' - let found = {} - for path in pathogen#split(&runtimepath) - let path = expand(path, ':p') - let matches = split(glob(path.sep.pattern),"\n") - call map(matches,'isdirectory(v:val) ? v:val.sep : v:val') - call map(matches,'expand(v:val, ":p")[strlen(path)+1:-1]') - for match in matches - let found[match] = 1 - endfor - endfor - return sort(keys(found)) -endfunction - -command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Ve :execute s:find(,'edit',,0) -command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vedit :execute s:find(,'edit',,0) -command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vopen :execute s:find(,'edit',,1) -command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vsplit :execute s:find(,'split',,1) -command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vvsplit :execute s:find(,'vsplit',,1) -command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vtabedit :execute s:find(,'tabedit',,1) -command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vpedit :execute s:find(,'pedit',,1) -command! -bar -bang -range=1 -nargs=1 -complete=customlist,s:Findcomplete Vread :execute s:find(,'read',,1) - -" vim:set et sw=2 foldmethod=expr foldexpr=getline(v\:lnum)=~'^\"\ Section\:'?'>1'\:getline(v\:lnum)=~#'^fu'?'a1'\:getline(v\:lnum)=~#'^endf'?'s1'\:'=': diff --git a/vim/vim.symlink/colors/maxbucknell.vim b/vim/vim.symlink/colors/maxbucknell.vim deleted file mode 100644 index 753c0b9..0000000 --- a/vim/vim.symlink/colors/maxbucknell.vim +++ /dev/null @@ -1,162 +0,0 @@ -set background=light -hi clear - -if exists("syntax_on") - syntax reset -endif - -""""""""""""""""""""""""""""" -" -" Terminal colours cheatsheet -" -" 0: black -" 1: red (errors) -" 2: green (comments) -" 3: yellow (search) -" 4: blue -" 5: magenta (current) -" 4: cyan (scalars) -" 7: white (default) -" -" +8 for bright colours. -" -""""""""""""""""""""""""""""" - -let g:colors_name = "maxbucknell" - -" 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 - -" 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 markdownH4 cterm=NONE ctermbg=NONE ctermfg=7 -hi markdownBlockQuote cterm=NONE ctermbg=NONE ctermfg=7 - -" Residual HTML -hi htmlTitle cterm=NONE ctermbg=NONE ctermfg=7 - -" Miscellaneous leftovers -hi helpNote cterm=NONE ctermfg=7 ctermbg=NONE -hi MatchParen cterm=NONE ctermfg=7 ctermbg=5 - -" Scalars are cyan -hi String cterm=NONE ctermfg=4 ctermbg=NONE -hi Number cterm=NONE ctermfg=4 ctermbg=NONE -hi Boolean cterm=NONE ctermfg=4 ctermbg=NONE -hi phpHereDoc cterm=NONE ctermfg=4 ctermbg=NONE -hi phpNowDoc cterm=NONE ctermfg=4 ctermbg=NONE -hi phpBackslashSequences cterm=NONE ctermfg=4 ctermbg=NONE - -" Comments are green -hi Comment cterm=NONE ctermfg=2 ctermbg=NONE - -" Todos are almost green -hi Todo cterm=NONE ctermfg=0 ctermbg=2 - -" Preprocessor statements aren't comments. -hi PreProc cterm=NONE ctermfg=7 ctermbg=NONE - -" JSDoc comments are comments. -hi jsDocTags cterm=NONE ctermfg=2 ctermbg=NONE -hi jsDocType cterm=NONE ctermfg=2 ctermbg=NONE -hi jsDocParam cterm=NONE ctermfg=2 ctermbg=NONE -hi jsDocTypeNoParam cterm=NONE ctermfg=2 ctermbg=NONE -hi jsDocSeeTag cterm=NONE ctermfg=2 ctermbg=NONE - -" PHPDoc comments are comments. -hi phpDocTags cterm=NONE ctermfg=2 ctermbg=NONE -hi phpDocCustomTags cterm=NONE ctermfg=2 ctermbg=NONE - -" Line numbers are grey -hi LineNr cterm=NONE ctermfg=7 ctermbg=NONE - -" Current search result yellow -hi Search cterm=NONE ctermfg=0 ctermbg=3 -hi MBSearchNext cterm=NONE ctermfg=0 ctermbg=3 - -" Errors are red - -" Make current line magenta -hi CursorLine cterm=NONE ctermfg=4 ctermbg=NONE -hi CursorLineNr cterm=NONE ctermfg=4 ctermbg=NONE - -"""""""" -" Visual -"""""""" - -hi Visual cterm=NONE ctermbg=7 ctermfg=0 - -""""""""""""" -" Status Line -""""""""""""" - -hi StatusLine cterm=NONE ctermfg=7 ctermbg=4 -hi StatusLineNC cterm=NONE ctermfg=0 ctermbg=7 - -""""""" -" Signs -""""""" - -hi SignColumn cterm=NONE ctermbg=0 ctermfg=0 - -"""""""" -" Vdebug -"""""""" - -hi DbgBreakptLine cterm=NONE ctermfg=5 ctermbg=NONE -hi DbgBreakptSign cterm=NONE ctermfg=5 ctermbg=5 -hi DbgCurrentLine cterm=NONE ctermfg=7 ctermbg=5 -hi DbgCurrentSign cterm=NONE ctermfg=5 ctermbg=5 - -""""" -" Ale -""""" - -hi ALEWarningSign cterm=NONE ctermbg=3 ctermfg=3 -hi ALEErrorSign cterm=NONE ctermbg=1 ctermfg=1 - -""""""""""" -" UltiSnips -""""""""""" - -hi snipLeadingSpaces cterm=NONE ctermbg=0 ctermfg=NONE -hi snipTabStop cterm=NONE ctermbg=NONE ctermfg=4 -hi snipTabStopDefault cterm=NONE ctermbg=NONE ctermfg=4 - -"""""""""""" -" Long lines -"""""""""""" - -hi ColorColumn cterm=NONE ctermbg=1 ctermfg=NONE diff --git a/vim/vim.symlink/indent/xml.vim b/vim/vim.symlink/indent/xml.vim deleted file mode 100644 index 817f3bb..0000000 --- a/vim/vim.symlink/indent/xml.vim +++ /dev/null @@ -1,96 +0,0 @@ -" Language: xml -" Maintainer: Johannes Zellner -" Last Change: 2012 Jul 25 -" Notes: 1) does not indent pure non-xml code (e.g. embedded scripts) -" 2) will be confused by unbalanced tags in comments -" or CDATA sections. -" 2009-05-26 patch by Nikolai Weibull -" TODO: implement pre-like tags, see xml_indent_open / xml_indent_close - -" Only load this indent file when no other was loaded. -if exists("b:did_indent") - finish -endif -let b:did_indent = 1 -let s:keepcpo= &cpo -set cpo&vim - -" [-- local settings (must come before aborting the script) --] -setlocal indentexpr=XmlIndentGet(v:lnum,1) -setlocal indentkeys=o,O,*,<>>,<<>,/,{,} - -" [-- check if it's xml --] -fun! XmlIndentSynCheck(lnum) - if '' != &syntax - let syn1 = synIDattr(synID(a:lnum, 1, 1), 'name') - let syn2 = synIDattr(synID(a:lnum, strlen(getline(a:lnum)) - 1, 1), 'name') - if '' != syn1 && syn1 !~ 'xml' && '' != syn2 && syn2 !~ 'xml' - " don't indent pure non-xml code - return 0 - elseif syn1 =~ '^xmlComment' && syn2 =~ '^xmlComment' - " indent comments specially - return -1 - endif - endif - return 1 -endfun - -fun! XmlPrevLine(line) - " 'Checking previous line:' - if (match(a:line, '^') != -1) - " 'Doctype' - return 0 - elseif (match(a:line, '/>') != -1) || (match(a:line, '') != -1) - " 'Is opening tag, time to indent.' - return 1 - else - " 'No change' - return 0 - endif -endfun - -fun! XmlCurrentLine(line) - " 'Checking current line:' - if (match(a:line, '^\s*/\{0,1}>') != -1) || (match(a:line, '^\s*XmlIndentSynCheck(lnum) - let check_alnum = XmlIndentSynCheck(a:lnum) - if 0 == check_lnum || 0 == check_alnum - return indent(a:lnum) - elseif -1 == check_lnum || -1 == check_alnum - return -1 - endif - endif - - let cur = getline(a:lnum) - let pre = getline(lnum) - - let ind = indent(lnum) + &sw * (XmlPrevLine(pre) + XmlCurrentLine(cur)) - - return ind -endfun - -let &cpo = s:keepcpo -unlet s:keepcpo - -" vim:ts=8 diff --git a/vim/vimrc.symlink b/vim/vimrc.symlink index 724ec9c..8b13789 100644 --- a/vim/vimrc.symlink +++ b/vim/vimrc.symlink @@ -1,503 +1 @@ -" Max's .vimrc - -"""""""""""""""""""""" -" Plugins -"""""""""""""""""""""" - -execute pathogen#infect() - -"""""""""""""""""""""" -" Basic editing config -"""""""""""""""""""""" - -set term=xterm-256color - -set nocompatible - -colorscheme maxbucknell - -" Leader -" -" Using space as leader is actually a terrific idea. It's one of the -" easiest things to hit on the keyboard. -let mapleader = "\" - -" Don't wrap lines -" -" I look at a lot of CSV files and logs, which are generally the only -" times I see long lines. If code is too long, I shorten it. As such, -" having lines artificially wrapping only gets in my way. -set nowrap - -" Line numbering -" -" This shows the real line number of the current line, and relative -" line numbers on the other lines. Relative line numbers are good to -" know how many lines to yank, delete, or move. -set number -set relativenumber - -" Write before commands -" -" This means that if I have unsaved changes, they get saved before -" executing a git commit, or something like that. -set autowrite - -" Open splits in better places -" -" This seems to be the most logical way to split, in the direction -" that we read, and in agreement with Tmux. -set splitbelow -set splitright - -" Quicker window movement -" -" Just remove an extra keystroke -nnoremap j -nnoremap k -nnoremap h -nnoremap l - -" Set editor shell to bash, for Syntastic compatibility -set shell=bash - -" Allow visual block mode to select anywhere. -" -" I want to use this to manage my ascii drawings -set virtualedit=block - -" Swap block and visual block -nnoremap v -nnoremap v - -vnoremap v -vnoremap v - -" Automatically read on update -set autoread - -" I am always adding /g. No longer, suckers! -set gdefault - -" Set comment line length -set tw=72 -set fo=c - -" Navigate to test, and back - -" Find test counterpart. -" -" This works by replacing src/ with test/, and test/ with src/ -function! FindTestFilename(filename) - " Replace src/ with t_est/ - let first = substitute(a:filename, 'src/', 't_est/', '') - " Replace test/ with src/ - let second = substitute(first, 'test/', 'src/', '') - " Replace t_est/ with test/ - let third = substitute(second, 't_est/', 'test/', '') - - return third -endfunction - -nnoremap :exec ":e " . FindTestFilename(expand('%')) - -" Run a given vim command on the results of fuzzy selecting from a given shell -" command. See usage below. -function! SelectaCommand(choice_command, selecta_args, vim_command) - try - let selection = system(a:choice_command . " | selecta " . a:selecta_args) - catch /Vim:Interrupt/ - " Swallow the ^C so that the redraw below happens; otherwise there will be - " leftovers from selecta on the screen - redraw! - return - endtry - redraw! - exec a:vim_command . " " . selection -endfunction - -" Find all files in all non-dot directories starting in the working directory. -" Fuzzy select one of those. Open the selected file with :e. -nnoremap t :call SelectaCommand("find * -type f", "", ":e") - -" Git blame -" -" I used to do this by just filling in my buffer, but this is nicer. -nnoremap a :Gblame - -" Tab config options -" -" In general, I prefer spaces to tabs, and 2-space indentation. These -" settings just make that consistent, so I rarely have to think about -" it. -set expandtab -set tabstop=2 -set shiftwidth=2 -set softtabstop=2 -set autoindent - -" Disable creation of swap files. -" -" Swap files serve a purpose, but not to me. I write often, and so -" these just get in the way. -set nobackup -set nowritebackup -set noswapfile - -" What the hell is ex mode -" -" Whatever it is, I don't like it. -nnoremap Q - -" Faster highlight removal than ;noh -" -" :noh is the command one should run to remove highlighted search -" terms. I search for things so often, that I got sick of typing it -" so much. So I made a short cut. -nnoremap / :noh - -" Remap semi-colon to colon. -" -" Colon is the starting point of a lot of actions in Vim. And I -" shouldn't have to hold a modifier key to access so much -" essential functionality. -noremap ; : -noremap ;; ; - -" Quick exit insert mode -" -" Escape is at the far corner of my keyboard, and having it so far away -" was discouraging my from exiting insert mode. Qwerty users can remap -" jk to , which is a far better solution. The keys are next to each -" other, and it makes exiting insert mode a pleasant rolling motion. -" Moreover, when in normal mode, jk is a no-op. -" -" As a dvorak user, jk was too cumbersome, but there were no other -" suitable candidates. hh is inferior in that it is not a no-op in -" normal mode, but it is just as easy to type. The only caveat is when -" an edit ends with h, which is why hhh will expand to place an h in -" the buffer before exiting. -" -" To encourage me to adopt the new style, I disable escape. That one is -" sure to mess up someone not familiar with my setup. -inoremap hh -inoremap hhh h -" inoremap -inoremap uu \ - -" Bad arrow keys -" -" This will disable use of arrow keys in normal and insert modes. This -" is a good idea to get into the vim way. I don’t really use the arrow -" keys anymore. -" -" That said, I have reservations about the apparently egregious nature -" of the arrow keys. On my MacBook, they are quite close. Still, I can -" understand that it is better to rely only on the core keys that you -" know are within reach, not just the ones that happen to be on one -" computer. -inoremap -inoremap -inoremap -inoremap -noremap -noremap -noremap -noremap - -" Move lines up and down -" -" These are very useful commands, especially for re-ordering things. I -" would like to make it possible to move hunks of code with similar -" shortcuts, but I haven't thought it through yet. I would also like -" to have something automated, wherein I could sort a list of things -" alphabetically. -noremap - ddp -noremap _ ddkP - -" Uppercase an entire word. -" -" This is handy for things like constants. I have no caps lock, and -" holding shift can be a pain. -nnoremap u viwU - -" Show me when my lines are too long -" -" I wish to limit my lines to 80 characters long. However, Vim creates -" the n+1th character when you have n characters in a line. Hence, when -" my line is 80 characters long, I see the red line. So, this is set to -" 82, meaning that I only see the line when my lines actually are too long. -call matchadd('ColorColumn', '\%82v', 100) - -" Prevent K from being annoying -noremap K - -" Edit and Reload .vimrc files -" -" When I hit something that bugs me, I usually think about what I can -" do to make it better. Then I forget. This keeps happening and I keep -" getting annoyed. These commands make it simple to quickly edit my -" vimrc, and then reload it. -nmap ev :e $MYVIMRC -nmap es :so $MYVIMRC - -" Search options -" -" Show partial matches while searching -set incsearch - -" Highlight other matches in the file -set hlsearch - -" Show the next search result. -" By Damian Conway. -" -" This rewires n and N to do their normal thing, and then call the -" HLNext routine. This temporarily adds a new style to the next -" highlight. -nnoremap n n:call HLNext(0.2) -nnoremap N N:call HLNext(0.2) - -" Blink the next match -function! HLNext (blinktime) - let [bufnum, lnum, col, off] = getpos('.') - let matchlen = strlen(matchstr(strpart(getline('.'),col-1),@/)) - let target_pat = '\c\%#'.@/ - let ring = matchadd('MBSearchNext', target_pat, 101) - redraw - exec 'sleep ' . float2nr(a:blinktime * 1000) . 'm' - call matchdelete(ring) - redraw -endfunction - -" Disable match-paren -" -" It has really bad colours and it displays terribly. -" let loaded_matchparen = 1 - -" Make searches case sensitive only if an upper case character has been typed -set ignorecase smartcase - -" Prevent Vim from clobbering the scrollback buffer. -" -" This means that all of Vim's output is shown in the terminal screen -" history. This is ugly, but it's saved my bacon a few times. See -" http://www.shallowsky.com/linux/noaltscreen.html -set t_ti= t_te= - -" Highlight current line -" -" It's good to have a sense of place. -set cursorline - -" Ensure that the cursor never touches top or bottom of screen -" -" This controls the distance that the current line must maintain -" between the top and bottom of the screen. Setting this to a very -" large number will always keep the cursor vertically centered. -" -" I don't do this, because sometimes I wish to see something at the -" bottom of the buffer, so I can copy it at the top. -set scrolloff=4 - -" Allow backspacing over everything in insert mode -" -" By default, Vim will stop when it gets to the beginning of a line, -" throw its arms in the air and give up. -set backspace=indent,eol,start - -" Display incomplete commands and the lines they apply to. -set showcmd - -" Allow hidden buffers -" -" If this is off, buffers are destroyed when they fade out of view. We -" have the memory to spare to keep them around. -set hidden - -" Enable highlighting for syntax -syntax on - -" Enable file type detection. -" -" Use the default filetype settings, so that mail gets 'tw' set to 72, -" 'cindent' is on in C files, etc. -" Also load indent files, to automatically do language-dependent -" indenting. -filetype plugin indent on - -" Insert only one space when joining lines that contain -" sentence-terminating punctuation like `.`. -set nojoinspaces - -" If a file is changed outside of vim, automatically reload it -set autoread - -" Show trailing whitespace, since it's a crime -set list -set listchars=trail:·,tab:‣\ - -" Turn off code folding -" -" I hate code folding. It makes me mad. I just want a buffer with all -" of my text in it, no funny business. -set foldmethod=manual -set nofoldenable -let g:vim_markdown_folding_disabled=1 -let g:vimtex_fold_enabled=0 - -" Always show status bar -set laststatus=2 - -" Pastetoggle to let Vim paste things without auto stuff -set pastetoggle= - -"""""""""""""""""" -" Ultisnips, y'all -"""""""""""""""""" - -let g:UltiSnipsExpandTrigger="" -let g:UltiSnipsJumpForwardTrigger="" -let g:UltiSnipsJumpBackwardTrigger="" - -"""""""" -" VDebug -"""""""" - -let g:vdebug_options={} -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 -let g:vdebug_options['path_maps']={ - \'/mnt/www': getcwd() -\} - -""""""""""""" -" Local vimrc -""""""""""""" - -" Just load automatically, never ask me. -let g:localvimrc_ask=0 - -"""""""" -" Python -"""""""" - -let g:pymode_python = 'python3' - -""""""""""""""""" -" Custom autocmds -""""""""""""""""" - -augroup vimrcEx - " Clear all autocmds in the group - autocmd! - autocmd FileType text setlocal textwidth=78 - " Jump to last cursor position unless it's invalid or in an event handler - autocmd BufReadPost * - \ if line("'\"") > 0 && line("'\"") <= line("$") | - \ exe "normal g`\"" | - \ endif - - " Language whitespace settings - autocmd FileType dockerfile,less,snippets,json,c,xml,java,php,python setl et sw=4 sts=4 - autocmd FileType make,markdown setl noet sw=8 sts=8 ts=8 - - " Hard wrap prose - " - " This will automatically insert a new line in insert mode when a - " line gets too long (above 80 characters). I can also run gqap - " in normal mode to reflow a paragraph. - autocmd FileType - \ markdown, - \ setl tw=80 fo=t1 - -augroup END - -" Make directories in a filename if they don't exist. - -function! AskQuit (msg, options, quit_option) - if confirm(a:msg, a:options) == a:quit_option - exit - endif -endfunction - -function! EnsureDirExists () - let required_dir = expand("%:h") - if !isdirectory(required_dir) - try - call mkdir( required_dir, 'p' ) - catch - echom "Could not create directory" - exit - endtry - endif -endfunction - -augroup AutoMkdir - autocmd! - autocmd BufNewFile * :call EnsureDirExists() -augroup END - -" Set the statusline. -" This shows something like: -" -" [vim/vimrc.symlink] [351,30] [vim] -set statusline=[%f] " filename -set statusline+=\ [%l,\ %c] "line and column number -set statusline+=\ %y " filetype -set statusline+=\ %{ALEGetStatusLine()} - -" Ale -" -" An asynchronous linting engine. -let g:ale_lint_on_text_changed = 1 -let g:ale_linters = { - \ 'javascript': [ 'eslint' ], - \ 'php': [ 'php', 'phpcs' ], - \ 'json': [ 'jsonlint' ] -\ } - -" Hallelujah! -let g:ale_set_signs = 1 -let g:ale_sign_column_always = 1 -let g:ale_sign_error = '--' -let g:ale_sign_warning = '--' - -let g:ale_php_phpcs_standard = 'PSR2' -let g:ale_javascript_eslint_options = '--no-ignore ' - -" Gitgutter - -let g:gitgutter_realtime = 1 -let g:gitgutter_eager = 1 - -" JSX in mah JavaScript -let g:jsx_ext_required = 0 - -" Copy visual selection to clipboard. -noremap y "*y - -" Go to most recently edited file -nnoremap - -" Disable syntax hiding in JSON -" -" Vim JSON provides a fancy way of viewing, where it hides quotes and -" just shows you data. I don't want that. -let g:vim_json_syntax_conceal = 0 - -" Show syntax highlighting groups for word under cursor -" -" This is useful for finding rogue elements I forgot in my colour -" scheme. -nnoremap \ :call SynStack() -function! SynStack() - if !exists("*synstack") - return - endif - echo map(synstack(line('.'), col('.')), 'synIDattr(v:val,"name")') -endfunc -