/
vimrc
312 lines (272 loc) · 9.12 KB
/
vimrc
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
" vim-plug
call plug#begin('~/.vim/plugged')
Plug 'JulesWang/css.vim', { 'for': 'css' }
Plug 'airblade/vim-gitgutter'
Plug 'altercation/vim-colors-solarized'
Plug 'ap/vim-css-color', { 'for': 'css' }
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'briancollins/vim-jst', { 'for': 'jst' }
Plug 'ekalinin/Dockerfile.vim', { 'for': 'Dockerfile' }
Plug 'fatih/vim-go', { 'do': ':GoInstallBinaries' }
Plug 'groenewege/vim-less', { 'for': 'less' }
Plug 'hashivim/vim-terraform', { 'for': 'terraform' }
Plug 'kien/ctrlp.vim'
Plug 'majutsushi/tagbar'
Plug 'mitsuhiko/vim-jinja', { 'for': 'jinja' }
Plug 'mitsuhiko/vim-python-combined', { 'for': 'python' }
Plug 'nazo/pt.vim'
Plug 'othree/html5.vim', { 'for': 'html' }
Plug 'pangloss/vim-javascript', { 'for': 'javascript' }
Plug 'pearofducks/ansible-vim', { 'for': 'ansible' }
Plug 'tangledhelix/vim-kickstart', { 'for': 'kickstart' }
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-unimpaired'
Plug 'tpope/vim-git'
Plug 'MaxMEllon/vim-jsx-pretty'
Plug 'leafgarland/typescript-vim'
Plug 'google/vim-jsonnet'
Plug 'chrisbra/unicode.vim'
Plug 'jremmen/vim-ripgrep'
" Plug 'sjl/splice.vim'
Plug 'errael/splice9'
Plug 'yasuhiroki/github-actions-yaml.vim'
Plug 'neoclide/coc.nvim', {'branch': 'release', 'for': 'typescript*'}
call plug#end()
filetype plugin on
syntax on
scriptencoding utf-8
"
" options
"
" os/terminal
if !has('nvim')
set clipboard=exclude:.* " disable connecting to X11 (hangs on putty/ssh session)
endif
set noswapfile
set printoptions=number:y,paper:letter,syntax:n
if !has('nvim')
set term=xterm-256color " force term due to inkpot 256 colors
endif
set title " set the title of the terminal
set ttyfast
if &term ==? "xterm"
set t_Sb=^[4%dm
set t_Sf=^[3%dm
set ttymouse=xterm2
endif
" style/formatting
set autoindent
set colorcolumn=100
set expandtab
set ignorecase
set nowrap
set shiftwidth=4
set smartindent
set smarttab
set softtabstop=4
set tabstop=4
"colorscheme inkpot
set background=dark
let g:solarized_termcolors=256
let g:solarized_termtrans=1
colorscheme solarized
" highlight >--- with a better color from inkpot, X(82) vs inkpots X(55)
au BufEnter * hi SpecialKey cterm=BOLD ctermfg=237 ctermbg=NONE
" general
set backspace=2
set cscopetag
set nofileignorecase " so Build* doesn't match build.go
set foldenable
set foldmethod=marker
set history=50
set hlsearch
set noincsearch
set laststatus=2
set list
set listchars=
set listchars=extends:$,precedes:$,tab:¬\ ,trail:.
set mouse=
set nocompatible
set nomodeline
set ruler
set scrolloff=3
set showcmd
set showmatch
set suffixes+=.log,.out
set viminfo='20,<100,%
set wildmenu
set wildignore=*.pyc,*.obj,*.o,*.lo
"
" key mappings
"
nnoremap <leader><space> :noh<cr>
nnoremap <leader>sync :syntax sync fromstart<cr>
nnoremap <leader>b :<C-U>CtrlPBuffer<CR>
nnoremap <leader>lc :lclose<CR>
" don't outdent comment lines when they are smartindented help smartindent
inoremap # X#
" Don't use Ex mode, use Q for formatting
map Q gq
" q: is annoying
nmap q: :q
"
" other
"
" make % work in html and other files
runtime macros/matchit.vim
source $VIMRUNTIME/ftplugin/man.vim " make :Man command available
" default MANPAGER vimmanpager doesn't play well
" with the :Man command and we don't want to see raw colour codes
" so we use sed to strip them.
let $MANPAGER = "sed -e 's:\\x1B\\[[[:digit:]]\\+m::g'"
"
" auto...
"
autocmd BufRead,BufNewFile *.as setlocal ft=actionscript
autocmd BufRead,BufNewFile *.c setlocal ts=2 sw=2 sts=2 nocin
autocmd BufRead,BufNewFile *.cc setlocal ts=2 sw=2 sts=2 nocin
autocmd BufRead,BufNewFile *.h setlocal ts=2 sw=2 sts=2 nocin
autocmd BufRead,BufNewFile *.css setlocal ts=2 sw=2 sts=2
autocmd BufRead,BufNewFile *.haml setlocal ts=2 sw=2 sts=2
autocmd BufRead,BufNewFile *.html setlocal ts=2 sw=2 sts=2
autocmd BufRead,BufNewFile *.jinja setlocal ft=htmljinja ts=2 sw=2 sts=2
autocmd BufRead,BufNewFile *.js setlocal ts=2 sw=2 sts=2
autocmd BufRead,BufNewFile *.jst setlocal ft=jst ts=2 sw=2 sts=2
autocmd BufRead,BufNewFile *.less setlocal ft=less ts=2 sw=2 sts=2
autocmd BufRead,BufNewFile *.md setlocal ft=markdown
autocmd BufRead,BufNewFile *.proto setlocal ts=2 sw=2 sts=2
autocmd BufRead,BufNewFile *.rb setlocal ts=2 sw=2 sts=2
autocmd BufRead,BufNewFile *.tf setlocal ts=2 sw=2 sts=2
autocmd BufRead,BufNewFile *.tst setlocal syntax=perl
autocmd BufRead,BufNewFile *.txt setlocal printoptions+=number:n
autocmd BufRead,BufNewFile *.scss setlocal ft=scss ts=2 sw=2 sts=2
autocmd BufRead,BufNewFile *.yml setlocal ts=2 sw=2 sts=2
autocmd BufRead,BufNewFile *.yaml setlocal ts=2 sw=2 sts=2
autocmd BufRead,BufNewFile *.yaml.tmpl setlocal ft=yaml ts=2 sw=2 sts=2
autocmd BufRead,BufNewFile Build* setlocal noexpandtab filetype=make syntax=make
autocmd BufRead,BufNewFile Jenkinsfile setlocal ft=groovy
autocmd BufRead,BufNewFile hg-editor-*.txt setlocal syntax=hgcommit
autocmd BufRead,BufNewFile inv/* setlocal syntax=ansible_hosts
autocmd BufRead,BufNewFile inventory/* setlocal syntax=ansible_hosts
autocmd BufRead,BufNewFile go.mod setlocal noexpandtab
autocmd BufRead,BufNewFile [Mm]ake* setlocal noexpandtab filetype=make syntax=make
autocmd BufRead,BufNewFile Rakefile setlocal ts=2 sw=2 sts=2
autocmd BufRead,BufNewFile Vagrantfile setlocal ft=ruby ts=2 sw=2 sts=2
autocmd FileType crontab set backupcopy=yes
autocmd FileType jsonnet set ts=2 sw=2 sts=2
autocmd FileType typescript* set ts=2 sw=2 sts=2
" gitgutter
highlight GitGutterAdd ctermbg=none
highlight GitGutterChange ctermbg=none
highlight GitGutterDelete ctermbg=none
highlight SignColumn ctermbg=none
" AFAICT, gitgutter is busted because it never updates; force it to run
" when writing the file
au BufWritePost * :GitGutter
" golang
au FileType go nmap <leader>r <Plug>(go-run)
au FileType go nmap <leader>b <Plug>(go-build)
au FileType go nmap <leader>t <Plug>(go-test)
au FileType go nmap <leader>tc <Plug>(go-test-compile)
au FileType go nmap <leader>T <Plug>(go-test-func)
au FileType go nmap <leader>TF <Plug>(go-test-file)
au FileType go nmap <leader>c <Plug>(go-coverage)
au FileType go nmap <Leader>ds <Plug>(go-def-split)
au FileType go nmap <Leader>dv <Plug>(go-def-vertical)
au FileType go nmap <Leader>dt <Plug>(go-def-tab)
au FileType go nmap <Leader>gd <Plug>(go-doc)
au FileType go nmap <Leader>gv <Plug>(go-doc-vertical)
au FileType go nmap <Leader>gb <Plug>(go-doc-browser)
au FileType go nmap <Leader>s <Plug>(go-implements)
au FileType go nmap <Leader>i <Plug>(go-info)
au FileType go nmap <Leader>e <Plug>(go-rename)
let g:go_highlight_functions = 1
let g:go_highlight_methods = 1
let g:go_highlight_fields = 1
let g:go_highlight_types = 1
let g:go_highlight_operators = 1
let g:go_highlight_build_constraints = 1
" restore last cursor position
autocmd BufReadPost *
\ if line("'\"") > 0 && line ("'\"") <= line("$") |
\ exe "normal g'\"" |
\ endif |
" fancier editing of binaries
augroup Binary
au!
au BufReadPre *.bin let &bin=1
au BufReadPost *.bin if &bin | silent %!xxd
au BufReadPost *.bin set ft=xxd | endif
au BufWritePre *.bin if &bin | silent %!xxd -r
au BufWritePre *.bin endif
au BufWritePost *.bin if &bin | silent %!xxd
au BufWritePost *.bin set nomod | endif
augroup END
"
" plugins
"
" airline (theming)
let g:airline_detect_modified = 1
let g:airline_detect_paste = 1
"let g:airline_theme = 'badwolf'
"let g:airline_theme='laederon'
"let g:airline_theme='simple' " not very good during splits
let g:airline_mode_map = {
\ 'n' : 'normal',
\ 'i' : 'insert',
\ 'R' : 'rplace',
\ 'v' : 'visual',
\ 'V' : 'v-line',
\ 'c' : 'cmd ',
\ '' : 'v-blck',
\ }
let g:airline_left_sep = ''
let g:airline_right_sep = ''
let g:airline_linecolumn_prefix = '¶ '
let g:airline_branch_prefix = '⎇ '
let g:airline_paste_symbol = 'ρ'
let g:airline_section_z = '0x%-4B %3p%% '.g:airline_linecolumn_prefix.'%3l:%3c'
" ctrlp (fuzzy file/buf matching)
let g:ctrlp_custom_ignore = {
\ 'dir': '\v[\/]migrations$',
\ }
let g:ctrlp_working_path_mode = 'a'
let g:ctrlp_use_caching = 1
let g:ctrlp_clear_cache_on_exit = 0
" pt
let g:pt_prg = "pt --nogroup --nocolor"
" tagbar (tagging)
nnoremap <leader>t :TagbarOpen<cr>
let g:tagbar_autoclose = 1
let g:tagbar_compact = 1
let g:tagbar_sort = 0
let g:tagbar_width = 40
" yaml syntax is busted when VAR='blah' is used. First ' does not get
" recognized. this fixes it some
autocmd FileType yaml* syntax clear yamlFlowString
"
" coc + typescript
"
let g:coc_global_extensions = ['coc-go', 'coc-tsserver']
autocmd FileType yaml* syntax clear yamlFlowString
" Remap keys for applying codeAction to the current line.
nmap <leader>ac <Plug>(coc-codeaction)
" Apply AutoFix to problem on the current line.
nmap <leader>qf <Plug>(coc-fix-current)
" GoTo code navigation.
nmap <silent> cd <Plug>(coc-definition)
nmap <silent> cy <Plug>(coc-type-definition)
nmap <silent> ci <Plug>(coc-implementation)
nmap <silent> cr <Plug>(coc-references)
":python << EOF
"import os
"virtualenv = os.environ.get('VIRTUAL_ENV')
"if virtualenv:
" activate_this = os.path.join(virtualenv, 'bin', 'activate_this.py')
" if os.path.exists(activate_this):
" execfile(activate_this, dict(__file__=activate_this))
"EOF
source ~/.vimrc.local