summaryrefslogtreecommitdiffstats
path: root/vim/vimrc
blob: 682df2ba860362607ea8c8c17030e5b7f70bf3be (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
" New vimrc! Jan 2020
"
" We want to load this first - everything else I include overrides it
runtime! plugin/sensible.vim

set nocompatible
set backspace=indent,eol,start

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\