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