-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
440 lines (357 loc) · 11.5 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
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
""""""""""""""""""
" REGULAR CONFIG "
""""""""""""""""""
set shell=/bin/bash
set mouse=nicr
set number
set tabstop=4
set shiftwidth=4
set expandtab
set conceallevel=2
set timeoutlen=600
set ttimeoutlen=50
set belloff=all
set wrap
set linebreak
set showbreak=..
set breakindent
set autoindent
set incsearch
set hlsearch
"set hidden
set shortmess-=S
set textwidth=90
set display+=lastline
set fillchars+=vert:\▏
filetype plugin on
filetype indent off
set termguicolors
set background=dark
"colorscheme flattened_dark
"colorscheme flattened_light
"colorscheme solarized_og
"colorscheme gruvbox
"let g:gruvbox_contrast_dark='medium'
"let g:airline_theme='solarized'
"let g:airline_theme='gruvbox'
"colorscheme worldreport
colorscheme solr
let g:solr_italic=1
let g:airline_theme='solr'
"colorscheme world_news
"let g:airline_theme='solr'
syntax enable
set spell
set spelllang=en_us
set cursorline
set cursorlineopt=number
autocmd ColorScheme * highlight CursorLineNr cterm=bold term=bold gui=bold
""""""""""""""""""""""""
" PLUG PACKAGE MANAGER "
""""""""""""""""""""""""
" begin plugin list
call plug#begin('~/.vim/plugged')
"" vim-fugitive ""
Plug 'tpope/vim-fugitive'
"" vim-obsession ""
Plug 'tpope/vim-obsession'
"" UltiSnips engine and snippets ""
Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'
"" VimTeX ""
Plug 'lervag/vimtex'
"" Extra TeX snips ""
Plug 'gillescastel/latex-snippets'
"" TeX-conceal ""
Plug 'KeitaNakamura/tex-conceal.vim', {'for': ['tex','md']}
"" NERDTree ""
Plug 'scrooloose/nerdtree'
"" Airline ""
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
"" Solarized color scheme ""
"Plug 'altercation/vim-colors-solarized'
Plug 'lifepillar/vim-solarized8'
"" GruvBox color scheme ""
Plug 'morhetz/gruvbox'
"" Markdown ""
Plug 'godlygeek/tabular'
Plug 'https://git.samgriesemer.com/samgriesemer/vim-roam-md'
"" Lists ""
Plug 'dkarter/bullets.vim'
"" Wiki ""
Plug 'skywind3000/asyncrun.vim'
Plug 'https://git.samgriesemer.com/samgriesemer/wiki.vim'
Plug 'https://git.samgriesemer.com/samgriesemer/vim-roam'
Plug 'https://git.samgriesemer.com/samgriesemer/vim-roam-search'
"" Taskwiki ""
Plug 'https://git.samgriesemer.com/samgriesemer/vim-roam-task'
"" fzf ""
Plug '~/.fzf' "make sure fzf installed (along with ripgrep)
Plug 'junegunn/fzf.vim'
"" coc.nvim ""
Plug 'neoclide/coc.nvim', {'branch': 'release', 'for': ['json', 'lua', 'vim', 'python']}
"Plug 'psf/black'
Plug 'dhruvasagar/vim-table-mode'
" end plugin list, initialize system
call plug#end()
""""""""""""""""""
" PACKAGE CONFIG "
""""""""""""""""""
"" Airline config ""
let g:airline#extensions#coc#enabled=1
"" UltiSnips configuration ""
let g:UltiSnipsExpandTrigger = '<tab>'
let g:UltiSnipsJumpForwardTrigger = '<tab>'
let g:UltiSnipsJumpBackwardTrigger = '<s-tab>'
let g:UltiSnipsEditSplit = 'vertical'
"" VimTex configuration ""
let g:tex_flavor = 'latex'
let g:vimtex_view_method = 'zathura'
let g:vimtex_quickfix_mode = 0
"" TeX-conceal configuration ""
let g:tex_conceal='abdmg'
"" NERDTree config ""
let NERDTreeMinimalUI=1
"" Vim-markdown plugin config ""
let g:vim_markdown_math = 1
let g:vim_markdown_folding_disabled = 1
let g:vim_markdown_auto_insert_bullets = 0
let g:vim_markdown_new_list_item_indent = 0
"" Base markdown settings (tpope) ""
let g:markdown_folding = 1
"" Wiki ""
let g:wiki_root = '~/Documents/notes'
let g:wiki_filetypes = ['md']
let g:wiki_write_on_nav = 1
let g:wiki_journal = {
\ 'name' : '',
\ 'frequency' : 'daily',
\ 'date_format' : {
\ 'daily' : '%Y-%m-%d',
\ 'monthly' : '%Y-%m',
\ 'yearly' : '%Y',
\ },
\}
let g:wiki_mappings_local = {
\ '<plug>(wiki-link-toggle)' : '<Leader>wlt',
\ '<plug>(wiki-fzf-toc)' : '<leader>wt',
\ '<plug>(wiki-page-toc)' : '<Leader>wpt',
\ '<plug>(wiki-journal-toweek)' : '<Leader>wjt',
\ '<plug>(wiki-graph-find-backlinks)' : '<Leader>wlb',
\ }
let g:wiki_map_create_page = 'StringToFname' " used through with `wn`
let g:wiki_map_file2link = 'FnameToString' " file to link map, for renaming & vim-roam link reverse
let g:wiki_resolver = 'WikiResolver' " transform link to filename
let g:wiki_file_handler = 'WikiFileOpen' " handle wiki `file:` opening
let g:wiki_post_page_open = 'WikiPostOpen' " callback after page open
function! StringToFname(str)
return substitute(a:str,' ','_','g')
endfunction
function! FnameToString(fname)
return substitute(a:fname,'_',' ','g')
endfunction
function! WikiResolver(fname, origin)
if empty(a:fname) | return a:origin | endif
let l:file = StringToFname(a:fname)
let l:file = simplify(wiki#get_root().'/'.l:file)
let l:ext = fnamemodify(l:file, ':e')
if l:ext == 'md'
return l:file
elseif l:ext == 'pdf'
eval call('WikiFileOpen', [], {'path': l:file})
else
if filereadable(l:file.'.md')
return l:file.'.md'
elseif filereadable(l:file.'.pdf')
eval call('WikiFileOpen', [], {'path': l:file.'.pdf'})
else
" final default behavior, open new Markdown file
return l:file.'.md'
endif
endif
return a:origin
endfunction
function! WikiFileOpen(...) abort dict
if self.path =~# 'pdf$'
let l:cmd = '!nohup zathura '.fnameescape(self.path)
if get(self, 'page')
let l:cmd .= ' -P '.string(self.page)
endif
silent execute l:cmd.' &'
redraw!
return 1
endif
return 0
endfunction
function! WikiPostOpen(fname)
let l:fnew = !filereadable(expand('%'))
"let l:fnew = filereadable(a:fname)
" snippets for new files
if l:fnew
if a:fname =~# 'task-[a-z0-9]\{8\}.md'
normal! iwn
call UltiSnips#ExpandSnippet()
endif
if a:fname =~# '[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}'
normal! iwj
call UltiSnips#ExpandSnippet()
endif
endif
endfunction
"" Vim-roam ""
let g:roam_search_wrap_link = 'WrapLink'
function! WrapLink(lines)
let l:link = join(a:lines)
let l:link = FnameToString(l:link)
if fnamemodify(l:link, ':e') == 'pdf'
let l:link = '[['.l:link.']]'
else
let l:link = '[['.fnamemodify(l:link,':r').']]'
endif
if getcurpos()[2]+strlen(l:link) > &tw
let l:spacing = repeat(' ', &tw - getcurpos()[2])
let l:link = l:spacing . l:link
endif
" get link string for path (assumed relative to wiki root)
return l:link
endfunction
let g:fzf_colors =
\ { 'fg': ['fg', 'Normal'],
\ 'bg': ['bg', 'Normal'],
\ 'hl': ['fg', 'Comment'],
\ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'],
\ 'bg+': ['bg', 'CursorLine', 'CursorColumn'],
\ 'hl+': ['fg', 'Statement'],
\ 'info': ['fg', 'PreProc'],
\ 'border': ['fg', 'Ignore'],
\ 'prompt': ['fg', 'Conditional'],
\ 'pointer': ['fg', 'Exception'],
\ 'marker': ['fg', 'Keyword'],
\ 'spinner': ['fg', 'Label'],
\ 'header': ['fg', 'Comment'] }
"" Taskwiki config ""
let g:taskwiki_markup_syntax = 'markdown'
let g:taskwiki_sort_order = 'status-,urgency-'
let g:taskwiki_task_note_metadata = 1
let g:taskwiki_disable_concealcursor = 1
"let g:taskwiki_task_root = 'tasks'
"let g:taskwiki_dont_preserve_folds = 1
"
"" coc.nvim ""
let g:coc_disable_startup_warning = 1
"nmap <silent> [g <Plug>(coc-diagnostic-prev)
"nmap <silent> ]g <Plug>(coc-diagnostic-next)
"
"" GoTo code navigation.
"nmap <silent> gd <Plug>(coc-definition)
"nmap <silent> gy <Plug>(coc-type-definition)
"nmap <silent> gi <Plug>(coc-implementation)
"nmap <silent> gr <Plug>(coc-references)
let g:coc_global_extensions = ['coc-pyright', 'coc-tsserver', 'coc-html', 'coc-omni'
"\ 'coc-eslint', 'coc-prettier',
"\ 'coc-css', 'coc-json', 'coc-yaml'
\ ]
" Better display for messages
set cmdheight=2
" Smaller updatetime for CursorHold & CursorHoldI
set updatetime=300
" don't give |ins-completion-menu| messages.
set shortmess+=c
" always show signcolumns
set signcolumn=yes
let mapleader = "\<Space>"
" Use `lp` and `ln` for navigate diagnostics
nmap <silent> <leader>lp <Plug>(coc-diagnostic-prev)
nmap <silent> <leader>ln <Plug>(coc-diagnostic-next)
" Remap keys for gotos
nmap <silent> <leader>ld <Plug>(coc-definition)
nmap <silent> <leader>lt <Plug>(coc-type-definition)
nmap <silent> <leader>li <Plug>(coc-implementation)
nmap <silent> <leader>lf <Plug>(coc-references)
" Remap for rename current word
nmap <leader>lr <Plug>(coc-rename)
" Use K for show documentation in preview window
nnoremap <silent> K :call <SID>show_documentation()<CR>
function! s:show_documentation()
if &filetype == 'vim'
execute 'h '.expand('<cword>')
else
call CocAction('doHover')
endif
endfunction
" Highlight symbol under cursor on CursorHold
"autocmd CursorHold * silent call CocActionAsync('highlight')
"""
""""""""""""""""""""""
" POST PLUGIN CONFIG "
""""""""""""""""""""""
" Markdown indentation
au BufRead,BufNewFile *.md filetype indent off
au BufRead,BufNewFile *.md setlocal spell
au FileType markdown setlocal foldlevel=99
" general appearance
highlight clear LineNr
highlight clear SignColumn
highlight clear VertSplit
highlight clear SpellCap
highlight clear SpellBad
highlight clear SpellRare
highlight clear SpellLocal
highlight SpellBad cterm=underline
" Transparent bg to match terminal, comes at end to ensure hi isn't overwritten
"highlight Normal guibg=NONE ctermbg=NONE
" Italic comments
highlight Comment cterm=italic
let &l:comments='fb:* [ ],fb:- [ ],nb:>,'.&comments
"""""""""""""""""""
" CUSTOM MAPPINGS "
"""""""""""""""""""
" redefine <Leader> to <space>
let mapleader = "\<Space>"
" enforce no arrows
noremap <Up> <Nop>
noremap <Down> <Nop>
noremap <Left> <Nop>
noremap <Right> <Nop>
" window movement remap
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
" NERDTree map
nmap <Leader>d :NERDTreeToggle<CR>
" general search, commands from `.vim/after`
nmap <Leader>df :DirFzfFiles<CR>
nmap <Leader>dl :DirFzfLines<CR>
" tabular formatted tables
inoremap <silent> <Bar> <Bar><Esc>:call TableAlign()<CR>a
" easy copying
vmap <C-c> "+y
" open current page name as HTML file using `xdg-open`
nmap <Leader>wo :call system('xdg-open "http://localhost:8000/' . expand('%:p:t:r') . '.html"')<CR>
" make homework mappings
let s:hw_enabled=0
let g:asyncrun_stop = 1
function! MakeHomework(file, open)
let l:opt = {}
if a:open
let l:opt = {'post': 'call OpenHomework()'}
endif
if s:hw_enabled
call asyncrun#run('', l:opt, 'source /home/smgr/.zshrc && mkhw '.a:file)
endif
endfunction
function! ToggleHomework()
if s:hw_enabled
let s:hw_enabled = 0
else
let s:hw_enabled = 1
call MakeHomework(expand('%'), 1)
endif
endfunction
function! OpenHomework()
silent exe '!zathura '.expand('%:r').'.pdf &'
redraw!
endfunction
nmap <Leader>hw :call ToggleHomework()<CR>
autocmd BufWritePost *.md call MakeHomework(expand('%'), 0)