Last active
December 7, 2016 21:31
-
-
Save tcolgate/14e8cb88c02c21eee8de076c92269e0f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| set nofoldenable " disable folding | |
| filetype plugin on | |
| filetype indent on | |
| "set number | |
| "set spell spelllang=en_gb | |
| " Persist undo | |
| if has('persistent_undo') | |
| set undodir=$HOME/.vimundo | |
| set undolevels=5000 | |
| set undofile | |
| endif | |
| " When shifting, retain selection over multiple shifts... | |
| vmap <expr> > KeepVisualSelection(">") | |
| vmap <expr> < KeepVisualSelection("<") | |
| function! KeepVisualSelection(cmd) | |
| set nosmartindent | |
| if mode() ==# "V" | |
| return a:cmd . ":set smartindent\<CR>gv" | |
| else | |
| return a:cmd . ":set smartindent\<CR>" | |
| endif | |
| endfunction | |
| set tabstop=2 shiftwidth=2 expandtab | |
| set scrolloff=4 | |
| nnoremap <F2> :set invpaste paste?<CR> | |
| set pastetoggle=<F2> | |
| set showmode | |
| set nosol | |
| set virtualedit=block | |
| imap <c-l> <c-g>u<Esc>[s1z=`]a<c-g>u | |
| vmap <expr> ++ VMATH_YankAndAnalyse() | |
| nmap ++ vip++ | |
| imap <c-l> <c-g>u<Esc>[s1z=`]a<c-g>u | |
| execute pathogen#infect() | |
| syntax on | |
| let g:syntastic_always_populate_loc_list = 1 | |
| filetype plugin indent on | |
| set ofu=syntaxcomplete#Complete | |
| set iskeyword=-,:,@,48-57,_,192-255 | |
| set tags=./tags,./../tags,./../../tags,./../../../tags,tags | |
| set path=./**,/home/tristan/go/src/**,/home/tristan/include,/usr/local/include,/usr/include | |
| function! GitTagMessage() | |
| let branch = system('git branch --color=never | fgrep \* | sed "s/\* //"') | |
| let datestr = strftime('%Y.%m.%d %H:%M') | |
| let uname = system('git config --get user.name') | |
| let uemail = system('git config --get user.email') | |
| let line = branch . ' ' . datestr . ' by ' . uname . ' <' . uemail . '>' | |
| call setline(line('.'), substitute(line, "\n", "", "g")) | |
| endfunction | |
| if !exists("autocommands_loaded") | |
| let autocommands_loaded = 1 | |
| au BufNewFile,BufRead TAG_EDITMSG call GitTagMessage() | |
| au BufNewFile,BufRead COMMIT_EDITMSG setlocal spell | |
| endif | |
| let g:SuperTabDefaultCompletionType = "context" | |
| "color breeze | |
| color edit_wb | |
| set cursorline | |
| set mouse=a | |
| set go+=a | |
| set visualbell noerrorbells t_vb= | |
| autocmd GUIEnter * set visualbell t_vb= | |
| set incsearch "Lookahead as search pattern is specified | |
| set ignorecase "Ignore case in all searches... | |
| set smartcase "...unless uppercase letters used | |
| set hlsearch | |
| " Highlight trailing whitespace, and leading tabs, as errors, sorry python | |
| match ErrorMsg '\s\+$' | |
| " match ErrorMsg '^\t\+' | |
| " Removes trailing spaces | |
| function! TrimWhiteSpace() | |
| %s/\s\+$//e | |
| endfunction | |
| nnoremap <silent> <Leader>rts :call TrimWhiteSpace()<CR> | |
| autocmd FileType puppet autocmd FileWritePre * :call TrimWhiteSpace() | |
| autocmd FileType puppet autocmd FileAppendPre * :call TrimWhiteSpace() | |
| autocmd FileType puppet autocmd FilterWritePre * :call TrimWhiteSpace() | |
| autocmd FileType puppet autocmd BufWritePre * :call TrimWhiteSpace() | |
| au BufEnter *.vps set nocursorline | |
| au BufEnter *.vpa set nocursorline | |
| au BufEnter *.vpf set nocursorline | |
| au BufEnter *.vpi set nocursorline | |
| au BufEnter *.vpe set nocursorline | |
| au CursorHold *.vpa set nocursorline | |
| "======[ Magically build interim directories if necessary ]=================== | |
| 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) | |
| call AskQuit("Parent directory '" . required_dir . "' doesn't exist.", | |
| \ "&Create it\nor &Quit?", 2) | |
| try | |
| call mkdir( required_dir, 'p' ) | |
| catch | |
| call AskQuit("Can't create '" . required_dir . "'", | |
| \ "&Quit\nor &Continue anyway?", 1) | |
| endtry | |
| endif | |
| endfunction | |
| augroup AutoMkdir | |
| autocmd! | |
| autocmd BufNewFile * :call EnsureDirExists() | |
| augroup END | |
| "=====[ Add or subtract comments ]=============================== | |
| " Work out what the comment character is, by filetype... | |
| autocmd BufNewFile,BufRead * let b:cmt = exists('b:cmt') ? b:cmt : '' | |
| autocmd FileType *sh,awk,python,perl,perl6,ruby,puppet let b:cmt = exists('b:cmt') ? b:cmt : '#' | |
| autocmd FileType vim let b:cmt = exists('b:cmt') ? b:cmt : '"' | |
| " Work out whether the line has a comment then reverse that condition... | |
| function! ToggleComment () | |
| " What's the comment character??? | |
| let comment_char = exists('b:cmt') ? b:cmt : '#' | |
| " Grab the line and work out whether it's commented... | |
| let currline = getline(".") | |
| " If so, remove it and rewrite the line... | |
| if currline =~ '^' . comment_char | |
| let repline = substitute(currline, '^' . comment_char, "", "") | |
| call setline(".", repline) | |
| " Otherwise, insert it... | |
| else | |
| let repline = substitute(currline, '^', comment_char, "") | |
| call setline(".", repline) | |
| endif | |
| endfunction | |
| " Toggle comments down an entire visual selection of lines... | |
| function! ToggleBlock () range | |
| " What's the comment character??? | |
| let comment_char = exists('b:cmt') ? b:cmt : '#' | |
| " Start at the first line... | |
| let linenum = a:firstline | |
| " Get all the lines, and decide their comment state by examining the first... | |
| let currline = getline(a:firstline, a:lastline) | |
| if currline[0] =~ '^' . comment_char | |
| " If the first line is commented, decomment all... | |
| for line in currline | |
| let repline = substitute(line, '^' . comment_char, "", "") | |
| call setline(linenum, repline) | |
| let linenum += 1 | |
| endfor | |
| else | |
| " Otherwise, encomment all... | |
| for line in currline | |
| let repline = substitute(line, '^\('. comment_char . '\)\?', comment_char, "") | |
| call setline(linenum, repline) | |
| let linenum += 1 | |
| endfor | |
| endif | |
| endfunction | |
| " Set up the relevant mappings | |
| nmap <silent> # :call ToggleComment()<CR>j0 | |
| vmap <silent> # :call ToggleBlock()<CR> | |
| " Sytastic settings | |
| let g:syntastic_auto_loc_list=1 | |
| let g:syntastic_check_on_open=1 | |
| let g:syntastic_error_symbol='E' | |
| let g:syntastic_warning_symbol='W' | |
| let g:syntastic_go_checkers = ['go','golint', 'govet', 'errcheck'] | |
| let g:go_list_type = "quickfix" | |
| " | |
| " | |
| " | |
| let g:github_user="tcolgate" | |
| let g:github_token="3fa67eccb4bcd6369e974b868dccaa8ea48813f8" | |
| let g:gist_clip_command = 'xclip -selection clipboard' | |
| let g:go_fmt_command = "goimports" | |
| au FileType go nmap <Leader>t :Tagbar<CR><C-w>l | |
| au FileType go nmap <Leader>s <Plug>(go-implements) | |
| au FileType go nmap <Leader>i <Plug>(go-info) | |
| au FileType go nmap <Leader>l :GoLint<CR> | |
| au FileType go nmap <Leader>v <Plug>(go-vet) | |
| au FileType go nmap <Leader>gd <Plug>(go-doc) | |
| au FileType go nmap <Leader>gv <Plug>(go-doc-vertical) | |
| let g:flake8_show_in_file=1 | |
| au BufWritePost *.py call Flake8() | |
| function! VimuxSlime() | |
| call VimuxSendText(@v) | |
| call VimuxSendKeys("Enter") | |
| endfunction | |
| " If text is selected, save it in the v buffer and send that buffer it to tmux | |
| vmap <LocalLeader>vs "vy :call VimuxSlime()<CR> | |
| " Select current paragraph and send it to tmux | |
| nmap <LocalLeader>vs vip<LocalLeader>vs<CR> | |
| set incsearch | |
| let g:netrw_liststyle=2 | |
| let g:calendar_google_calendar = 1 | |
| let g:calendar_google_tasks = 1 | |
| nmap ; : | |
| vmap ; :Blockwise<SPACE> | |
| let g:netrw_banner = 0 | |
| let g:netrw_liststyle = 3 | |
| let g:netrw_browse_split = 4 | |
| let g:netrw_altv = 1 | |
| let g:netrw_winsize = 25 | |
| set wildchar=<Tab> wildmenu wildmode=full |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment