-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvimrc.local
More file actions
441 lines (363 loc) · 11.2 KB
/
vimrc.local
File metadata and controls
441 lines (363 loc) · 11.2 KB
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
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
" Vim configuration
scriptencoding utf-8
set confirm
set shell=/bin/bash
set shortmess+=c
set nobackup
set nowritebackup
set noswapfile
set signcolumn=yes
set termguicolors
set t_Co=256
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
" updatetime has performance impact
set updatetime=300
" timout for keys
set timeoutlen=500
" timeout esc sequence
set ttimeoutlen=20
set lazyredraw
set scrolljump=3
set synmaxcol=300
syntax sync minlines=256
" Allow project-specific .vimrc files
set exrc
set secure
" gvim
set guioptions=c
set guifont=Iosevka\ Nerd\ Font:h14
let g:nerdtree_tabs_open_on_gui_startup = 0
" Switch themes
function SaveTheme(theme)
if a:theme ==? "Dracula"
exec "silent ! rm /tmp/.vimrc 2>/dev/null &"
else
exec "silent ! echo 'autocmd VimEnter * :" . a:theme . "' > /tmp/.vimrc &"
endif
redraw!
endfunction
command Dracula colorscheme dracula | AirlineTheme dracula | set nocursorline | call SaveTheme("Dracula")
command Dark colorscheme torte | AirlineTheme dark | set nocursorline | call SaveTheme("Dark")
command Light colorscheme zellner | AirlineTheme dark | set cursorline | call SaveTheme("Light")
" Theme
let g:dracula_colorterm = 1
let g:dracula_italic = 1
colorscheme dracula
" Airline
let g:airline_theme = 'dracula'
let g:airline_extensions = ['branch', 'coc', 'tabline', 'quickfix']
let g:airline_highlighting_cache = 1
let g:airline_powerline_fonts = 1
let g:airline_skip_empty_sections = 0
let g:airline#extensions#coc#error_symbol = ' '
let g:airline#extensions#coc#warning_symbol = ' '
let g:airline#extensions#branch#vcs_priority = ["git"]
let g:airline#extensions#branch#vcs_checks = []
" Copy command
vnoremap <C-x> :!pbcopy<CR>
vnoremap <C-c> :w !pbcopy<CR><CR>
" Tab is the same as <C-i> and should jump forward
nunmap <Tab>
" Paste multiple times
xnoremap p "_dP
" Exit insert mode
inoremap jj <ESC>
inoremap jk <ESC>
imap <C-h> <Left>
imap <C-j> <Down>
imap <C-k> <Up>
imap <C-l> <Right>
" Yank consistency with other commands
nnoremap Y y$
" Save
nnoremap <C-s> :w<CR>
inoremap <C-s> <ESC>:w<CR>
" Saves the file (handling the permission-denied error)
cnoremap w!! w !sudo tee % >/dev/null
" Save without format
command Wnoformat noa w
cabbrev wn Wnoformat
cabbrev nw Wnoformat
" Load and save Vim config
command Reload source $MYVIMRC
command Config :e ~/dotfiles/vimrc.local
command ConfigPlugins :e ~/dotfiles/vimrc.local.bundles
" uuid
command Uuid :r !uuidgen
command UUID :r !uuidgen
command CopyFileName :let @+ = expand("%:p")
nnoremap <C-c> :CopyFileName<CR>
" Zoxide / Autojump
command -nargs=1 J Z <args>
" Ticket
command Ticket :execute "normal! A" . system('ticket')
" Abbreviations
cabbrev Ci CocInfo
cabbrev ci CocInfo
cabbrev Cr CocRestart
cabbrev cr CocRestart
cabbrev Cs CocSearch
cabbrev cs CocSearch
cabbrev Ft Filetypes
cabbrev ft Filetypes
cabbrev Re Reload
cabbrev re Reload
cabbrev Sn Snippets
cabbrev sn Snippets
" Date
inoremap <C-d> <C-R>=strftime("%Y-%m-%d")<CR>
cnoremap <C-d> <C-R>=strftime("%Y-%m-%d")<CR>
" Open links in browser
let g:netrw_nogx = 1
nmap gx <Plug>(openbrowser-smart-search)
vmap gx <Plug>(openbrowser-smart-search)
" Expand snippets
let g:UltiSnipsExpandTrigger='<Nop>'
" Multiple cursors
let g:multi_cursor_exit_from_visual_mode = 1
let g:multi_cursor_exit_from_insert_mode = 1
let g:multi_cursor_start_word_key = '<C-n>'
let g:multi_cursor_select_all_word_key = '<leader><C-n>'
" Multiple cursor fix for delimitmate issue with '"' char
function! Multiple_cursors_before()
exe 'DelimitMateOff'
endfunction
function! Multiple_cursors_after()
exe 'DelimitMateOn'
endfunction
" Ctags
set tags+=tags;tags.vendors;,tags;
" Search with Rg (overwrites vimrc)
nnoremap <silent> <leader>f :Rg<CR>
nnoremap <silent> <leader>F :Gcd<CR>:Rg<CR>
" Rg search command
command! -bang -nargs=* Rg
\ call fzf#vim#grep(
\ 'rg --hidden --column --line-number --no-heading --color=always --smart-case '.shellescape(<q-args>),
\ 1,
\ {'options': '--delimiter : --nth 2..'},
\ <bang>0)
" Close all other buffers
command! BufOnly silent! execute "%bd|e#|bd#"
noremap <silent> <leader>C :BufOnly<CR>
" Command to read windows files (crlf)
cabbrev windowsfile e ++ff=dos
cabbrev dosfile e ++ff=dos
" Ctrl backspace to delete words
noremap! <C-BS> <C-w>
noremap! <C-h> <C-w>
" Startify
let g:startify_files_number = 10
let g:startify_change_to_dir = 0
let startify_custom_header = split(system('toilet -f pagga " VIM"'), '\n')
let g:startify_enable_special = 0
autocmd User Startified nmap <buffer> e <leader>e
let g:startify_lists = [
\ {'type': 'files', 'header': [' Recently']},
\ {'type': 'commands', 'header': [' Commands']},
\ {'type': 'bookmarks', 'header': [' Bookmarks']},
\ ]
let g:startify_commands = []
let g:startify_bookmarks = [
\ {'d': '~/dotfiles'},
\ {'n': '~/dotfiles/nix/packages.nix'},
\ ]
" Rooter
let g:rooter_buftypes = ['']
let g:rooter_targets = '*'
let g:rooter_silent_chdir = 1
let g:rooter_patterns = [
\ 'spago.dhall',
\ 'package.json',
\ 'elm.json',
\ 'stack.yaml',
\ '.git/',
\ 'pom.xml',
\ 'requirements.txt'
\ ]
" Coc
let g:coc_global_extensions = [
\ '@yaegassy/coc-tailwindcss3',
\ 'coc-cspell-dicts',
\ 'coc-diagnostic',
\ 'coc-docker',
\ 'coc-eslint',
\ 'coc-java',
\ 'coc-json',
\ 'coc-markdownlint',
\ 'coc-prettier',
\ 'coc-rust-analyzer',
\ 'coc-snippets',
\ 'coc-spell-checker',
\ 'coc-tsserver',
\ 'coc-yaml',
\ 'coc-go',
\ ]
nmap <F5> :CocRebuild<CR>
nmap <leader>r :CocSearch <c-r><c-w><CR>
nmap <silent> <leader>R <Plug>(coc-rename)
nmap <silent> <leader>s <Plug>(coc-codeaction-cursor)
xmap <silent> <leader>s <Plug>(coc-codeaction-selected)
nmap <silent> <leader>S <Plug>(coc-fix-current)
nmap <silent> <leader>a <Plug>(coc-diagnostic-next)
nmap <silent> <leader>A <Plug>(coc-diagnostic-next-error)
nmap <silent> <leader>d <Plug>(coc-definition)
nmap <silent> <leader>g :call ShowDocumentation()<CR>
nmap <silent> <leader>G <Plug>(coc-diagnostic-info)
nmap <silent> <leader>t <Plug>(coc-type-definition)
nmap <silent> <leader>u <Plug>(coc-references)
nmap <silent> <leader>i <Plug>(coc-implementation)
nmap <silent> <leader>p :call CocActionAsync('format')<CR>
xmap <silent> <leader>p <Plug>(coc-format-selected)
nnoremap <silent> <leader>O :call CocActionAsync('runCommand', 'editor.action.organizeImport')<CR>
nnoremap <silent> <nowait> <leader>l :<C-u>CocList diagnostics<CR>
nnoremap <silent> <nowait> <leader>L :<C-u>CocList -I symbols<cr>
command MarkdownFix :call CocAction('runCommand', 'markdownlint.fixAll')<CR>
function! CheckBackspace() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
" Use tab for trigger completion with characters ahead and navigate.
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by
" other plugin before putting this into your config.
inoremap <silent><expr> <TAB>
\ coc#pum#visible() ? coc#pum#next(1):
\ CheckBackspace() ? "\<Tab>" :
\ coc#refresh()
inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"
inoremap <expr> <cr> coc#pum#visible() ? coc#_select_confirm() : "\<CR>"
" Use <c-space> to trigger completion.
if has('nvim')
inoremap <silent><expr> <c-space> coc#refresh()
else
inoremap <silent><expr> <c-@> coc#refresh()
endif
function! ShowDocumentation()
call CocActionAsync('doHover')
endfunction
" Coc Errors
hi link CocErrorHighlight SpellBad
hi link CocWarningHighlight SpellLocal
hi link CocUnusedHighlight Comment
hi link CocInfoHighlight SpellRare
hi link CocHintHighlight SpellCap
" Floating
hi link CocFloating Visual
hi link CocErrorFloat Visual
hi link CocWarningFloat Visual
hi link CocInfoFloat Visual
hi link CocHintFloat Visual
hi link CocFloatDividingLine Comment
" Pmenu (e.g. completions)
hi! link Pmenu Visual
hi! link PmenuSel DraculaOrangeInverse
hi! link CocMenuSel DraculaOrangeInverse
hi! link CocSearch DraculaOrange
" " TypeScript colors
hi! link typescriptParens DraculaFgBold
" vimdiff
if &diff
map <leader>1 :diffget LOCAL<CR>
map <leader>2 :diffget BASE<CR>
map <leader>3 :diffget REMOTE<CR>
map <leader>g :diffget<CR>
map <leader>d :difft<CR>
map <leader>o :diffo<CR>
endif
" Git gutter
let g:gitgutter_sign_priority = 1
let g:gitgutter_sign_added = '✚'
let g:gitgutter_sign_modified = '➜'
let g:gitgutter_sign_removed = '✘'
let g:gitgutter_sign_removed_first_line = '✘'
let g:gitgutter_sign_modified_removed='±'
let g:gitgutter_preview_win_floating = 1
command! -nargs=0 GitUndo :GitGutterUndoHunk
command! -nargs=0 GitBrunch :! git-brunch
command! -nargs=0 GBrunch :! git-brunch
command! -nargs=0 Gbrunch :! git-brunch
command! -nargs=0 Brunch :! git-brunch
nmap <silent> <leader>m :call GitGutterNextHunkCycle()<CR>
nmap <silent> <leader>M :GitGutterPreviewHunk<CR>
function! GitGutterNextHunkCycle()
let line = line('.')
silent! GitGutterNextHunk
if line('.') == line
normal! 1G
GitGutterNextHunk
endif
endfunction
" git: Do not remember commit message cursor position
autocmd BufReadPost COMMIT_EDITMSG exe "normal! gg"
" NerdTree
let g:NERDTreeMinimalUI = 1
let g:NERDTreeQuitOnOpen = 1
let g:NERDTreeMapActivateNode = "l"
let g:NERDTreeRespectWildIgnore = 1
let g:NERDTreeAutoDeleteBuffer=1
let g:NERDTreeCustomOpenArgs = {'file': {'where':'p'}}
nmap <silent> <leader>n :call NerdTreeToggleFind()<CR>
nmap <silent> <leader>N :NERDTreeToggle<CR>
hi link NERDTreeOpenable Type
hi link NERDTreeClosable Special
hi link NERDTreeDir Question
function! NerdTreeToggleFind()
if exists("g:NERDTree") && g:NERDTree.IsOpen()
NERDTreeClose
elseif filereadable(expand('%'))
NERDTreeFind
else
NERDTree
endif
endfunction
" Folding
set foldmethod=indent
set foldnestmax=1
set nofoldenable
set foldlevel=0
noremap <leader>z zM<CR>
noremap <leader>Z zR<CR>
" Expand region
map + <Plug>(expand_region_expand)
map _ <Plug>(expand_region_expand)
map - <Plug>(expand_region_shrink)
" Abolish (coerce casing)
nmap crp crm
" Ranger
let g:ranger_map_keys = 0
nmap <leader>o :Ranger<CR>
" Presenting
let g:presenting_top_margin = 2
" Markdown
let g:vim_markdown_conceal = 1
let g:vim_markdown_conceal_code_blocks = 1
" Java
let g:syntastic_java_checkers = []
command! -nargs=0 IdeaFormat silent :w | exec "!idea format %" | :e
" PureScript
let g:purescript_disable_indent = 1
let g:purescript_indent_let = 2
let g:purescript_indent_in = 0
let g:purescript_indent_where = 0
let g:purescript_unicode_conceal_enable = 0
let g:purescript_unicode_conceal_disable_common = 1
let g:purescript_unicode_conceal_enable_discretionary = 0
" Language tool
let g:languagetool_cmd='languagetool-commandline'
let g:languagetool_disable_rules='COMMA_PARENTHESIS_WHITESPACE,DASH_RULE,EN_QUOTES,WHITESPACE_RULE,ARROWS'
command English set spelllang=en
command German set spelllang=de
" Git commit
autocmd FileType gitcommit set textwidth=72
autocmd FileType gitcommit set colorcolumn+=73
" Copilot
let g:copilot_no_tab_map = v:true
imap <silent><script><expr> <C-j> copilot#Accept("\<CR>")
imap <C-k> <Plug>(copilot-next)
" MDX
autocmd BufNewFile,BufRead *.mdx set filetype=markdown
" Include temporary vim settings
if filereadable("/tmp/.vimrc")
source /tmp/.vimrc
endif