Mercurial > dotfiles
comparison .chezmoitemplates/config.vim @ 626:f795168ece65
clean up unused vim comfig
author | zegervdv <zegervdv@me.com> |
---|---|
date | Tue, 26 Jul 2022 22:33:25 +0200 |
parents | ad5e870cd4b2 |
children | a2a5862a3bd3 |
comparison
equal
deleted
inserted
replaced
625:c8960ba7f019 | 626:f795168ece65 |
---|---|
1 " vim:fdm=marker:ts=2:sw=2 | 1 " vim:fdm=marker:ts=2:sw=2 |
2 | 2 |
3 let s:darwin = has('mac') | 3 let s:darwin = has('mac') |
4 let s:windows = has('win32') | 4 let s:windows = has('win32') |
5 | 5 |
6 " Activate built in plugins | |
7 if !has('nvim') | |
8 if has('packages') | |
9 packadd! matchit | |
10 packadd! shellmenu | |
11 endif | |
12 endif | |
13 source $VIMRUNTIME/ftplugin/man.vim | |
14 | |
15 if has("nvim") | |
16 let g:python3_host_prog=expand('$HOME/.config/virtualenvs/python3/bin/python') | |
17 let g:python_host_prog=expand('$HOME/.config/virtualenvs/python2/bin/python') | |
18 endif | |
19 " | |
20 | 6 |
21 " General Settings and options | 7 " General Settings and options |
22 | 8 |
23 if !s:windows | 9 if !s:windows |
24 if !isdirectory(expand(&backupdir)) | 10 if !isdirectory(expand(&backupdir)) |
144 endif | 130 endif |
145 endfunction | 131 endfunction |
146 cnoremap <expr> <CR> CCR() | 132 cnoremap <expr> <CR> CCR() |
147 " | 133 " |
148 | 134 |
149 " Text objects | |
150 function! s:inIndentation() | |
151 " select all text in current indentation level excluding any empty lines | |
152 " that precede or follow the current indentationt level; | |
153 " | |
154 " the current implementation is pretty fast, even for many lines since it | |
155 " uses "search()" with "\%v" to find the unindented levels | |
156 " | |
157 " NOTE: if the current level of indentation is 1 (ie in virtual column 1), | |
158 " then the entire buffer will be selected | |
159 " | |
160 " WARNING: python devs have been known to become addicted to this | |
161 " magic is needed for this | |
162 let l:magic = &magic | |
163 set magic | |
164 | |
165 " move to beginning of line and get virtcol (current indentation level) | |
166 " BRAM: there is no searchpairvirtpos() ;) | |
167 normal! ^ | |
168 let l:vCol = virtcol(getline('.') =~# '^\s*$' ? '$' : '.') | |
169 | |
170 " pattern matching anything except empty lines and lines with recorded | |
171 " indentation level | |
172 let l:pat = '^\(\s*\%'.l:vCol.'v\|^$\)\@!' | |
173 | |
174 " find first match (backwards & don't wrap or move cursor) | |
175 let l:start = search(l:pat, 'bWn') + 1 | |
176 | |
177 " next, find first match (forwards & don't wrap or move cursor) | |
178 let l:end = search(l:pat, 'Wn') | |
179 | |
180 if (l:end !=# 0) | |
181 " if search succeeded, it went too far, so subtract 1 | |
182 let l:end -= 1 | |
183 endif | |
184 | |
185 " go to start (this includes empty lines) and--importantly--column 0 | |
186 execute 'normal! '.l:start.'G0' | |
187 | |
188 " skip empty lines (unless already on one .. need to be in column 0) | |
189 call search('^[^\n\r]', 'Wc') | |
190 | |
191 " go to end (this includes empty lines) | |
192 execute 'normal! Vo'.l:end.'G' | |
193 | |
194 " skip backwards to last selected non-empty line | |
195 call search('^[^\n\r]', 'bWc') | |
196 | |
197 " go to end-of-line 'cause why not | |
198 normal! $o | |
199 | |
200 " restore magic | |
201 let &magic = l:magic | |
202 endfunction | |
203 | |
204 " "in indentation" (indentation level sans any surrounding empty lines) | |
205 xnoremap <silent> ii :<c-u>call <sid>inIndentation()<cr> | |
206 onoremap <silent> ii :<c-u>call <sid>inIndentation()<cr> | |
207 | |
208 function! s:aroundIndentation() | |
209 " select all text in the current indentation level including any emtpy | |
210 " lines that precede or follow the current indentation level; | |
211 " | |
212 " the current implementation is pretty fast, even for many lines since it | |
213 " uses "search()" with "\%v" to find the unindented levels | |
214 " | |
215 " NOTE: if the current level of indentation is 1 (ie in virtual column 1), | |
216 " then the entire buffer will be selected | |
217 " | |
218 " WARNING: python devs have been known to become addicted to this | |
219 | |
220 " magic is needed for this (/\v doesn't seem work) | |
221 let l:magic = &magic | |
222 set magic | |
223 | |
224 " move to beginning of line and get virtcol (current indentation level) | |
225 " BRAM: there is no searchpairvirtpos() ;) | |
226 normal! ^ | |
227 let l:vCol = virtcol(getline('.') =~# '^\s*$' ? '$' : '.') | |
228 | |
229 " pattern matching anything except empty lines and lines with recorded | |
230 " indentation level | |
231 let l:pat = '^\(\s*\%'.l:vCol.'v\|^$\)\@!' | |
232 | |
233 " find first match (backwards & don't wrap or move cursor) | |
234 let l:start = search(l:pat, 'bWn') + 1 | |
235 | |
236 " NOTE: if l:start is 0, then search() failed; otherwise search() succeeded | |
237 " and l:start does not equal line('.') | |
238 " FORMER: l:start is 0; so, if we add 1 to l:start, then it will match | |
239 " everything from beginning of the buffer (if you don't like | |
240 " this, then you can modify the code) since this will be the | |
241 " equivalent of "norm! 1G" below | |
242 " LATTER: l:start is not 0 but is also not equal to line('.'); therefore, | |
243 " we want to add one to l:start since it will always match one | |
244 " line too high if search() succeeds | |
245 | |
246 " next, find first match (forwards & don't wrap or move cursor) | |
247 let l:end = search(l:pat, 'Wn') | |
248 | |
249 " NOTE: if l:end is 0, then search() failed; otherwise, if l:end is not | |
250 " equal to line('.'), then the search succeeded. | |
251 " FORMER: l:end is 0; we want this to match until the end-of-buffer if it | |
252 " fails to find a match for same reason as mentioned above; | |
253 " again, modify code if you do not like this); therefore, keep | |
254 " 0--see "NOTE:" below inside the if block comment | |
255 " LATTER: l:end is not 0, so the search() must have succeeded, which means | |
256 " that l:end will match a different line than line('.') | |
257 | |
258 if (l:end !=# 0) | |
259 " if l:end is 0, then the search() failed; if we subtract 1, then it | |
260 " will effectively do "norm! -1G" which is definitely not what is | |
261 " desired for probably every circumstance; therefore, only subtract one | |
262 " if the search() succeeded since this means that it will match at least | |
263 " one line too far down | |
264 " NOTE: exec "norm! 0G" still goes to end-of-buffer just like "norm! G", | |
265 " so it's ok if l:end is kept as 0. As mentioned above, this means | |
266 " that it will match until end of buffer, but that is what I want | |
267 " anyway (change code if you don't want) | |
268 let l:end -= 1 | |
269 endif | |
270 | |
271 " finally, select from l:start to l:end | |
272 execute 'normal! '.l:start.'G0V'.l:end.'G$o' | |
273 | |
274 " restore magic | |
275 let &magic = l:magic | |
276 endfunction | |
277 | |
278 " "around indentation" (indentation level and any surrounding empty lines) | |
279 xnoremap <silent> ai :<c-u>call <sid>aroundIndentation()<cr> | |
280 onoremap <silent> ai :<c-u>call <sid>aroundIndentation()<cr> | |
281 " | |
282 " | |
283 | |
284 " Filetype specific settings | 135 " Filetype specific settings |
285 " Text | 136 " Text |
286 augroup ft_text | 137 augroup ft_text |
287 au! | 138 au! |
288 " au BufNewFile,BufRead,BufEnter *.txt setlocal spell spelllang=en_gb | 139 " au BufNewFile,BufRead,BufEnter *.txt setlocal spell spelllang=en_gb |
305 syn match Error "\v^ERROR:.*$" | 156 syn match Error "\v^ERROR:.*$" |
306 endfunction | 157 endfunction |
307 " | 158 " |
308 | 159 |
309 " Plugin settings | 160 " Plugin settings |
310 " Gundo tree | |
311 nnoremap <leader>u :GundoToggle<CR> | |
312 | |
313 | 161 |
314 " | 162 " |
315 " Vinegar/NetRW | 163 " Vinegar/NetRW |
316 autocmd FileType netrw setl bufhidden=delete | 164 autocmd FileType netrw setl bufhidden=delete |
317 " | 165 " |
318 " Load local vimrc | |
319 if filereadable($HOME . '/.vimrc.local') | |
320 source ~/.vimrc.local | |
321 endif | |
322 | |
323 " Load project local vimrc | |
324 if filereadable('.vimrc.local') | |
325 source .vimrc.local | |
326 endif | |
327 | |
328 augroup Chezmoi | 166 augroup Chezmoi |
329 autocmd! | 167 autocmd! |
330 autocmd BufWritePost ~/.local/share/chezmoi/* silent !chezmoi apply --source-path % | 168 autocmd BufWritePost ~/.local/share/chezmoi/* silent !chezmoi apply --source-path % |
331 autocmd BufWritePost ~/.local/share/chezmoi/.chezmoitemplates/init.lua silent !chezmoi apply --source-path ~/.local/share/chezmoi/dot_config/nvim/init.lua.tmpl | 169 autocmd BufWritePost ~/.local/share/chezmoi/.chezmoitemplates/init.lua silent !chezmoi apply --source-path ~/.local/share/chezmoi/dot_config/nvim/init.lua.tmpl |
332 autocmd BufWritePost ~/.local/share/chezmoi/.chezmoitemplates/config.vim silent !chezmoi apply --source-path ~/.local/share/chezmoi/dot_config/nvim/plugin/config.vim.tmpl | 170 autocmd BufWritePost ~/.local/share/chezmoi/.chezmoitemplates/config.vim silent !chezmoi apply --source-path ~/.local/share/chezmoi/dot_config/nvim/plugin/config.vim.tmpl |