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