-
Notifications
You must be signed in to change notification settings - Fork 2
/
vimrc
375 lines (305 loc) · 10.2 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
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
" pathogen runtime manipulation
execute pathogen#infect()
" old stuff taken out:
"
" set path& " Include all subdirectories in path
" set path+=**
" if not neovim, match neovim defaults
if !has('nvim')
silent !mkdir -p ~/.local/share/vim/backup
silent !mkdir -p ~/.local/share/vim/swap
silent !mkdir -p ~/.local/share/vim/undo
syntax on " Enable syntax highlighting
filetype plugin indent on " Enable filetype detection
set autoindent " Do smart indenting
set autoread " Automatically reload files that change outside vim
set background=dark
set backspace=indent,eol,start " Allow backspacing over everything in insert mode
set backupdir=~/.local/share/vim/backup
set belloff=all " Never ring the bell
set nocompatible " Enable VIM features
set complete-=i " Eclude scanning included files for completions
set cscopeverbose
set directory=~/.local/share/vim/swap//
"set display=lastline,msgsep
set encoding=utf-8
"set fillchars=vert:|,fold:·,sep:|
set formatoptions=tcqj
set nofsync
set history=10000
set hlsearch
set incsearch
set langnoremap
set nolangremap
set laststatus=2
"set listchars=tab:>,trail:-,nbsp:+
set nrformats=bin,hex
set ruler " Show the cursor position all the time
set sessionoptions-=options
set shortmess+=F
set shortmess-=S
set showcmd " Show partially typed commands
set sidescroll=1
set smarttab
set nostartofline
set tabpagemax=50
set tags=./tags;,tags
set ttimeoutlen=50
set ttyfast
set undodir=~/.local/share/vim/undo
set viminfo+=!
set wildmenu
"set wildoptions=pum,tagfile
"not included: man.vim and matchit plugins
endif
" neovim doesn't support encryption
if !has('nvim')
set cm=blowfish2 " better file encryption
endif
set nocindent " don't do weird indenting for words like 'for'
set background=light
set fsync
set showmatch " Flash matching brackets or parantheses
set ignorecase " / Only do case-sensitive searching when at least
set smartcase " \ one letter is capitalized
set tabstop=4 " tab size = 4
set softtabstop=2 " Inserting a tab inserts 2 spaces
set shiftwidth=2 " Indent by 2 spaces
set smartindent " Autoindent when starting a new line
set expandtab " Expand tabs to spaces when inserting
set nojoinspaces " Don't insert two spaces after punctuation on a join
set hidden " Allow opening new buffer without first saving
set scrolloff=3 " Keep 3 visible lines above and below cursor
set title " Show a title
set foldmethod=marker " use {{{ and }}} to mark folds
set clipboard=unnamed " use the system clipboard
set mouse=a " allow the use of a mouse
set cmdheight=2
set formatoptions=j " don't line break when inserting text
set linebreak
set textwidth=70
" show symbol for wrapped lines
set showbreak=⇢
set breakat&
set breakat-=.
" make up/down not skip soft wrapped lines
nnoremap j gj
nnoremap k gk
nnoremap gj j
nnoremap gk k
" https://vi.stackexchange.com/questions/4054/case-sensitive-with-ignorecase-on
nnoremap <silent> * *N:let @/.='\C'<CR>n
" suggested by coc
set updatetime=300
set shortmess+=c
" set signcolumn=yes
" bug in Vim?
set t_ZH=[3m
set t_ZR=[23m
syntax spell toplevel
" Make Y behave like C and D
noremap Y y$
set cinwords=
" -----------------------
" -- EASY TEXT REPLACE --
" -----------------------
function! MySubstitute()
exe "normal! mm"
let replacement = input("Replace With?: ")
exe "%s//" . replacement . "/g"
exe "normal! `m"
endfunction
function! FilesWithPatInDir(d)
exe "normal! mm"
exe ":cd " . a:d
let cmd = " grep -ls \"" . @/ . "\" *"
" echo cmd
let files = system(cmd)
exe ":cd -"
" echo files
return files
endfunction
function! RecFilesWithPatInDir(d)
let cmd = "grep -lr \"" . @/ . "\" " . a:d
" echo cmd
let files = system(cmd)
" echo files
return files
endfunction
function! MyGlobalSubstitute()
exe "normal! mm"
let dir = input("Directory?: ")
let r = input("Recursive? (y/n): ")
if r == "y"
let files = RecFilesWithPatInDir(dir)
else
let files = FilesWithPatInDir(dir)
endif
echo "\n" . files
let okay = input("Files Okay? (y/n): ")
if okay == "y"
let replacement = input("Replace With?: ")
exe ":args " . substitute(files,"\\n"," ","g")
exe ":argdo %s/" . @/ . "/" . replacement . "/g"
endif
endfunction
map <silent> <Leader>r :call MySubstitute()<CR>
map <silent> <Leader>R :call MyGlobalSubstitute()<CR>
" -----------
" -- LATEX --
" -----------
" Make .tex files open as "latex" files
let g:tex_flavor = "latex"
" --------------
" -- MARKDOWN --
" --------------
let g:markdown_fenced_languages = ["python","R"]
" -------------
" -- HASKELL --
" -------------
let g:haskell_enable_quantification = 1 " to enable highlighting of `forall`
let g:haskell_enable_recursivedo = 1 " to enable highlighting of `mdo` and `rec`
let g:haskell_enable_arrowsyntax = 1 " to enable highlighting of `proc`
let g:haskell_enable_pattern_synonyms = 1 " to enable highlighting of `pattern`
let g:haskell_enable_typeroles = 1 " to enable highlighting of type roles
let g:haskell_enable_static_pointers = 1 " to enable highlighting of `static`
let g:haskell_backpack = 1 " to enable highlighting of backpack keywords
let g:haskell_classic_highlighting = 1 " classic highlighting colors
" ---------------
" -- NERD TREE --
" ---------------
" NERDTree
map <silent> <Leader>[ :NERDTreeToggle<CR>
" -----------------
" -- ERROR LISTS --
" -----------------
" Jumping through error lists
" map <silent> <Leader>ek :lfirst<CR>
" map <silent> <Leader>ej :llast<CR>
" map <silent> <Leader>eh :lprev<CR>
" map <silent> <Leader>el :lnext<CR>
" map <silent> <Leader>ek :cfirst<CR>
" map <silent> <Leader>ej :clast<CR>
" map <silent> <Leader>eh :cprev<CR>
" map <silent> <Leader>el :cnext<CR>
" -------------
" -- DIFFING --
" -------------
" map <silent> <Leader>dj :diffthis<CR>
" map <silent> <Leader>dk :diffoff<CR>
" ---------
" -- COC --
" ---------
highlight link CoCFloating Visual
nnoremap <silent> } <Plug>(coc-diagnostic-next)
nnoremap <silent> { <Plug>(coc-diagnostic-prev)
nnoremap <silent> <Leader>l :CocList diagnostics<CR>
nnoremap <silent> <Leader>d <Plug>(coc-definition)
nnoremap <silent> <Leader>t <Plug>(coc-type-definition)
nnoremap <silent> <Leader>i <Plug>(coc-implementation)
nnoremap <silent> <Leader>f <Plug>(coc-references)
nnoremap <silent> <Leader><Space> :call CocActionAsync('doHover')<CR>
nnoremap <silent> <Leader>h :call CocActionAsync('highlight')<CR>
" ---------
" -- COQ --
" ---------
highlight CoqtailChecked cterm=NONE ctermbg=white
function! DaraisSetupBufEnterCoq()
nnoremap <silent> <buffer> <Leader><Space> <Plug>CoqToLine
nnoremap <silent> <buffer> } <Plug>CoqNext
nnoremap <silent> <buffer> { <Plug>CoqUndo
highlight Error cterm=bold ctermfg=darkred ctermbg=lightred
endfunction
function! DaraisDetupBufLeaveCoq()
highlight Error cterm=NONE ctermfg=white ctermbg=red
endfunction
autocmd BufEnter *.v call DaraisSetupBufEnterCoq()
autocmd BufLeave *.v call DaraisDetupBufLeaveCoq()
" autocmd CursorHold * silent call CocActionAsync('highlight')
" autocmd CursorHold * silent call CocActionAsync('highlight')
" --------------------
" -- LanguageClient --
" -------------------
" let g:LanguageClient_rootMarkers = ['*.cabal', 'stack.yaml']
" let g:LanguageClient_serverCommands = {
" \ 'rust': ['rls'],
" \ 'haskell': ['ghcide', '--lsp'],
" \ }
" DONT DO THESE
" let g:LanguageClient_diagnosticsList = "Location"
" let g:LanguageClient_useVirtualText = "Diagnostics"
" ---------
" -- LSP --
" ---------
" au User lsp_setup call lsp#register_server({
" \ 'name': 'ghcide',
" \ 'cmd': {server_info->['/Users/daviddarais/.local/bin/ghcide', '--lsp']},
" \ 'whitelist': ['haskell'],
" \ })
"
" " let g:lsp_diagnostics_echo_cursor = 1
" let g:lsp_diagnostics_float_cursor = 1
" " let g:lsp_text_document_did_save_delay = 100
"
" map <silent> <Leader>eh :LspPreviousError<CR>
" map <silent> <Leader>el :LspNextError<CR>
"
" map <silent> <Leader>wh :LspPreviousWarning<CR>
" map <silent> <Leader>wl :LspNextWarning<CR>
" ---------
" -- ALE --
" ---------
" let g:ale_linters_explicit = 1
" let g:ale_linters = { 'haskell': ['ghcide'] }
" let g:ale_set_quickfix = 1
" let g:ale_set_highlights = 1
" let g:ale_cursor_detail = 1
" let g:ale_echo_cursor = 0
" set splitbelow
" ---------
" -- LSC --
" ---------
" let g:lsc_server_commands =
" \ { 'haskell':
" \ { 'command': 'ghcide'
" \ , 'suppress_stderr': 'v:true'
" \ }
" \ }
" ----------------
" -- TABLE MODE --
" ----------------
let g:table_mode_corner='|'
" ----------------
" -- TABULARIZE --
" ----------------
" map <Leader>t :Tabularize /
" File Hooks
augroup DD_CUSTOM
" Removes autocommands for the current group
autocmd!
" Remember last position in file
autocmd BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal g'\"" | endif
" Resync syntax highlighting
autocmd BufEnter * :syntax sync fromstart
" Source the vimrc if it gets changed
autocmd BufWritePost *vimrc if expand("%") == expand("$MYVIMRC") | source % | endif
" Use different fold markers for latex
autocmd BufReadPost *.tex set foldmarker={-{,}-}
" Disable latex auto indenting
autocmd BufReadPost *.tex set indentexpr=
" Disable cindent
autocmd BufReadPost *.tex set nocindent
autocmd BufReadPost *.bib set nocindent
autocmd BufReadPost *.bib set cinwords=
augroup END
" auto reload
function! AutoReload()
set autoread
au CursorHold,InsertEnter,InsertLeave * checktime
endfunction
function! SynGroup()
let l:s = synID(line('.'), col('.'), 1)
echo synIDattr(l:s, 'name') . ' -> ' . synIDattr(synIDtrans(l:s), 'name')
endfun
" snippets:
" :runtime syntax/hitest.vim -- show all highlight groups