summaryrefslogtreecommitdiffstats
path: root/vim
diff options
context:
space:
mode:
Diffstat (limited to 'vim')
-rw-r--r--vim/vimrc145
1 files changed, 145 insertions, 0 deletions
diff --git a/vim/vimrc b/vim/vimrc
new file mode 100644
index 0000000..a051efc
--- /dev/null
+++ b/vim/vimrc
@@ -0,0 +1,145 @@
+" New vimrc! Jan 2020
+"
+" We want to load this first - everything else I include overrides it
+runtime! plugin/sensible.vim
+
+set nocompatible
+
+syntax on
+filetype indent on
+filetype plugin on
+
+set omnifunc=syntaxcomplete#Complete
+
+" Do not scan included files when doing autocomplete
+" When doing C-n in default Vim autocomplete, it looks through all
+" includes which can take time. We can turn it off... This is referenced
+" at https://stackoverflow.com/questions/2169645/vims-autocomplete-is-excruciatingly-slow
+" and on p287 of Practical Vim
+set complete-=i
+
+"vim-go
+let test#go#runner = 'gotest'
+
+let g:go_term_mode = "split"
+let g:go_term_height = 10
+"autocmd FileType go nmap <leader>r :w<CR>:split <bar> terminal go run %<CR>
+autocmd FileType go nmap <leader>r :GoRun<CR>
+" highlights the variable in the file for you..
+"let g:go_auto_sameids = 1
+" auto import...
+let g:go_fmt_command = "goimports"
+" automatic type info on cursor
+let g:go_auto_type_info = 1
+"let g:go_snippet_engine = "neosnippet"
+au Filetype go nmap <leader>ga <Plug>(go-alternate-edit)
+au Filetype go nmap <leader>gah <Plug>(go-alternate-split)
+au Filetype go nmap <leader>gav <Plug>(go-alternate-vertical)
+au FileType go nmap <F10> :GoTest -short<cr>
+au FileType go nmap <F9> :DlvToggleBreakpoint<CR>
+au FileType go nmap <S-F9> :DlvTest<CR>
+au FileType go nmap <F11> :DlvDebug<CR>
+au FileType go nmap <S-F5> :GoRename<CR>
+
+" vim-test
+
+" use vim-dispatch to run tests in the quickfix window
+" from Modern Vim Ch.4
+" the mappings below are from vim-test
+" https://github.com/vim-test/vim-test
+" dispatch opens send test output to quickfix window
+let test#strategy = "vimterminal"
+let test#python#runner = "pytest"
+let test#neovim#term_position = "topleft"
+let test#python#pytest#options = '-vvv --tb=short'
+let test#go#runner = 'gotest'
+"let test#go#gotest#options = '-v'
+
+" To run mypy using vim-dispath -with Dispatch
+autocmd FileType python let b:dispatch = 'mypy --ignore-missing-imports'
+
+nmap <silent> t<C-n> :TestNearest<CR>
+nmap <silent> t<C-f> :TestFile<CR>
+nmap <silent> t<C-s> :TestSuite<CR>
+"nmap <silent> t<C-l> :TestLast<CR>
+nmap <silent> <S-F10> :TestLast<CR>
+nmap <silent> t<C-g> :TestVisit<CR>
+
+"backups/swap
+set swapfile
+set directory^=~/.vim/swap//
+set writebackup
+set nobackup
+
+" persist the undo tree for each file
+set undofile
+set undodir^=~/.vim/undo//
+
+" wildignore
+set wildignore=*.swp,*.bak,*.pyc,*.class
+set wildignore+=.hg,.git,.svn " Version control
+set wildignore+=*.aux,*.out,*.toc " LaTeX intermediate files
+set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg " binary images
+set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest " compiled object files
+set wildignore+=*.spl " compiled spelling word lists
+set wildignore+=*.sw? " Vim swap files
+set wildignore+=*.DS_Store " OSX bullshit
+set wildignore+=*.luac " Lua byte code
+set wildignore+=migrations " Django migrations
+set wildignore+=*.pyc " Python byte code
+set wildignore+=*.orig " Merge resolution files
+
+set visualbell
+set noerrorbells
+set splitbelow
+set splitright
+set autowrite
+set linebreak
+set fileencodings=utf-8
+set ttyfast
+"set t_Co=256
+set background=dark
+set path+=**
+set relativenumber
+set incsearch
+set hlsearch
+
+" make complete popupmenu better
+set completeopt=longest,menuone
+
+" leader
+let maplocalleader = "\\"
+let mapleader = ","
+
+" Ag
+if executable("ag")
+ set grepprg=ag\ --nogroup\ --nocolor\ --ignore-case\ --column
+ set grepformat=%f:%l:%c:%m,%f:%l:%m
+endif
+
+" maps
+nnoremap <leader>b :b <C-d>
+nnoremap <leader>g :grep<space>
+nnoremap <leader>q :b#<cr>
+nnoremap <leader><space> :noh<cr>:call clearmatches()<cr>
+nnoremap <leader>e :e ./**/
+
+" nice search in buffer
+" (example use :14 to select from menu)
+nnoremap <leader>S :g//#<left><left>
+
+" playing with Python syntax highlighting
+highlight pythonString cterm=NONE ctermbg=NONE ctermfg=65
+highlight pythonQuotes cterm=NONE ctermbg=NONE ctermfg=65
+highlight pythonBuiltin cterm=NONE ctermbg=NONE ctermfg=32
+
+" ghetto linting
+autocmd FileType python setlocal makeprg=flake8
+" this makes the quickfix window open automatically after
+autocmd QuickFixCmdPost [^l]* cwindow
+
+
+" nice statusline
+"set statusline=%-20F%m%r%h%w[%L][%{&ff}]%y[%p%%][%04l,%04v]
+"set statusline+=%{gutentags#statusline()}
+set statusline=%<\ %f\ %m%r%y%w%=\ L:\ \%l\/\%L\ C:\ \%c\