Mercurial > dotfiles
comparison dot_config/nvim/plugin/config.vim @ 423:5683e8e3e361
Use lua to configure
author | zegervdv <zegervdv@me.com> |
---|---|
date | Sun, 25 Jul 2021 18:16:46 +0200 |
parents | 04d84cc8e59a |
children | 10916f9b1676 |
comparison
equal
deleted
inserted
replaced
422:24330d37c9e3 | 423:5683e8e3e361 |
---|---|
23 endif | 23 endif |
24 " }}} | 24 " }}} |
25 | 25 |
26 " General Settings and options {{{ | 26 " General Settings and options {{{ |
27 | 27 |
28 " Backspace over everything, like normal | |
29 set backspace=2 | |
30 | |
31 " Buffers | |
32 set autoread " Read external changes | |
33 set hidden " Change between buffers without saving | |
34 set autowriteall " Write changes when losing focus | |
35 | |
36 " Visuals | |
37 set number | |
38 set relativenumber | |
39 set ruler | |
40 syntax on | |
41 set title | |
42 set scrolloff=4 " Stay 4 lines from top/bottom | |
43 set showcmd | |
44 | |
45 " Theme and style | |
46 | |
47 set termguicolors | |
48 | |
49 set background=dark | |
50 | |
51 if s:windows | |
52 set background=light | |
53 colorscheme PaperColor | |
54 set guifont=consolas:h10 | |
55 endif | |
56 | |
57 set showmatch " Highlight matching brackets | |
58 | |
59 set wrap " Wrap lines | |
60 set wrapmargin=2 " Stay 2 chars from side | |
61 set textwidth=79 | |
62 set colorcolumn=81 | |
63 set linebreak " Smarter wrapping | |
64 if v:version > 703 | |
65 set breakindent " Indent wrapped lines to same level | |
66 endif | |
67 | |
68 set fixendofline | |
69 | |
70 set expandtab " Expand tabs to spaces | |
71 set tabstop=2 shiftwidth=2 " Tab is 2 spaces | |
72 | |
73 set shiftround " Round shift indents to nearest value | |
74 | |
75 " Searching | |
76 set magic " Use magic regexes | |
77 set hlsearch " Highlight all matches | |
78 set incsearch " Show matches while typing | |
79 set ignorecase " Ignore case when searching | |
80 set smartcase " Be case sensitive if at least one uppercase char is used | |
81 set gdefault " Default substitute all matches on a line | |
82 if has('nvim') | |
83 set inccommand=nosplit | |
84 endif | |
85 | |
86 set autoindent " Automatically indent | |
87 set cindent " Indent based on C syntax | |
88 set cinwords+=foreach | |
89 | |
90 set updatetime=300 | |
91 | |
92 if s:darwin | |
93 set vb | |
94 endif | |
95 set noerrorbells " Don't beep | |
96 | |
97 set guioptions-=r | |
98 set guioptions-=l | |
99 set guioptions-=R | |
100 set guioptions-=L | |
101 set guioptions-=a | |
102 set guioptions-=m | |
103 set guioptions-=T | |
104 set guioptions+=c | |
105 | |
106 set history=100 " Set history 100 | |
107 set wildmenu " Command completion | |
108 set wildmode=longest:full,full " Complete to fullest match | |
109 set ttyfast " Use a fast terminal | |
110 set lazyredraw " No need to redraw constantly | |
111 set shortmess+=c | |
112 | |
113 set ttimeoutlen=-1 " Set the timeout to a minimum | |
114 set diffopt+=iwhite " Ignore spaces in diffs" | |
115 set diffopt+=internal,algorithm:patience " use patience algorithm for better diffs | |
116 | |
117 set tags=.git/tags,tags,/project/asic_fpga/tools/vim/share/vim/vimfiles/tags | |
118 | |
119 " Have find look through all folders | |
120 set path+=** | |
121 " Add PRJROOT and subdirs to path if it is set | |
122 if exists('$PRJROOT') | |
123 set path+=$PRJROOT/** | |
124 endif | |
125 | |
126 set formatoptions= | |
127 set formatoptions+=c " Format comments | |
128 set formatoptions+=r " Continue comments by default | |
129 set formatoptions+=o " Make comment when using o or O from comment line | |
130 set formatoptions+=q " Format comments with gq | |
131 set formatoptions+=n " Recognize numbered lists | |
132 set formatoptions+=2 " Use indent from 2nd line of a paragraph | |
133 " set formatoptions+=l " Don't break lines that are already long | |
134 set formatoptions+=1 " Break before 1-letter words | |
135 | |
136 set signcolumn=yes | |
137 | |
138 " Enable cursorline | |
139 set cursorline | |
140 augroup cline | 28 augroup cline |
141 au! | 29 au! |
142 autocmd WinEnter * setlocal cursorline | 30 autocmd WinEnter * setlocal cursorline |
143 autocmd WinLeave * setlocal nocursorline | 31 autocmd WinLeave * setlocal nocursorline |
144 augroup END | 32 augroup END |
145 | 33 |
146 if !s:windows | |
147 set list | |
148 set listchars=tab:»\ ,trail:·,extends:>,precedes:<,nbsp:+ | |
149 endif | |
150 | |
151 set sessionoptions-=options | |
152 | |
153 " Scan files for completion | |
154 set complete=.,w,b,u,k,kspell,t,i,d | |
155 set completeopt=menu,menuone,noselect | |
156 | |
157 set splitright | |
158 set virtualedit=block | |
159 | |
160 if v:version > 703 | |
161 set conceallevel=0 | |
162 if !has('nvim') | |
163 set cryptmethod=blowfish2 | |
164 endif | |
165 endif | |
166 | |
167 filetype plugin indent on | |
168 | |
169 set pastetoggle=<F2> " Toggle to paste mode | |
170 | |
171 if v:version >= 703 | |
172 set undofile | |
173 endif | |
174 set undolevels=1000 | |
175 set backup | |
176 set noswapfile | |
177 if has('nvim') | |
178 " set viminfo+=n~/.config/nvim/.viminfo | |
179 set backupdir=~/.config/nvim/tmp/backup/,. | |
180 set directory=~/.config/nvim/tmp/swap//,. | |
181 else | |
182 set viminfo+=n~/.vim/.viminfo | |
183 set backupdir=~/.vim/tmp/backup/,. | |
184 set directory=~/.vim/tmp/swap//,. | |
185 endif | |
186 if !isdirectory(expand(&backupdir)) | 34 if !isdirectory(expand(&backupdir)) |
187 call mkdir(expand(&backupdir), "p") | 35 call mkdir(expand(&backupdir), "p") |
188 endif | 36 endif |
189 if !isdirectory(expand(&directory)) | 37 if !isdirectory(expand(&directory)) |
190 call mkdir(expand(&directory), "p") | 38 call mkdir(expand(&directory), "p") |
191 endif | 39 endif |
192 | 40 |
193 if v:version >= 703 | 41 if v:version >= 703 |
194 if has('nvim') | |
195 set undodir=~/.config/nvim/tmp/undo//,. | |
196 else | |
197 set undodir=~/.vim/tmp/undo//,. | |
198 endif | |
199 if !isdirectory(expand(&undodir)) | 42 if !isdirectory(expand(&undodir)) |
200 call mkdir(expand(&undodir), "p") | 43 call mkdir(expand(&undodir), "p") |
201 endif | 44 endif |
202 endif | 45 endif |
203 | |
204 | |
205 set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.o,*.bin,*.elf,*.hex,*.eps,.git/**,*.dup,.hg/**,*.orig,*.*~ | |
206 | |
207 " No selecting via mouse (stops visual selection when scrolling) | |
208 set mouse=nic | |
209 | 46 |
210 " }}} | 47 " }}} |
211 | 48 |
212 " Mappings {{{ | 49 " Mappings {{{ |
213 " Set leader to spacebar | 50 " Set leader to spacebar |
345 augroup END | 182 augroup END |
346 let $GIT_EDITOR = 'nvr -cc split --remote-wait' | 183 let $GIT_EDITOR = 'nvr -cc split --remote-wait' |
347 endif | 184 endif |
348 | 185 |
349 " Open buffers, tags... in vertical splits | 186 " Open buffers, tags... in vertical splits |
350 nnoremap <leader>b :vert sbuffer | 187 nnoremap <leader>b :vert sbuffer |
351 nnoremap <leader>t :vert stjump | 188 nnoremap <leader>t :vert stjump |
352 nnoremap <leader>f :vert sfind | 189 nnoremap <leader>f :vert sfind |
353 | 190 |
354 | 191 |
355 " }}} | 192 " }}} |
356 | 193 |
357 " Functions {{{ | 194 " Functions {{{ |
731 onoremap <silent> ai :<c-u>call <sid>aroundIndentation()<cr> | 568 onoremap <silent> ai :<c-u>call <sid>aroundIndentation()<cr> |
732 " }}} | 569 " }}} |
733 " }}} | 570 " }}} |
734 | 571 |
735 " Filetype specific settings {{{ | 572 " Filetype specific settings {{{ |
736 " Latex {{{ | |
737 " Open pdf | |
738 | |
739 function! Latexprog() | |
740 if !filereadable("./Makefile") | |
741 setlocal makeprg=latexmk\ -interaction=nonstopmode\ -synctex=1\ -file-line-error\ -pdf\ %:r | |
742 endif | |
743 endfunction | |
744 | |
745 augroup latex | |
746 autocmd! | |
747 autocmd FileType tex call Latexprog() | |
748 au BufNewFile,BufRead,BufEnter *.tex setlocal spell spelllang=en_gb | |
749 au BufNewFile,BufRead,BufEnter *.tex setlocal textwidth=0 | |
750 augroup END | |
751 " }}} | |
752 " Markdown {{{ | |
753 let g:vim_markdown_folding_disabled=1 | |
754 " }}} | |
755 " Text {{{ | 573 " Text {{{ |
756 augroup ft_text | 574 augroup ft_text |
757 au! | 575 au! |
758 " au BufNewFile,BufRead,BufEnter *.txt setlocal spell spelllang=en_gb | 576 " au BufNewFile,BufRead,BufEnter *.txt setlocal spell spelllang=en_gb |
759 au BufNewFile,BufRead,BufEnter *.txt setlocal textwidth=0 | 577 au BufNewFile,BufRead,BufEnter *.txt setlocal textwidth=0 |
765 au BufNewFile,BufRead,BufEnter *.log call ColorRpt() | 583 au BufNewFile,BufRead,BufEnter *.log call ColorRpt() |
766 augroup END | 584 augroup END |
767 | 585 |
768 function! ColorRpt() | 586 function! ColorRpt() |
769 " Color numbers based on length | 587 " Color numbers based on length |
770 syn match String "\v<\d{1,3}>" | 588 syn match String "\v<\d{1,3}>" |
771 syn match Number "\v<\d{4,6}>" | 589 syn match Number "\v<\d{4,6}>" |
772 syn match Statement "\v<\d{7,9}>" | 590 syn match Statement "\v<\d{7,9}>" |
773 | 591 |
774 " Color errors | 592 " Color errors |
775 syn match Error "\v^ERROR:.*$" | 593 syn match Error "\v^ERROR:.*$" |
776 endfunction | 594 endfunction |
797 " C {{{ | 615 " C {{{ |
798 augroup ft_c | 616 augroup ft_c |
799 au! | 617 au! |
800 au FileType c setlocal foldmethod=syntax | 618 au FileType c setlocal foldmethod=syntax |
801 augroup END | 619 augroup END |
802 " }}} | |
803 " VHDL {{{ | |
804 " VHDL ctags | |
805 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' | |
806 let g:vhdl_indent_genportmap =0 | |
807 let g:vhdl_indent_rhassign = 1 | |
808 | |
809 augroup ft_vhdl | |
810 au! | |
811 autocmd FileType vhdl call VHDLColonAlign() | |
812 augroup END | |
813 | |
814 function! SetAutoAlign() | |
815 inoremap <silent> => =><ESC>mzvip:EasyAlign/=>/<CR>`z$a | |
816 endfunction | |
817 | |
818 function! VHDLChipScopeMacro() | |
819 let @c = "mtyiw'Sosignal \"_cs : std_logic;'Coattribute mark_debug of \"_cs : signal is \"true\"; | |
820 attribute dont_touch of \"_cs : signal is \"true\";'Do\"_cs <= \";=='t" | |
821 endfunction | |
822 | |
823 function! VHDLColonAlign() | |
824 let g:easy_align_delimiters = { | |
825 \ ':': { 'pattern': ':', 'left_margin': 1, 'right_margin': 1, 'stick_to_left': 0} | |
826 \} | |
827 endfunction | |
828 " }}} | 620 " }}} |
829 " TCL {{{ | 621 " TCL {{{ |
830 | 622 |
831 augroup ft_tcl | 623 augroup ft_tcl |
832 au! | 624 au! |
925 " }}} | 717 " }}} |
926 " Grep {{{ | 718 " Grep {{{ |
927 let g:grepper = { | 719 let g:grepper = { |
928 \ 'tools': ['ag', 'hg'], | 720 \ 'tools': ['ag', 'hg'], |
929 \ 'highlight': 1, | 721 \ 'highlight': 1, |
930 \ 'ag': { | 722 \ 'ag': { |
931 \ 'grepprg': 'rg --vimgrep', | 723 \ 'grepprg': 'rg --vimgrep', |
932 \ }} | 724 \ }} |
933 | 725 |
934 nnoremap gs <plug>(GrepperOperator) | 726 nnoremap gs <plug>(GrepperOperator) |
935 xnoremap gs <plug>(GrepperOperator) | 727 xnoremap gs <plug>(GrepperOperator) |
971 imap <expr> <Tab> vsnip#jumpable(1) ? '<Plug>(vsnip-jump-next)' : '<Tab>' | 763 imap <expr> <Tab> vsnip#jumpable(1) ? '<Plug>(vsnip-jump-next)' : '<Tab>' |
972 smap <expr> <Tab> vsnip#jumpable(1) ? '<Plug>(vsnip-jump-next)' : '<Tab>' | 764 smap <expr> <Tab> vsnip#jumpable(1) ? '<Plug>(vsnip-jump-next)' : '<Tab>' |
973 imap <expr> <S-Tab> vsnip#jumpable(-1) ? '<Plug>(vsnip-jump-prev)' : '<S-Tab>' | 765 imap <expr> <S-Tab> vsnip#jumpable(-1) ? '<Plug>(vsnip-jump-prev)' : '<S-Tab>' |
974 smap <expr> <S-Tab> vsnip#jumpable(-1) ? '<Plug>(vsnip-jump-prev)' : '<S-Tab>' | 766 smap <expr> <S-Tab> vsnip#jumpable(-1) ? '<Plug>(vsnip-jump-prev)' : '<S-Tab>' |
975 | 767 |
976 let delimitMate_expand_cr = 1 | 768 " }}} |
977 let delimitMate_expand_space = 1 | |
978 " }}} | |
979 " Splice {{{ | |
980 let g:splice_initial_diff_grid=1 | |
981 let g:splice_initial_diff_compare=1 | |
982 let g:splice_initial_diff_path=0 | |
983 let g:splice_initial_scrollbind_grid=1 | |
984 let g:splice_initial_scrollbind_compare=1 | |
985 let g:splice_initial_scrollbind_path=1 | |
986 let g:splice_wrap="nowrap" | |
987 " }}} | 769 " }}} |
988 " }}} | 770 " }}} |
989 | 771 |
990 function! SendOSCClipboard(lines, regtype) | 772 function! SendOSCClipboard(lines, regtype) |
991 call SendViaOSC52(join(a:lines, "\n")) | 773 call SendViaOSC52(join(a:lines, "\n")) |