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