-
Notifications
You must be signed in to change notification settings - Fork 0
/
dot_vimrc.tmpl
322 lines (287 loc) · 7.85 KB
/
dot_vimrc.tmpl
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
313
314
315
316
317
318
319
320
321
"---------
" ~/.vimrc
"---------
" Settings
" basics
set nocompatible
set encoding=utf-8
set number
set secure
" ui
set ruler
set noshowmode
set lazyredraw
set showcmd
set nospell
" remove hit-enter prompts for intro
set shortmess+=I
" for :set list
set listchars=tab:▸\ ,extends:❯,precedes:❮,nbsp:␣,eol:→
" theming
syntax on
set synmaxcol=1000 " don't render lines > 300 chars
{{ if not .uses_wal -}}
colorscheme delucks
{{- end }}
if !has('gui_running')
set t_Co=256
endif
" enables a completion menu over the statusline
set wildmenu
set wildmode=full
" searching
set ignorecase
set smartcase
set incsearch
set hlsearch
" Overrides case search behavior in completion box
set infercase
" editing
set autoindent
set foldmethod=manual
set history=100
set splitright
set laststatus=2
" text wrapping
set wrap
set sidescroll=1
" write swap file after 10 characters
set updatecount=10
" control what we can backspace over in insert
set backspace=indent,eol,start
" let us edit text that's not there in block mode
set virtualedit=block
" tab width
set shiftwidth=2
set tabstop=2
set expandtab
set tw=0
" misc
let g:sh_no_error = 1
let g:markdown_fenced_languages = ['python', 'java', 'sh', 'vim', 'clojure']
" ignore the following files (or give low preference)
set suffixes=.bak,.pyc,.swp,.o,.out,.pyo,.jpg,.png,.gif,.class
let g:netrw_liststyle=2
if executable("rg")
set grepprg=ag
elseif executable("ack")
set grepprg=ack
endif
if v:version >= 703
augroup PythonColumn
autocmd!
autocmd FileType python setlocal colorcolumn=160
augroup END
set undodir=~/.vim/undo
set undofile
set undolevels=1000 "max number of changes that can be undone
set undoreload=10000 "max number lines to save for undo on buffer reload
endif
let @p = 'o- [](:r!xclip -okJf(lxA) - '
"--------
" Plugins
call plug#begin('~/.vim/plugins')
Plug 'fatih/vim-go', { 'for': 'go' } " enables gofmt on :w
Plug 'vim-airline/vim-airline' " draws buffers in tabline and colorizes the statusline
Plug 'ctrlpvim/ctrlp.vim' " fast fuzzy find buffer menu
Plug 'deris/vim-shot-f' " highlights the first match of a character in a line for f/t commands
Plug 'mhinz/vim-signify' " display version control hints
Plug 'junegunn/limelight.vim' " syntax highlight only the current paragraph
Plug 'benmills/vimux' " send commands to tmux
" Syntax Plugins
Plug 'PotatoesMaster/i3-vim-syntax'
Plug 'gleam-lang/gleam.vim'
Plug 'saltstack/salt-vim'
Plug 'hashivim/vim-terraform'
if executable("elixir")
Plug 'elixir-lang/vim-elixir', { 'for': 'elixir' } " better support
endif
{{ if .uses_wal -}}
Plug 'dylanaraps/wal.vim' " use the colorscheme generated by pywal
{{- end }}
call plug#end()
"---------------
" Plugin Options
{{ if .uses_wal -}}
colorscheme wal
{{- end }}
" Signify
let g:signify_vcs_list = [ 'git', 'svn' ]
let g:signify_line_highlight = 0
let g:signify_sign_change = '~'
let g:signify_sign_delete = '-'
" CtrlP options
let g:ctrlp_map = '<Leader>q'
let g:ctrlp_cmd = 'CtrlP'
" limelight.vim & vim-illuminate
nmap <silent> gl :Limelight!!<CR>
xmap gl <Plug>(Limelight)
let g:limelight_conceal_ctermfg = 8
let g:limelight_paragraph_span = 0
" Buftabline
let g:buftabline_show=1
let g:buftabline_numbers=0
let g:buftabline_separators=0
" Airline
let g:airline#extensions#tabline#enabled = 1
let g:airline_left_sep=''
let g:airline_right_sep=''
let g:airline_theme='dark'
let g:airline_symbols_ascii = 1
let g:airline#extensions#tabline#left_sep = ''
let g:airline#extensions#tabline#left_alt_sep = ''
" ale
let g:airline#extensions#ale#enabled = 1
"let g:ale_echo_msg_format = '[%linter%] %s'
let g:ale_lint_delay = 2000
let g:ale_lint_on_text_changed = 'never'
" vim-go
let g:go_fmt_command = "goimports"
"---------
" Keybinds
" Enhancements
nmap j gj
nmap k gk
nnoremap <Space> :
nnoremap n nzz
nnoremap J mzJ`z
cmap w!! %!sudo tee > /dev/null %
" improve my search and replace workflow
nmap S :%s//g<LEFT><LEFT>
nmap <expr> M ':%s/' . @/ . '//g<LEFT><LEFT>'
" get rid of some keys
nnoremap <F1> <nop>
nnoremap Q <nop>
" Buffer Manipulation
nnoremap <Tab> :b<space>
" way better than default
nmap <left> :bp<CR>
nmap <right> :bn<CR>
nnoremap <PageUp> :bn<CR>
nnoremap <PageDown> :bp<CR>
nmap <up> :%foldopen<CR>
nmap <down> :%foldclose<CR>
" Window movement
nmap <C-h> <C-W><C-H>
nmap <C-j> <C-W><C-J>
nmap <C-k> <C-W><C-K>
nmap <C-l> <C-W><C-L>
" this allows you to change the next and previous matches for the current word
nnoremap c* *Ncgn
nnoremap c# #NcgN
" Make the current buffer suitable for direct copy-pasting out of a terminal window
function! CopyMode()
setlocal number!
setlocal ruler!
setlocal showcmd!
:SignifyToggle
:AirlineToggle
if &laststatus
set laststatus=0
else
set laststatus=2
endif
endfunction
"---------------
" Leader Mappings
"
" n CopyMode
nnoremap <Leader>n :call CopyMode()<CR>
" vimux Commands
" tc Tmux Command
nmap <Leader>tc :VimuxPromptCommand<CR>
" tl Tmux Last
nmap <Leader>tl :VimuxRunLastCommand<CR>
" tx Tmux interrupt
nmap <Leader>tx :VimuxInterruptRunner<CR>
" tz Tmux Zoom
nmap <Leader>tz :VimuxZoomRunner<CR>
" ts Tmux shell (jump to runner)
nmap <Leader>ts :VimuxInspectRunner<CR>
" v version control prev hunk
" V version control next hunk
nmap <Leader>v <plug>(signify-next-hunk)
nmap <Leader>V <plug>(signify-prev-hunk)
" q CtrlP from current dir
" a CtrlP Buffers
nnoremap <silent> <Leader>q :CtrlP<CR>
nnoremap <silent> <Leader><Tab> :CtrlPBuffer<CR>
" e Explore menu in a split
nnoremap <silent> <Leader>e :Lexplore<CR>
" s Recompute syntax highlighting
nnoremap <silent> <Leader>s :syntax sync fromstart<CR>
" w Prev buffer
" b Next buffer
nnoremap <silent> <Leader>w :bn<CR>
nnoremap <silent> <Leader>b :bp<CR>
" c Close buffer
nnoremap <silent> <Leader>c :bd<CR>
" h Focus one buffer to the left
" j Focus one buffer down
" k Focus one buffer up
" l Focus one buffer to the right
nmap <Leader>h <C-W><C-H>
nmap <Leader>j <C-W><C-J>
nmap <Leader>k <C-W><C-K>
nmap <Leader>l <C-W><C-L>
" H Move buffer to the left
" J Move buffer down
" K Move buffer up
" L Move buffer to the right
nmap <Leader><S-h> :winc H<CR>
nmap <Leader><S-j> :winc J<CR>
nmap <Leader><S-k> :winc K<CR>
nmap <Leader><S-l> :winc L<CR>
" / Clear search highlight
nnoremap <silent> <Leader>/ :noh<CR>
" Copy/paste from X
nmap <Leader>p :r!xclip --clipboard primary -o <CR>
vmap <Leader>y :!xclip -f -sel clip<CR>
"-------------
" Autocommands
" Reload ~/.vimrc after saving
augroup ReloadVimrc
autocmd!
autocmd bufwritepost .vimrc source %
augroup END
" jump to last used position in every file
augroup JumpToPosition
autocmd!
autocmd bufreadpost * normal `"
augroup END
" resize splits when the terminal is resized
augroup ResizeWindows
autocmd!
autocmd VimResized * wincmd =
augroup END
" filetype-specific commands
augroup FileSpecific
autocmd!
autocmd FileType python
\ setlocal shiftwidth=4 |
\ setlocal tabstop=4 |
\ setlocal expandtab |
\ setlocal nowrap
autocmd FileType sh
\ setlocal shiftwidth=2 |
\ setlocal tabstop=2 |
autocmd FileType go
\ setlocal nowrap
autocmd FileType java
\ setlocal shiftwidth=4 |
\ setlocal tabstop=4
autocmd FileType vim
\ map K :execute('vert help ' . expand("<cword>"))<CR><C-w><C-h>
autocmd BufRead,BufNewFile *.md
\ set filetype=markdown |
\ set complete+=k |
\ set syntax=off
autocmd BufRead,BufNewFile /tmp/jrnl*
\ set syntax=off |
\ set nowrap
augroup END
" Allow for each machine to override global settings
if !empty(glob("~/.localvimrc"))
source ~/.localvimrc
endif