Mercurial > dotfiles
annotate dot_config/nvim/init.vim @ 286:6dad02f7604f
Clean up plugins
author | zegervdv <zegervdv@me.com> |
---|---|
date | Sun, 06 Sep 2020 18:47:59 +0200 |
parents | d48b05b03ddf |
children | 6744d7605e8b |
rev | line source |
---|---|
273 | 1 " vim:fdm=marker:ts=2:sw=2 |
2 | |
3 let s:darwin = has('mac') | |
4 let s:windows = has('win32') | |
5 | |
6 " Include Vim-Plug {{{ | |
7 if !s:windows | |
8 if has('nvim') | |
9 if empty(glob('~/.config/nvim/autoload/plug.vim')) | |
10 silent !mkdir -p ~/.config/nvim/autoload | |
11 silent !curl -fLo ~/.config/nvim/autoload/plug.vim | |
12 \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim | |
13 autocmd VimEnter * PlugInstall | |
14 endif | |
15 else | |
16 if empty(glob('~/.vim/autoload/plug.vim')) | |
17 silent !mkdir -p ~/.vim/autoload | |
18 silent !curl -fLo ~/.vim/autoload/plug.vim | |
19 \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim | |
20 autocmd VimEnter * PlugInstall | |
21 endif | |
22 endif | |
23 endif | |
24 | |
25 " }}} | |
26 " Vim-Plug {{{ | |
27 let g:plug_window='topleft new' | |
28 | |
29 if has('nvim') | |
30 call plug#begin('~/.config/nvim/plugged') | |
31 else | |
32 call plug#begin('~/.vim/plugged') | |
33 endif | |
34 | |
35 " General Plugins | |
286 | 36 Plug 'tpope/vim-sensible' |
273 | 37 |
38 if s:darwin | |
39 Plug 'vim-scripts/gitignore' | |
40 endif | |
41 | |
42 Plug 'sjl/splice.vim' | |
43 | |
44 Plug 'tpope/vim-repeat' | |
45 Plug 'tpope/vim-rsi' | |
46 Plug 'einfachtoll/didyoumean' | |
47 | |
48 " Session Management | |
49 Plug 'tpope/vim-obsession' | |
50 | |
51 " Spelling | |
52 Plug 'tpope/vim-abolish' | |
53 | |
54 " Settings | |
55 Plug 'sgur/vim-editorconfig' | |
56 | |
57 " Brackets | |
58 Plug 'tpope/vim-surround' | |
59 Plug 'raimondi/delimitMate' | |
284 | 60 Plug 'zegervdv/vim-endwise' |
273 | 61 |
62 " Formatting | |
63 Plug 'junegunn/vim-easy-align', { 'on' : [] } | |
64 augroup load_easy_align | |
65 autocmd! | |
66 autocmd CursorHold,CursorHoldI * call plug#load('vim-easy-align') | autocmd! load_easy_align | |
67 augroup END | |
68 | |
69 " Comments | |
70 Plug 'tpope/vim-commentary' | |
71 | |
72 " Moving in files | |
73 Plug 'wellle/targets.vim', { 'on': [] } | |
74 augroup load_targets | |
75 autocmd! | |
76 autocmd InsertEnter * call plug#load('targets.vim') | autocmd! load_targets | |
77 augroup END | |
78 Plug 'mhinz/vim-grepper', { 'on' : 'Grepper' } | |
79 | |
80 " Indentation | |
81 Plug 'nathanaelkane/vim-indent-guides' | |
82 | |
83 " Command line | |
84 Plug 'tpope/vim-eunuch', { 'on' : ['Remove', 'Unlink', 'Move', 'Rename', 'Mkdir', 'Chmod', 'Find', 'Locate', 'SudoEdit', 'SudoWrite']} | |
85 | |
86 " Undoing | |
87 Plug 'sjl/gundo.vim', { 'on': 'GundoToggle' } | |
88 | |
89 " Tabs | |
90 Plug 'gcmt/taboo.vim' | |
91 | |
92 " Other | |
93 Plug 'yuttie/comfortable-motion.vim' | |
94 Plug 'tpope/vim-apathy' | |
95 | |
96 " Tmux | |
97 Plug 'christoomey/vim-tmux-navigator' | |
98 Plug 'tmux-plugins/vim-tmux-focus-events' | |
99 | |
100 " Background make | |
101 Plug 'tpope/vim-dispatch' | |
102 | |
103 " Completing and snippets | |
104 Plug 'sirver/ultisnips' | |
105 Plug 'honza/vim-snippets' | |
106 if has('nvim') | |
107 Plug 'neovim/nvim-lsp' | |
275
6eae07a6985f
Update urls for completion-nvim and diagnostic-nvim
zegervdv <zegervdv@me.com>
parents:
274
diff
changeset
|
108 Plug 'nvim-lua/completion-nvim' |
6eae07a6985f
Update urls for completion-nvim and diagnostic-nvim
zegervdv <zegervdv@me.com>
parents:
274
diff
changeset
|
109 Plug 'nvim-lua/diagnostic-nvim' |
282 | 110 " Plug 'nvim-treesitter/nvim-treesitter' |
111 Plug '~/Projects/nvim-treesitter' | |
112 Plug 'nvim-treesitter/playground' | |
281 | 113 Plug 'steelsojka/completion-buffers' |
285 | 114 Plug 'nvim-treesitter/completion-treesitter' |
273 | 115 endif |
116 | |
117 " Copying | |
118 Plug 'ShikChen/osc52.vim' | |
119 | |
120 " Vim file navigation | |
121 Plug 'justinmk/vim-dirvish' | |
122 Plug 'tpope/vim-projectionist' | |
123 | |
124 " Theme | |
125 Plug 'NLKNguyen/papercolor-theme' | |
282 | 126 Plug 'rakr/vim-one' |
273 | 127 |
128 "Tcl | |
129 Plug 'vim-scripts/tcl.vim--smithfield-indent', { 'for': 'tcl'} | |
130 | |
274
b77b75c88ce6
Disable default formatting on save
zegervdv <zegervdv@me.com>
parents:
273
diff
changeset
|
131 Plug 'dense-analysis/ale' |
273 | 132 Plug 'sbdchd/neoformat' |
133 | |
134 Plug 'Glench/Vim-Jinja2-Syntax' | |
135 | |
136 if s:darwin | |
137 " Ruby | |
138 Plug 'tpope/vim-rails', { 'for': 'ruby' } | |
139 Plug 'vim-ruby/vim-ruby', { 'for': 'ruby' } | |
140 Plug 'tpope/vim-bundler', { 'for': 'ruby' } | |
141 Plug 'tpope/vim-rake', { 'for': 'ruby' } | |
142 Plug 'slim-template/vim-slim', { 'for': 'ruby' } | |
143 Plug 'duwanis/tomdoc.vim', { 'for': 'ruby' } | |
144 Plug 'keith/rspec.vim', { 'for': 'rspec' } | |
145 | |
146 " Markdown | |
147 Plug 'tpope/vim-markdown', { 'for': 'markdown' } | |
148 | |
149 " Jade | |
150 Plug 'digitaltoad/vim-jade', { 'for': 'jade' } | |
151 | |
152 " Latex | |
153 Plug 'lervag/vimtex', { 'for': 'tex' } | |
154 endif | |
155 | |
156 " Coffeescript | |
157 Plug 'kchmck/vim-coffee-script', { 'for': 'coffee' } | |
158 | |
159 " C | |
160 Plug 'NLKNguyen/c-syntax.vim', { 'for': 'c' } | |
161 | |
162 " Python | |
163 Plug 'Vimjas/vim-python-pep8-indent', { 'for': 'python' } | |
164 Plug 'vim-python/python-syntax', { 'for': 'python' } | |
165 | |
166 " Git | |
167 Plug 'tpope/vim-git' | |
168 call plug#end() | |
169 " }}} | |
170 | |
171 " Activate built in plugins {{{ | |
172 if !has('nvim') | |
173 if has('packages') | |
174 packadd! matchit | |
175 packadd! shellmenu | |
176 endif | |
177 endif | |
178 source $VIMRUNTIME/ftplugin/man.vim | |
179 | |
180 if has('packages') | |
181 silent! packadd! log_file | |
182 silent! packadd! browsify | |
183 silent! packadd! snippets | |
184 silent! packadd! chipscoper | |
185 endif | |
186 | |
187 if has("nvim") | |
188 let g:python3_host_prog=expand('$HOME/.config/virtualenvs/python3/bin/python') | |
189 let g:python_host_prog=expand('$HOME/.config/virtualenvs/python2/bin/python') | |
190 endif | |
191 " }}} | |
192 | |
193 " General Settings and options {{{ | |
194 | |
195 " Backspace over everything, like normal | |
196 set backspace=2 | |
197 | |
198 " Buffers | |
199 set autoread " Read external changes | |
200 set hidden " Change between buffers without saving | |
201 set autowriteall " Write changes when losing focus | |
202 | |
203 " Visuals | |
204 set number | |
205 set relativenumber | |
206 set ruler | |
207 syntax on | |
208 set title | |
209 set scrolloff=4 " Stay 4 lines from top/bottom | |
210 set showcmd | |
211 | |
212 " Theme and style | |
213 " Override needs to be defined before calling colorscheme | |
214 function! IndentGuidesColor() abort | |
215 highlight IndentGuidesOdd ctermbg=254 | |
216 highlight IndentGuidesEven ctermbg=254 | |
217 endfunction | |
218 | |
219 augroup IndentColors | |
220 autocmd! | |
221 autocmd ColorScheme * call IndentGuidesColor() | |
222 augroup END | |
223 | |
224 " function! ColorOverrides() abort | |
225 " highlight Special ctermfg=31 | |
226 " endfunction | |
227 | |
228 " augroup ColorOverrides | |
229 " autocmd! | |
230 " autocmd ColorScheme * call ColorOverrides() | |
231 " augroup END | |
232 | |
233 | |
234 let g:PaperColor_Theme_Options = { | |
235 \ 'theme': { | |
236 \ 'default': { | |
237 \ 'allow_bold': 0 | |
238 \ } | |
239 \ } | |
240 \} | |
241 let g:onedark_color_overrides = { | |
242 \ "yellow": {"cterm": "3", "gui": "#ffc24b"} | |
243 \} | |
282 | 244 " colorscheme onedark |
245 set termguicolors | |
246 | |
247 let g:one_allow_italics=1 | |
248 colorscheme one | |
273 | 249 set background=dark |
282 | 250 |
273 | 251 if s:darwin |
252 set background=dark | |
253 colorscheme tomorrow-night | |
254 set guifont=inconsolata:h13 | |
255 elseif s:windows | |
256 set background=light | |
257 colorscheme PaperColor | |
258 set guifont=consolas:h10 | |
259 endif | |
260 | |
261 set showmatch " Highlight matching brackets | |
262 | |
263 set wrap " Wrap lines | |
264 set wrapmargin=2 " Stay 2 chars from side | |
265 set textwidth=79 | |
266 set colorcolumn=81 | |
267 set linebreak " Smarter wrapping | |
268 if v:version > 703 | |
269 set breakindent " Indent wrapped lines to same level | |
270 endif | |
271 | |
272 set fixendofline | |
273 | |
274 set expandtab " Expand tabs to spaces | |
277 | 275 set tabstop=2 shiftwidth=2 " Tab is 2 spaces |
273 | 276 |
277 set shiftround " Round shift indents to nearest value | |
278 | |
279 " Searching | |
280 set magic " Use magic regexes | |
281 set hlsearch " Highlight all matches | |
282 set incsearch " Show matches while typing | |
283 set ignorecase " Ignore case when searching | |
284 set smartcase " Be case sensitive if at least one uppercase char is used | |
285 set gdefault " Default substitute all matches on a line | |
286 if has('nvim') | |
287 set inccommand=nosplit | |
288 endif | |
289 | |
290 set autoindent " Automatically indent | |
291 set cindent " Indent based on C syntax | |
292 set cinwords+=foreach | |
293 | |
294 set updatetime=300 | |
295 | |
296 if s:darwin | |
297 set vb | |
298 endif | |
299 set noerrorbells " Don't beep | |
300 | |
301 set guioptions-=r | |
302 set guioptions-=l | |
303 set guioptions-=R | |
304 set guioptions-=L | |
305 set guioptions-=a | |
306 set guioptions-=m | |
307 set guioptions-=T | |
308 set guioptions+=c | |
309 | |
310 set history=100 " Set history 100 | |
311 set wildmenu " Command completion | |
312 set wildmode=longest:full,full " Complete to fullest match | |
313 set ttyfast " Use a fast terminal | |
314 set lazyredraw " No need to redraw constantly | |
315 set shortmess+=c | |
316 | |
317 set ttimeoutlen=-1 " Set the timeout to a minimum | |
318 set diffopt+=iwhite " Ignore spaces in diffs" | |
319 | |
320 set tags=.git/tags,tags,/project/asic_fpga/tools/vim/share/vim/vimfiles/tags | |
321 | |
322 " Have find look through all folders | |
323 set path+=** | |
324 " Add PRJROOT and subdirs to path if it is set | |
325 if exists('$PRJROOT') | |
326 set path+=$PRJROOT/** | |
327 endif | |
328 | |
329 set formatoptions= | |
330 set formatoptions+=c " Format comments | |
331 set formatoptions+=r " Continue comments by default | |
332 set formatoptions+=o " Make comment when using o or O from comment line | |
333 set formatoptions+=q " Format comments with gq | |
334 set formatoptions+=n " Recognize numbered lists | |
335 set formatoptions+=2 " Use indent from 2nd line of a paragraph | |
336 " set formatoptions+=l " Don't break lines that are already long | |
337 set formatoptions+=1 " Break before 1-letter words | |
338 | |
339 set signcolumn=yes | |
340 | |
341 " Enable cursorline | |
342 set cursorline | |
343 augroup cline | |
344 au! | |
345 autocmd WinEnter * setlocal cursorline | |
346 autocmd WinLeave * setlocal nocursorline | |
347 augroup END | |
348 | |
349 if !s:windows | |
350 set list | |
351 set listchars=tab:»\ ,trail:·,extends:>,precedes:<,nbsp:+ | |
352 endif | |
353 | |
354 set sessionoptions-=options | |
355 | |
356 " Scan files for completion | |
357 set complete=.,w,b,u,k,kspell,t,i,d | |
358 " set completeopt=menuone,longest,preview,noinsert,noselect | |
359 set completeopt=noinsert,menuone,noselect | |
360 | |
361 set splitright | |
362 set virtualedit=block | |
363 | |
364 if v:version > 703 | |
365 set conceallevel=0 | |
366 if !has('nvim') | |
367 set cryptmethod=blowfish2 | |
368 endif | |
369 endif | |
370 | |
371 filetype plugin indent on | |
372 | |
373 set pastetoggle=<F2> " Toggle to paste mode | |
374 | |
375 if v:version >= 703 | |
376 set undofile | |
377 endif | |
378 set undolevels=1000 | |
379 set backup | |
380 set noswapfile | |
381 if has('nvim') | |
382 " set viminfo+=n~/.config/nvim/.viminfo | |
383 set backupdir=~/.config/nvim/tmp/backup/,. | |
384 set directory=~/.config/nvim/tmp/swap//,. | |
385 else | |
386 set viminfo+=n~/.vim/.viminfo | |
387 set backupdir=~/.vim/tmp/backup/,. | |
388 set directory=~/.vim/tmp/swap//,. | |
389 endif | |
390 if !isdirectory(expand(&backupdir)) | |
391 call mkdir(expand(&backupdir), "p") | |
392 endif | |
393 if !isdirectory(expand(&directory)) | |
394 call mkdir(expand(&directory), "p") | |
395 endif | |
396 | |
397 if v:version >= 703 | |
398 if has('nvim') | |
399 set undodir=~/.config/nvim/tmp/undo//,. | |
400 else | |
401 set undodir=~/.vim/tmp/undo//,. | |
402 endif | |
403 if !isdirectory(expand(&undodir)) | |
404 call mkdir(expand(&undodir), "p") | |
405 endif | |
406 endif | |
407 | |
408 | |
409 set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.o,*.bin,*.elf,*.hex,*.eps,.git/**,*.dup,.hg/**,*.orig,*.*~ | |
410 | |
411 " No selecting via mouse (stops visual selection when scrolling) | |
412 set mouse=nic | |
413 | |
414 " }}} | |
415 " Status line {{{ | |
416 hi StatusLine ctermfg=0 ctermbg=3 cterm=NONE | |
417 hi StatusLineNC ctermfg=8 ctermbg=7 cterm=NONE | |
418 hi User1 ctermfg=0 ctermbg=7 | |
419 hi User2 ctermfg=NONE ctermbg=NONE | |
420 hi User3 ctermfg=0 ctermbg=3 | |
421 hi User4 ctermfg=0 ctermbg=5 | |
422 function! Status() | |
423 let l:statusline='' | |
424 let l:statusline.=' %t' | |
425 let l:statusline.=' %1*' | |
426 let l:statusline.=' %Y' | |
427 let l:statusline.=' %2*' | |
428 let l:statusline.='%=' | |
429 let l:statusline.=' %1*' | |
430 let l:statusline.=' line ' | |
431 let l:statusline.='' | |
432 let l:statusline.='%l' | |
433 let l:statusline.=' %3*' | |
434 let l:statusline.=' of ' | |
435 let l:statusline.='' | |
436 let l:statusline.='%L ' | |
437 let l:statusline.='' | |
438 return l:statusline | |
439 endfunction | |
440 set laststatus=2 | |
441 set statusline=%!Status() | |
442 " }}} | |
443 " Fix Colors in colorscheme {{{ | |
444 function! SpellHighlights() abort | |
445 highlight SpellBad ctermbg=256 ctermfg=210 | |
446 highlight SpellLocal ctermbg=240 ctermfg=010 | |
447 highlight SpellCap ctermbg=256 ctermfg=211 | |
448 endfunction | |
449 augroup SpellColors | |
450 autocmd! | |
451 autocmd ColorScheme * call SpellHighlights() | |
452 augroup END | |
453 "}}} | |
454 | |
455 " Mappings {{{ | |
456 " Set leader to spacebar | |
457 map <space> <leader> | |
458 | |
459 " See long lines as line breaks | |
460 noremap <expr> j (v:count? 'j' : 'gj') | |
461 noremap <expr> k (v:count? 'k' : 'gk') | |
462 | |
463 " Remap tag-search to better place | |
464 nnoremap <C-$> g<C-]> | |
465 nnoremap <C-y> g<C-]> | |
466 nnoremap <C-w>y <C-w>g<C-]> | |
467 | |
468 nnoremap <C-s> <C-e> | |
469 | |
470 " Move while in insert mode | |
471 inoremap <C-f> <right> | |
472 | |
473 " Switch between the last two files | |
474 " nnoremap <space><space> <C-^> | |
475 | |
476 " " Very Magic search patterns | |
477 nnoremap / /\v | |
478 vnoremap / /\v | |
479 | |
480 " Keep search matches in the middle of the window. | |
481 nnoremap n nzzzv | |
482 nnoremap N Nzzzv | |
483 | |
484 " Search for beginning of command | |
485 cnoremap <c-n> <down> | |
486 cnoremap <c-p> <up> | |
487 | |
488 " Move whole lines | |
489 nnoremap [e :<c-u>execute 'move -1-'. v:count1<cr> | |
490 nnoremap ]e :<c-u>execute 'move +'. v:count1<cr> | |
491 | |
492 " Insert empty lines | |
493 nnoremap [<space> :<c-u>put! =repeat(nr2char(10), v:count1)<cr>'[ | |
494 nnoremap ]<space> :<c-u>put =repeat(nr2char(10), v:count1)<cr> | |
495 | |
496 " Clear highlight | |
497 nnoremap <silent><leader>l :noh<CR> | |
498 | |
499 inoremap £ \ | |
500 | |
501 " Highlight last inserted text | |
502 nnoremap gV `[v`] | |
503 | |
504 " Highlight VCS conflict markers | |
505 match ErrorMsg '^\(<\|=\|>\)\{7\}\([^=].\+\)\?$' | |
506 | |
507 " Use backspace as delete in visual mode | |
508 vmap <BS> x | |
509 | |
510 " Redraw screen | |
511 nnoremap <F3> :redraw!<CR> | |
512 | |
513 " Keep selection when shifting | |
514 vmap <expr> > KeepVisualSelection(">") | |
515 vmap <expr> < KeepVisualSelection("<") | |
516 | |
517 function! KeepVisualSelection(cmd) | |
518 set nosmartindent | |
519 if mode() ==# "V" | |
520 return a:cmd . ":set smartindent\<CR>gv" | |
521 else | |
522 return a:cmd . ":set smartindent\<CR>" | |
523 endif | |
524 endfunction | |
525 | |
526 " Swap backticks and quotes | |
527 nnoremap ` ' | |
528 nnoremap ' ` | |
529 | |
530 " Open vimrc | |
531 nnoremap <leader>ve :e $MYVIMRC<CR> | |
532 nnoremap <leader>vs :so $MYVIMRC<CR> | |
533 | |
534 " Open dup in diffmode | |
535 nnoremap <leader>d :call OpenDup(@%)<CR> | |
536 | |
537 function! OpenDup(file) | |
538 let l:filename = a:file . ".dup" | |
539 execute 'vsplit' l:filename | |
540 windo diffthis | |
541 endfunction | |
542 | |
543 " Do not move on * | |
544 nnoremap <silent> * :let stay_star_view = winsaveview()<cr>*:call winrestview(stay_star_view)<cr> | |
545 | |
546 " Search for selected text, forwards or backwards. | |
547 vnoremap <silent> * :<C-U> | |
548 \let old_reg=getreg('"')<Bar>let old_regtype=getregtype('"')<CR> | |
549 \gvy/<C-R><C-R>=substitute( | |
550 \escape(@", '/\.*$^~['), '\_s\+', '\\_s\\+', 'g')<CR><CR> | |
551 \gV:call setreg('"', old_reg, old_regtype)<CR> | |
552 vnoremap <silent> # :<C-U> | |
553 \let old_reg=getreg('"')<Bar>let old_regtype=getregtype('"')<CR> | |
554 \gvy?<C-R><C-R>=substitute( | |
555 \escape(@", '?\.*$^~['), '\_s\+', '\\_s\\+', 'g')<CR><CR> | |
556 \gV:call setreg('"', old_reg, old_regtype)<CR> | |
557 | |
558 " nnoremap <F10> :botright copen<CR> | |
559 | |
560 xnoremap <silent> p p:if v:register == '"'<Bar>let @@=@0<Bar>endif<CR> | |
561 | |
562 " Error navigation | |
563 nnoremap <UP> :cprev<CR> | |
564 nnoremap <DOWN> :cnext<CR> | |
565 nnoremap <RIGHT> :cnf<CR> | |
566 nnoremap <LEFT> :cpf<CR> | |
567 | |
568 nnoremap <leader>y :ptjump <c-r><c-w><CR> | |
569 | |
570 function! ToggleDiff() | |
571 if &diff == 1 | |
572 windo diffoff | |
573 else | |
574 windo diffthis | |
575 endif | |
576 endfunction | |
577 nnoremap <leader>g :call ToggleDiff()<CR> | |
578 | |
579 if has('nvim') | |
580 tnoremap <space><esc> <C-\><C-n> | |
581 tnoremap <C-h> <C-\><C-n><C-w>h | |
582 tnoremap <C-j> <C-\><C-n><C-w>j | |
583 tnoremap <C-k> <C-\><C-n><C-w>k | |
584 tnoremap <C-l> <C-\><C-n><C-w>l | |
585 augroup enter_term | |
586 au! | |
587 au BufEnter * if &buftype == 'terminal' | :startinsert | endif | |
588 augroup END | |
589 endif | |
590 | |
591 " Open buffers, tags... in vertical splits | |
592 nnoremap <leader>b :vert sbuffer | |
593 nnoremap <leader>t :vert stjump | |
594 nnoremap <leader>f :vert sfind | |
595 | |
596 | |
597 " }}} | |
598 | |
599 " Functions {{{ | |
600 " When editing a file, always jump to the last known cursor position. | |
601 " Don't do it for commit messages, when the position is invalid, or when | |
602 " inside an event handler (happens when dropping a file on gvim). | |
603 autocmd BufReadPost * | |
604 \ if &ft != 'gitcommit' && line("'\"") > 0 && line("'\"") <= line("$") | | |
605 \ exe "normal g`\"" | | |
606 \ endif | |
607 | |
608 " Thg mappings | |
609 function! s:HGhist(file) | |
610 if !empty(a:file) | |
611 let path = a:file | |
612 else | |
613 let path = expand('%') | |
614 endif | |
615 exec 'silent! !thg filelog ' . path . ' &' | |
616 endfunction | |
617 | |
618 command! -nargs=? -complete=file HGhist call s:HGhist(<q-args>) | |
619 | |
620 augroup focus_lost | |
621 au! | |
622 au FocusLost * if !&readonly | :wa | endif | |
623 augroup END | |
624 | |
625 augroup LuaHighlight | |
626 autocmd! | |
627 autocmd TextYankPost * silent! lua require'vim.highlight'.on_yank() | |
628 augroup END | |
629 | |
630 " Resize splits after window resize {{{ | |
631 augroup vim_resize | |
632 au! | |
633 au VimResized * exe "normal! \<c-w>=" | |
634 augroup END | |
635 " }}} | |
636 | |
637 " Automatically reload vimrc when saving {{{ | |
638 augroup reload_vim | |
639 autocmd! | |
640 autocmd BufWritePost $MYVIMRC nested source $MYVIMRC | |
641 augroup END | |
642 " }}} | |
643 | |
644 " Reload diffs {{{ | |
645 augroup diff_files | |
646 au! | |
647 au BufWritePost * if &diff == 1 | diffupdate | endif | |
648 augroup END | |
649 " }}} | |
650 | |
651 " Custom folding by Steve Losh | |
652 function! MyFoldText() " {{{ | |
653 let line = getline(v:foldstart) | |
654 | |
655 let nucolwidth = &fdc + &number * &numberwidth | |
656 let windowwidth = winwidth(0) - nucolwidth - 3 | |
657 let foldedlinecount = v:foldend - v:foldstart | |
658 | |
659 " expand tabs into spaces | |
660 let onetab = strpart(' ', 0, &tabstop) | |
661 let line = substitute(line, '\t', onetab, 'g') | |
662 | |
663 let line = strpart(line, 0, windowwidth - 2 -len(foldedlinecount)) | |
664 let fillcharcount = windowwidth - len(line) - len(foldedlinecount) | |
665 return line . '…' . repeat(" ",fillcharcount) . foldedlinecount . '…' . ' ' | |
666 endfunction " }}} | |
667 set foldtext=MyFoldText() | |
668 set foldopen+=jump | |
669 | |
670 " Detect Filetype from content if file has no extension {{{ | |
671 augroup newFileDetection | |
672 au! | |
673 autocmd CursorMovedI * call CheckFileType() | |
674 augroup END | |
675 | |
676 function! CheckFileType() | |
677 if exists("b:countCheck") == 0 | |
678 let b:countCheck = 0 | |
679 endif | |
680 let b:countCheck += 1 | |
681 if &filetype == "" && b:countCheck > 20 && b:countCheck < 200 | |
682 filetype detect | |
683 " Delete the function if no filetype can be established, or the type has | |
684 " been found | |
685 elseif b:countCheck >= 200 || &filetype != "" | |
686 autocmd! newFileDetection | |
687 endif | |
688 endfunction | |
689 " }}} | |
690 | |
691 " Convert hex <-> decimal {{{ | |
692 command! -nargs=? -range Dec2hex call s:Dec2hex(<line1>, <line2>, '<args>') | |
693 function! s:Dec2hex(line1, line2, arg) range | |
694 if empty(a:arg) | |
695 if histget(':', -1) =~# "^'<,'>" && visualmode() !=# 'V' | |
696 let cmd = 's/\%V\<\d\+\>/\=printf("0x%x",submatch(0)+0)/g' | |
697 else | |
698 let cmd = 's/\<\d\+\>/\=printf("0x%x",submatch(0)+0)/g' | |
699 endif | |
700 try | |
701 execute a:line1 . ',' . a:line2 . cmd | |
702 catch | |
703 echo 'Error: No decimal number found' | |
704 endtry | |
705 else | |
706 echo printf('%x', a:arg + 0) | |
707 endif | |
708 endfunction | |
709 | |
710 command! -nargs=? -range Hex2dec call s:Hex2dec(<line1>, <line2>, '<args>') | |
711 function! s:Hex2dec(line1, line2, arg) range | |
712 if empty(a:arg) | |
713 if histget(':', -1) =~# "^'<,'>" && visualmode() !=# 'V' | |
714 let cmd = 's/\%V0x\x\+/\=submatch(0)+0/g' | |
715 else | |
716 let cmd = 's/0x\x\+/\=submatch(0)+0/g' | |
717 endif | |
718 try | |
719 execute a:line1 . ',' . a:line2 . cmd | |
720 catch | |
721 echo 'Error: No hex number starting "0x" found' | |
722 endtry | |
723 else | |
724 echo (a:arg =~? '^0x') ? a:arg + 0 : ('0x'.a:arg) + 0 | |
725 endif | |
726 endfunction | |
727 " }}} | |
728 | |
729 " Recognize filetype for dup files {{{ | |
730 autocmd! BufRead *.dup call DupSetSyntax(@%) | |
731 | |
732 function! DupSetSyntax(name) | |
733 let extension = matchlist(a:name, '\v.+.\.([^\.]+).dup')[1] | |
734 if extension == "vhd" | |
735 setlocal filetype=vhdl | |
736 elseif extension == "v" | |
737 setlocal filetype=verilog | |
738 elseif extension == "sv" | |
739 setlocal filetype=verilog | |
740 else | |
741 echo "Unknown filetype" | |
742 endif | |
743 endfunction | |
744 " }}} | |
745 | |
746 " Create arguments list from files in quickfix list | |
747 " Allows to Grep for a pattern and apply an argdo command on each of the | |
748 " matching files {{{ | |
749 command! -nargs=0 -bar Qargs execute 'args' QuickfixFilenames() | |
750 function! QuickfixFilenames() | |
751 " Building a hash ensures we get each buffer only once | |
752 let buffer_numbers = {} | |
753 for quickfix_item in getqflist() | |
754 let buffer_numbers[quickfix_item['bufnr']] = bufname(quickfix_item['bufnr']) | |
755 endfor | |
756 return join(map(values(buffer_numbers), 'fnameescape(v:val)')) | |
757 endfunction | |
758 "}}} | |
759 | |
760 augroup mark_files | |
761 au! | |
762 au BufLeave test.tcl mark T | |
763 au BufLeave case.do mark C | |
764 au BufLeave drv_*.tcl mark D | |
765 au BufLeave *.rtl.vhd mark R | |
766 augroup END | |
767 | |
768 | |
769 " Toggle between opening/closing the quickfix window {{{ | |
770 function! GetBufferList() | |
771 redir =>buflist | |
772 silent! ls! | |
773 redir END | |
774 return buflist | |
775 endfunction | |
776 | |
777 function! ToggleList(bufname, pfx) | |
778 let buflist = GetBufferList() | |
779 for bufnum in map(filter(split(buflist, '\n'), 'v:val =~ "'.a:bufname.'"'), 'str2nr(matchstr(v:val, "\\d\\+"))') | |
780 if bufwinnr(bufnum) != -1 | |
781 exec(a:pfx.'close') | |
782 return | |
783 endif | |
784 endfor | |
785 if a:pfx == 'l' && len(getloclist(0)) == 0 | |
786 echohl ErrorMsg | |
787 echo "Location List is Empty." | |
788 return | |
789 endif | |
790 let winnr = winnr() | |
791 exec('botright '.a:pfx.'open') | |
792 if winnr() != winnr | |
793 wincmd p | |
794 endif | |
795 endfunction | |
796 | |
797 nnoremap <silent> <F10> :call ToggleList("Quickfix List", 'c')<CR> | |
798 " }}} | |
799 | |
800 | |
801 " Make list-like commands more intuitive {{{ | |
802 " Copied from https://gist.github.com/romainl/047aca21e338df7ccf771f96858edb86 | |
803 function! CCR() | |
804 let cmdline = getcmdline() | |
805 if cmdline =~ '\v\C^(ls|files|buffers)' | |
806 " like :ls but prompts for a buffer command | |
807 return "\<CR>:b" | |
808 elseif cmdline =~ '\v\C/(#|nu|num|numb|numbe|number)$' | |
809 " like :g//# but prompts for a command | |
810 return "\<CR>:" | |
811 elseif cmdline =~ '\v\C^(dli|il)' | |
812 " like :dlist or :ilist but prompts for a count for :djump or :ijump | |
813 return "\<CR>:" . cmdline[0] . "j " . split(cmdline, " ")[1] . "\<S-Left>\<Left>" | |
814 elseif cmdline =~ '\v\C^(cli|lli)' | |
815 " like :clist or :llist but prompts for an error/location number | |
816 return "\<CR>:sil " . repeat(cmdline[0], 2) . "\<Space>" | |
817 elseif cmdline =~ '\C^old' | |
818 " like :oldfiles but prompts for an old file to edit | |
819 set nomore | |
820 return "\<CR>:sil se more|e #<" | |
821 elseif cmdline =~ '\C^changes' | |
822 " like :changes but prompts for a change to jump to | |
823 set nomore | |
824 return "\<CR>:sil se more|norm! g;\<S-Left>" | |
825 elseif cmdline =~ '\C^ju' | |
826 " like :jumps but prompts for a position to jump to | |
827 set nomore | |
828 return "\<CR>:sil se more|norm! \<C-o>\<S-Left>" | |
829 elseif cmdline =~ '\C^marks' | |
830 " like :marks but prompts for a mark to jump to | |
831 return "\<CR>:norm! `" | |
832 elseif cmdline =~ '\C^undol' | |
833 " like :undolist but prompts for a change to undo | |
834 return "\<CR>:u " | |
835 else | |
836 return "\<CR>" | |
837 endif | |
838 endfunction | |
839 cnoremap <expr> <CR> CCR() | |
840 " }}} | |
841 | |
842 " Text objects {{{ | |
843 function! s:inIndentation() | |
844 " select all text in current indentation level excluding any empty lines | |
845 " that precede or follow the current indentationt level; | |
846 " | |
847 " the current implementation is pretty fast, even for many lines since it | |
848 " uses "search()" with "\%v" to find the unindented levels | |
849 " | |
850 " NOTE: if the current level of indentation is 1 (ie in virtual column 1), | |
851 " then the entire buffer will be selected | |
852 " | |
853 " WARNING: python devs have been known to become addicted to this | |
854 " magic is needed for this | |
855 let l:magic = &magic | |
856 set magic | |
857 | |
858 " move to beginning of line and get virtcol (current indentation level) | |
859 " BRAM: there is no searchpairvirtpos() ;) | |
860 normal! ^ | |
861 let l:vCol = virtcol(getline('.') =~# '^\s*$' ? '$' : '.') | |
862 | |
863 " pattern matching anything except empty lines and lines with recorded | |
864 " indentation level | |
865 let l:pat = '^\(\s*\%'.l:vCol.'v\|^$\)\@!' | |
866 | |
867 " find first match (backwards & don't wrap or move cursor) | |
868 let l:start = search(l:pat, 'bWn') + 1 | |
869 | |
870 " next, find first match (forwards & don't wrap or move cursor) | |
871 let l:end = search(l:pat, 'Wn') | |
872 | |
873 if (l:end !=# 0) | |
874 " if search succeeded, it went too far, so subtract 1 | |
875 let l:end -= 1 | |
876 endif | |
877 | |
878 " go to start (this includes empty lines) and--importantly--column 0 | |
879 execute 'normal! '.l:start.'G0' | |
880 | |
881 " skip empty lines (unless already on one .. need to be in column 0) | |
882 call search('^[^\n\r]', 'Wc') | |
883 | |
884 " go to end (this includes empty lines) | |
885 execute 'normal! Vo'.l:end.'G' | |
886 | |
887 " skip backwards to last selected non-empty line | |
888 call search('^[^\n\r]', 'bWc') | |
889 | |
890 " go to end-of-line 'cause why not | |
891 normal! $o | |
892 | |
893 " restore magic | |
894 let &magic = l:magic | |
895 endfunction | |
896 | |
897 " "in indentation" (indentation level sans any surrounding empty lines) | |
898 xnoremap <silent> ii :<c-u>call <sid>inIndentation()<cr> | |
899 onoremap <silent> ii :<c-u>call <sid>inIndentation()<cr> | |
900 | |
901 function! s:aroundIndentation() | |
902 " select all text in the current indentation level including any emtpy | |
903 " lines that precede or follow the current indentation level; | |
904 " | |
905 " the current implementation is pretty fast, even for many lines since it | |
906 " uses "search()" with "\%v" to find the unindented levels | |
907 " | |
908 " NOTE: if the current level of indentation is 1 (ie in virtual column 1), | |
909 " then the entire buffer will be selected | |
910 " | |
911 " WARNING: python devs have been known to become addicted to this | |
912 | |
913 " magic is needed for this (/\v doesn't seem work) | |
914 let l:magic = &magic | |
915 set magic | |
916 | |
917 " move to beginning of line and get virtcol (current indentation level) | |
918 " BRAM: there is no searchpairvirtpos() ;) | |
919 normal! ^ | |
920 let l:vCol = virtcol(getline('.') =~# '^\s*$' ? '$' : '.') | |
921 | |
922 " pattern matching anything except empty lines and lines with recorded | |
923 " indentation level | |
924 let l:pat = '^\(\s*\%'.l:vCol.'v\|^$\)\@!' | |
925 | |
926 " find first match (backwards & don't wrap or move cursor) | |
927 let l:start = search(l:pat, 'bWn') + 1 | |
928 | |
929 " NOTE: if l:start is 0, then search() failed; otherwise search() succeeded | |
930 " and l:start does not equal line('.') | |
931 " FORMER: l:start is 0; so, if we add 1 to l:start, then it will match | |
932 " everything from beginning of the buffer (if you don't like | |
933 " this, then you can modify the code) since this will be the | |
934 " equivalent of "norm! 1G" below | |
935 " LATTER: l:start is not 0 but is also not equal to line('.'); therefore, | |
936 " we want to add one to l:start since it will always match one | |
937 " line too high if search() succeeds | |
938 | |
939 " next, find first match (forwards & don't wrap or move cursor) | |
940 let l:end = search(l:pat, 'Wn') | |
941 | |
942 " NOTE: if l:end is 0, then search() failed; otherwise, if l:end is not | |
943 " equal to line('.'), then the search succeeded. | |
944 " FORMER: l:end is 0; we want this to match until the end-of-buffer if it | |
945 " fails to find a match for same reason as mentioned above; | |
946 " again, modify code if you do not like this); therefore, keep | |
947 " 0--see "NOTE:" below inside the if block comment | |
948 " LATTER: l:end is not 0, so the search() must have succeeded, which means | |
949 " that l:end will match a different line than line('.') | |
950 | |
951 if (l:end !=# 0) | |
952 " if l:end is 0, then the search() failed; if we subtract 1, then it | |
953 " will effectively do "norm! -1G" which is definitely not what is | |
954 " desired for probably every circumstance; therefore, only subtract one | |
955 " if the search() succeeded since this means that it will match at least | |
956 " one line too far down | |
957 " NOTE: exec "norm! 0G" still goes to end-of-buffer just like "norm! G", | |
958 " so it's ok if l:end is kept as 0. As mentioned above, this means | |
959 " that it will match until end of buffer, but that is what I want | |
960 " anyway (change code if you don't want) | |
961 let l:end -= 1 | |
962 endif | |
963 | |
964 " finally, select from l:start to l:end | |
965 execute 'normal! '.l:start.'G0V'.l:end.'G$o' | |
966 | |
967 " restore magic | |
968 let &magic = l:magic | |
969 endfunction | |
970 | |
971 " "around indentation" (indentation level and any surrounding empty lines) | |
972 xnoremap <silent> ai :<c-u>call <sid>aroundIndentation()<cr> | |
973 onoremap <silent> ai :<c-u>call <sid>aroundIndentation()<cr> | |
974 " }}} | |
975 " }}} | |
976 | |
977 " Filetype specific settings {{{ | |
978 " Latex {{{ | |
979 " Open pdf | |
980 | |
981 function! Latexprog() | |
982 if !filereadable("./Makefile") | |
983 setlocal makeprg=latexmk\ -interaction=nonstopmode\ -synctex=1\ -file-line-error\ -pdf\ %:r | |
984 endif | |
985 endfunction | |
986 | |
987 augroup latex | |
988 autocmd! | |
989 autocmd FileType tex call Latexprog() | |
990 au BufNewFile,BufRead,BufEnter *.tex setlocal spell spelllang=en_gb | |
991 au BufNewFile,BufRead,BufEnter *.tex setlocal textwidth=0 | |
992 augroup END | |
993 " }}} | |
994 " Markdown {{{ | |
995 let g:vim_markdown_folding_disabled=1 | |
996 " }}} | |
997 " Text {{{ | |
998 augroup ft_text | |
999 au! | |
1000 " au BufNewFile,BufRead,BufEnter *.txt setlocal spell spelllang=en_gb | |
1001 au BufNewFile,BufRead,BufEnter *.txt setlocal textwidth=0 | |
1002 augroup END | |
1003 augroup ft_report | |
1004 au! | |
1005 au BufNewFile,BufRead,BufEnter *.rpt setlocal nowrap | |
1006 au BufNewFile,BufRead,BufEnter *.rpt call ColorRpt() | |
1007 au BufNewFile,BufRead,BufEnter *.log call ColorRpt() | |
1008 augroup END | |
1009 | |
1010 function! ColorRpt() | |
1011 " Color numbers based on length | |
1012 syn match String "\v<\d{1,3}>" | |
1013 syn match Number "\v<\d{4,6}>" | |
1014 syn match Statement "\v<\d{7,9}>" | |
1015 | |
1016 " Color errors | |
1017 syn match Error "\v^ERROR:.*$" | |
1018 endfunction | |
1019 " }}} | |
1020 " Git commit messages {{{ | |
1021 augroup ft_git | |
1022 au! | |
1023 au FileType gitcommit setlocal spell spelllang=en_gb | |
1024 augroup END | |
1025 " }}} | |
1026 " Ruby {{{ | |
1027 augroup ft_ruby | |
1028 au! | |
1029 autocmd BufRead *_spec.rb set filetype=rspec | |
1030 augroup END | |
1031 " }}} | |
1032 " Matlab {{{ | |
1033 augroup ft_matlab | |
1034 au! | |
1035 autocmd FileType matlab setlocal commentstring=\%\ %s | |
1036 augroup END | |
1037 " }}} | |
1038 " C {{{ | |
1039 augroup ft_c | |
1040 au! | |
1041 au FileType c setlocal foldmethod=syntax | |
1042 augroup END | |
1043 " }}} | |
1044 " VHDL {{{ | |
1045 " VHDL ctags | |
1046 let g:tlist_vhdl_settings = 'vhdl;d:package declarations;b:package bodies;e:entities;a:architecture specifications;t:type declarations;p:processes;f:functions;r:procedures' | |
1047 let g:vhdl_indent_genportmap =0 | |
1048 let g:vhdl_indent_rhassign = 1 | |
1049 | |
1050 augroup ft_vhdl | |
1051 au! | |
1052 autocmd FileType vhdl call VHDLColonAlign() | |
1053 augroup END | |
1054 | |
1055 function! SetAutoAlign() | |
1056 inoremap <silent> => =><ESC>mzvip:EasyAlign/=>/<CR>`z$a | |
1057 endfunction | |
1058 | |
1059 function! VHDLChipScopeMacro() | |
1060 let @c = "mtyiw'Sosignal \"_cs : std_logic;'Coattribute mark_debug of \"_cs : signal is \"true\"; | |
1061 attribute dont_touch of \"_cs : signal is \"true\";'Do\"_cs <= \";=='t" | |
1062 endfunction | |
1063 | |
1064 function! VHDLColonAlign() | |
1065 let g:easy_align_delimiters = { | |
1066 \ ':': { 'pattern': ':', 'left_margin': 1, 'right_margin': 1, 'stick_to_left': 0} | |
1067 \} | |
1068 endfunction | |
1069 " }}} | |
1070 " TCL {{{ | |
1071 | |
1072 augroup ft_tcl | |
1073 au! | |
1074 autocmd FileType tcl setlocal commentstring=#\ %s | |
1075 " autocmd FileType tcl compiler nagelfar | |
1076 autocmd BufRead *.do set filetype=tcl | |
1077 autocmd BufRead *.hal set filetype=tcl | |
1078 autocmd FileType tcl setlocal iskeyword+=: | |
1079 autocmd FileType tcl setlocal breakat-=: | |
1080 autocmd FileType tcl setlocal suffixesadd+=.tcl,.do | |
1081 augroup END | |
1082 " shortcuts | |
1083 iabbrev procargs array set arg [::argument_processing::proces_arguments $args]; | |
1084 " }}} | |
1085 " GPG {{{ | |
1086 " Don't save backups of gpg asc files | |
1087 set backupskip+=*.asc | |
1088 | |
1089 " Convenient editing of ascii-armoured encrypted files | |
1090 augroup GPGASCII | |
1091 au! | |
1092 au BufReadPost *.asc :%!gpg -q -d | |
1093 au BufReadPost *.asc |redraw | |
1094 au BufWritePre *.asc :%!gpg -q -e -a | |
1095 au BufWritePost *.asc u | |
1096 au VimLeave *.asc :!clear | |
1097 augroup END | |
1098 " }}} | |
1099 " System Verilog {{{ | |
1100 augroup ft_systemverilog | |
1101 au! | |
1102 au FileType systemverilog setlocal suffixesadd+=.sv,.v | |
1103 au FileType systemverilog setlocal foldmethod=marker | |
1104 au FileType systemverilog,verilog call SVAlign() | |
276
ecc3074ac1fc
Add delimitMate config for systemverilog and python
zegervdv <zegervdv@me.com>
parents:
275
diff
changeset
|
1105 au FileType systemverilog,verilog let b:delimitMate_quotes = "\"" |
273 | 1106 augroup END |
1107 | |
1108 function! SVAlign() | |
1109 let g:easy_align_delimiters = { | |
1110 \ ')': { 'pattern': '[()]', 'left_margin': 0, 'right_margin': 0, 'stick_to_left': 0} | |
1111 \} | |
1112 endfunction | |
1113 " }}} | |
1114 " Make {{{ | |
1115 augroup ft_make | |
1116 autocmd! | |
1117 autocmd BufEnter *.make setlocal filetype=make | |
1118 autocmd FileType make setlocal noexpandtab | |
1119 augroup END | |
1120 " JSON {{{ | |
1121 augroup ft_json | |
1122 autocmd! | |
1123 autocmd FileType json setlocal equalprg=jq | |
1124 augroup END | |
1125 " }}} | |
1126 " }}} | |
1127 " Python {{{ | |
1128 augroup f_python | |
1129 autocmd! | |
1130 autocmd FileType python setlocal shiftwidth=4 | |
1131 au FileType python setlocal formatprg=autopep8\ - | |
1132 autocmd FileType python setlocal path-=** | |
276
ecc3074ac1fc
Add delimitMate config for systemverilog and python
zegervdv <zegervdv@me.com>
parents:
275
diff
changeset
|
1133 autocmd Filetype python let b:delimitMate_nesting_quotes = ['"', "'"] |
273 | 1134 augroup END |
1135 | |
1136 let g:python_highlight_all=1 | |
1137 " }}} | |
1138 " }}} | |
1139 | |
1140 " Plugin settings {{{ | |
1141 " Easy-align {{{ | |
1142 " Start interactive EasyAlign in visual mode (e.g. vip<Enter>) | |
1143 vmap <Enter> <Plug>(EasyAlign) | |
1144 | |
1145 " Start interactive EasyAlign for a motion/text object (e.g. gaip) | |
1146 nmap ga <Plug>(EasyAlign) | |
1147 " }}} | |
1148 " Gundo tree {{{ | |
1149 nnoremap <leader>u :GundoToggle<CR> | |
1150 " }}} | |
1151 " Projectionist {{{ | |
1152 let g:projectionist_heuristics = { | |
1153 \ "*.c": { | |
1154 \ "*.c": { | |
1155 \ "alternate": "{}.h", | |
1156 \ "type": "source", | |
1157 \ "template": ["#include \"{}.h\""], | |
1158 \ "make": "make -wC {project}" | |
1159 \ }, | |
1160 \ "*.h": { | |
1161 \ "alternate": "{}.c", | |
1162 \ "type": "header", | |
1163 \ "template": ["#ifndef {uppercase}_H", "#define {uppercase}_H", "", "#endif"] | |
1164 \ }, | |
1165 \ "Makefile": {"type": "makefile"}, | |
1166 \ }, | |
1167 \ "*.py": { | |
1168 \ "*.py": { "make": "ipython {}" } | |
1169 \ }, | |
1170 \ } | |
1171 " }}} | |
1172 " Grep {{{ | |
1173 let g:grepper = { | |
1174 \ 'tools': ['ag', 'hg'], | |
1175 \ 'highlight': 1, | |
1176 \ 'ag': { | |
1177 \ 'grepprg': 'rg --vimgrep', | |
1178 \ }} | |
1179 | |
1180 nnoremap gs <plug>(GrepperOperator) | |
1181 xnoremap gs <plug>(GrepperOperator) | |
1182 | |
1183 | |
1184 command! -nargs=* -complete=file Ag Grepper -noprompt -tool ag -grepprg rg --vimgrep <args> | |
1185 " }}} | |
1186 " Vinegar/NetRW {{{ | |
1187 autocmd FileType netrw setl bufhidden=delete | |
1188 " }}} | |
1189 " NCM {{{ | |
1190 function! s:check_back_space() abort | |
1191 let col = col('.') - 1 | |
1192 return !col || getline('.')[col - 1] =~# '\s' | |
1193 endfunction | |
1194 | |
1195 | |
1196 " Auto close popup menu when finish completion | |
1197 autocmd! CompleteDone * if pumvisible() == 0 | pclose | endif | |
284 | 1198 |
1199 " Use <Tab> and <S-Tab> to navigate through popup menu | |
1200 inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>" | |
1201 inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>" | |
1202 | |
1203 " Set completeopt to have a better completion experience | |
1204 set completeopt=menuone,noinsert,noselect | |
1205 | |
1206 " Avoid showing message extra message when using completion | |
1207 set shortmess+=c | |
273 | 1208 |
1209 let g:completion_enable_snippet = 'UltiSnips' | |
1210 "Fallback for https://github.com/Raimondi/delimitMate expanding on enter | |
1211 let g:completion_confirm_key_rhs = "\<Plug>delimitMateCR" | |
1212 let g:UltiSnipsJumpForwardTrigger="<c-b>" | |
1213 let g:UltiSnipsJumpBackwardTrigger="<c-z>" | |
276
ecc3074ac1fc
Add delimitMate config for systemverilog and python
zegervdv <zegervdv@me.com>
parents:
275
diff
changeset
|
1214 |
ecc3074ac1fc
Add delimitMate config for systemverilog and python
zegervdv <zegervdv@me.com>
parents:
275
diff
changeset
|
1215 let delimitMate_expand_cr = 1 |
ecc3074ac1fc
Add delimitMate config for systemverilog and python
zegervdv <zegervdv@me.com>
parents:
275
diff
changeset
|
1216 let delimitMate_expand_space = 1 |
273 | 1217 " }}} |
1218 " Background make {{{ | |
1219 nnoremap <F9> :PMake<CR> | |
1220 " }}} | |
1221 " LanguageClient {{{ | |
1222 | |
1223 " }}} | |
1224 " Splice {{{ | |
1225 let g:splice_initial_diff_grid=1 | |
1226 let g:splice_initial_diff_compare=1 | |
1227 let g:splice_initial_diff_path=0 | |
1228 let g:splice_initial_scrollbind_grid=1 | |
1229 let g:splice_initial_scrollbind_compare=1 | |
1230 let g:splice_initial_scrollbind_path=1 | |
1231 let g:splice_wrap="nowrap" | |
1232 " }}} | |
1233 " Chipscoper {{{ | |
1234 nnoremap <leader>cm :call ChipScoperMark()<CR> | |
1235 nnoremap <leader>ci :call ChipScoperInsert()<CR> | |
1236 nnoremap <leader>cd :call ChipScoperUnMark()<CR> | |
1237 augroup cs_vhdl | |
1238 autocmd! | |
1239 autocmd FileType vhdl packadd chipscoper | |
1240 autocmd FileType vhdl silent! call ChipScoperSetup() | |
1241 augroup END | |
1242 " }}} | |
1243 " GDB {{{ | |
1244 let g:nvimgdb_disable_start_keymaps = 1 | |
1245 " }}} | |
1246 " context {{{ | |
1247 let g:context_enabled = 0 | |
1248 " }}} | |
1249 " ALE {{{ | |
1250 let g:ale_virtualtext_cursor=1 | |
274
b77b75c88ce6
Disable default formatting on save
zegervdv <zegervdv@me.com>
parents:
273
diff
changeset
|
1251 " augroup fmt |
b77b75c88ce6
Disable default formatting on save
zegervdv <zegervdv@me.com>
parents:
273
diff
changeset
|
1252 " autocmd! |
b77b75c88ce6
Disable default formatting on save
zegervdv <zegervdv@me.com>
parents:
273
diff
changeset
|
1253 " autocmd BufWritePre * try | undojoin | Neoformat | catch /^Vim\%((\a\+)\)\=:E790/ | finally | silent Neoformat | endtry |
b77b75c88ce6
Disable default formatting on save
zegervdv <zegervdv@me.com>
parents:
273
diff
changeset
|
1254 " augroup END |
273 | 1255 " }}} |
1256 " }}} | |
1257 | |
1258 function! SendOSCClipboard(lines, regtype) | |
1259 call SendViaOSC52(join(a:lines, "\n")) | |
1260 endfunction | |
1261 | |
1262 let g:clipboard = { | |
1263 \ 'name': 'TMUX', | |
1264 \ 'copy': { | |
1265 \ '+': function('SendOSCClipboard'), | |
1266 \ '*': 'tmux load-buffer -', | |
1267 \ }, | |
1268 \ 'paste': { | |
1269 \ '+': 'tmux save-buffer -', | |
1270 \ '*': 'tmux save-buffer -', | |
1271 \ }, | |
1272 \ 'cache_enabled': 1, | |
1273 \ } | |
1274 | |
280 | 1275 luafile ~/.config/nvim/init.lua |
1276 | |
273 | 1277 " Load local vimrc |
1278 if filereadable($HOME . '/.vimrc.local') | |
1279 source ~/.vimrc.local | |
1280 endif | |
1281 | |
1282 " Load project local vimrc | |
1283 if filereadable('.vimrc.local') | |
1284 source .vimrc.local | |
1285 endif | |
282 | 1286 |