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