1 " My personal vim, nvim, gvim configuration
2 " Author: Stefan Huber <shuber@sthu.org>
5 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
15 set fillchars=vert:│,fold:\
16 set listchars=tab:»,trail:·,eol:$
19 filetype plugin indent on
38 set wildmode=longest,list:full
47 if filereadable($HOME . '/.vim/lowendbox')
53 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
54 " Some global plugin settings
56 " Disable devicons on linux terminal
58 let g:enable_plugin_devicons=0
59 " Enable loading of devicons on all others
61 let g:enable_plugin_devicons=1
66 let g:EditorConfig_exclude_patterns = ['fugitive://.*', 'scp://.*']
68 " Some preferences for indent detection
69 let g:detectindent_min_indent = 2
70 let g:detectindent_max_indent = 4
71 let g:detectindent_preferred_indent = 4
73 " Attention: Must be run after plugsetup.vim
75 highlight default link BadWhitespace SpellCap
77 " Setup BadWhitespace syntax match expressions.
78 function SetBadWhitespaceSyntax()
79 " Do not expose bad whitespace in help buffers or for man pages. Or, more
80 " generally, if we open the file readonly.
81 "if &ft != "help" && &ft != "man"
83 " Make trailing whitespace be flagged as bad.
84 syn match BadWhitespace /\s\+$/ containedin=ALL
85 " Make space before tab be flagged as bad and vice versa
86 syn match BadWhitespace / \+\t/ containedin=ALL
87 syn match BadWhitespace /\t \+/ containedin=ALL
91 " Make trailing whitespace be flagged as bad.
92 au BufRead,BufNewFile * call SetBadWhitespaceSyntax()
94 let g:airline_powerline_fonts=1
95 let g:airline#extensions#tabline#enabled=1
96 let g:airline#extensions#branch#enabled=1
98 let g:gruvbox_contrast_light='hard'
99 let g:gruvbox_contrast_dark='hard'
103 let g:gruvbox_termcolors=16
105 " Setting termguicolors has two implications:
106 " - Breaks colors for some versions of mosh, but not if tmux is used on top of
107 " mosh. See https://github.com/mobile-shell/mosh/issues/928
109 let g:gruvbox_italic = 1
113 " let NERDTreeWinPos="right"
114 let NERDTreeHijackNetrw=0
115 let NERDTreeWinSize=22
116 let NERDTreeQuitOnOpen=1
117 "au VimEnter * if !argc() | Startify | NERDTree | wincmd w
119 if $USER != "root" && g:lowendbox == 0
120 let g:neomake_c_enabled_makers = ['clangtidy', 'clangcheck']
121 let g:neomake_cpp_enabled_makers = ['clangtidy', 'clangcheck']
122 let g:clang_compilation_database = '.'
126 call neomake#configure#automake('w')
128 call neomake#configure#automake('nw', 1000)
131 " Speedup deoplete startup time, see deoplete FAQ
132 let g:python3_host_prog = '/usr/bin/python3'
133 " deoplete requires huge startuptime. Delay loading upon first InsertEnter.
134 let g:deoplete#enable_at_startup = 0
135 call deoplete#custom#option({
136 \ 'smart_case' : v:true,
137 \ 'auto_refresh_delay' : 100,
139 au InsertEnter * call deoplete#enable()
144 "au FileType markdown,mkd call pencil#init()
145 "au FileType text call pencil#init()
146 "au FileType mail call pencil#init()
147 "au FileType tex call pencil#init()
150 let g:vim_markdown_frontmatter=1
151 let g:vim_markdown_math=1
154 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
155 " Some filetype-specific settings
157 au FileType text,markdown,asciidoc,mail,gitcommit,mediawiki,vimwiki,tex setlocal spell
158 au FileType text,markdown,asciidoc,mail,gitcommit,mediawiki,vimwiki setlocal formatoptions+=n
159 au Filetype mail setlocal formatoptions+=o
160 " Add | for block quotation, such that gq respects it
161 au Filetype mail setlocal comments+=n:\|,
163 au Filetype go setlocal shiftwidth=8 tabstop=8 noexpandtab
164 au Filetype tex setlocal shiftwidth=2 tabstop=2
166 au FileType mediawiki setlocal wrap linebreak textwidth=0
169 au Filetype mail syn match Statement /^\s*-*\s*>8\s*-*\s*$/
170 au Filetype mail syn match Statement /^\s*-*\s*8<\s*-*\s*$/
172 " Line wrap crippled with numbers shown
173 au Filetype man setlocal nonumber
175 " Minimum indenting for source code
176 au FileType java,cpp,c,cs let g:detectindent_min_indent = 4
177 " Consider using localvimrc config file or editorconfig instead
178 "au BufReadPost *.java :DetectIndent
180 au BufEnter *.c* let b:fswitchlocs='reg:/lib/include/,rel:.'
181 au BufEnter *.h* let b:fswitchlocs='reg:/include/lib/,rel:.'
183 au BufEnter *.cpp,*.cc,*.cxx let b:fswitchdst='h,hxx,hpp,hh'
184 au BufEnter *.h,*.hh,*.hxx let b:fswitchdst='cc,c,cxx,cpp'
185 au BufNewFile *.{h,hpp,hxx} call AddIncludeGuards()
187 au FileType cpp,c packadd termdebug
189 augroup autofoldcolumn
191 au CursorHold,BufWinEnter * AutoOrigamiFoldColumn
194 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
195 " Some plugin-specific settings
197 let g:localvimrc_persistent = 1
199 let g:fastfold_minlines = 0
201 au FileType markdown call RagtagInit()
203 let g:detectspelllang_langs = {}
204 let g:detectspelllang_langs.aspell =[ 'en_US', 'de_AT']
205 au FileType mail let g:VimMailSpellLangs=['de', 'en']
207 let g:org_todo_keywords = [['TODO(t)', 'WAITING(w)', '|', 'DONE(d)'],
208 \ ['|', 'OBSOLETE(o)', 'WONT(n)'],
211 let g:vimwiki_list = [{'path': '~/.vimwiki/',
212 \ 'template_path': '~/.vim/vimwiki/templates',
213 \ 'template_default': 'default',
214 \ 'template_ext': '.html'}]
215 let g:vimwiki_global_ext = 0
218 au FileType java setlocal omnifunc=javacomplete#Complete
219 au FileType java JCEnable
221 let g:VimMailContactsProvider=['khard']
222 let g:VimMailContactsCommands={
224 \{ 'query' : "khard email --parsable --search-in-source-files",
225 \'sync': "/bin/true"}
228 let g:vimtex_fold_enabled = 1
229 let g:vimtex_fold_levelmarker = '➜'
231 " termdebug split windows
232 let g:termdebug_wide = 1
233 let termdebugger = $HOME . '/.vim/gdb.sh'
235 let g:startify_files_number = 5
236 let g:startify_session_persistence = 1
237 let g:startify_lists = [
238 \ { 'type': 'dir', 'header': [' Recent files'] },
239 \ { 'type': 'sessions', 'header': [' Saved sessions'] },
243 let verstr = matchstr(execute('version'), 'NVIM v\zs[^\n]*')
244 let g:startify_custom_header = [
248 \ ' ┗┛ ╹ ╹ ╹ ' . verstr,
252 let verstr = matchstr(execute('version'), 'IMproved \zs[^\n ]*')
253 let g:startify_custom_header = [
257 \ ' ┗┛ ╹ ╹ ╹ ' . verstr,
263 if $USER != "root" && g:lowendbox == 0
265 " The denite settings are largely stolen from spacevim
266 let s:denite_options = {
270 \ 'start_filter' : 1,
272 \ 'highlight_matched_char' : 'MoreMsg',
273 \ 'highlight_matched_range' : 'MoreMsg',
274 \ 'direction': 'rightbelow',
277 augroup spacevim_layer_denite
279 autocmd FileType denite call s:denite_my_settings()
282 function! s:denite_my_settings() abort
283 nnoremap <silent><buffer><expr> i
284 \ denite#do_map('open_filter_buffer')
285 nnoremap <silent><buffer><expr> '
286 \ denite#do_map('toggle_select').'j'
287 nnoremap <silent><buffer><expr> q
288 \ denite#do_map('quit')
289 nnoremap <silent><buffer><expr> <C-t>
290 \ denite#do_map('do_action', 'tabopen')
291 nnoremap <silent><buffer><expr> <C-v>
292 \ denite#do_map('do_action', 'vsplit')
293 nnoremap <silent><buffer><expr> <C-s>
294 \ denite#do_map('do_action', 'split')
295 nnoremap <silent><buffer><expr> <CR>
296 \ denite#do_map('do_action')
297 nnoremap <silent><buffer><expr> p
298 \ denite#do_map('do_action', 'preview')
299 nnoremap <silent><buffer><Tab> j
300 nnoremap <silent><buffer><S-Tab> k
303 " FIND and GREP COMMANDS
305 " Ripgrep command on grep source
306 call denite#custom#var('grep', 'command', ['rg'])
307 call denite#custom#var('grep', 'default_opts',
308 \ ['--vimgrep', '--no-heading'])
309 call denite#custom#var('grep', 'recursive_opts', [])
310 call denite#custom#var('grep', 'pattern_opt', ['--regexp'])
311 call denite#custom#var('grep', 'separator', ['--'])
312 call denite#custom#var('grep', 'final_opts', [])
315 let s:insert_mode_mappings = [
316 \ ['jk', '<denite:enter_mode:normal>', 'noremap'],
317 \ ['<Tab>', '<denite:move_to_next_line>', 'noremap'],
318 \ ['<C-j>', '<denite:move_to_next_line>', 'noremap'],
319 \ ['<S-tab>', '<denite:move_to_previous_line>', 'noremap'],
320 \ ['<C-k>', '<denite:move_to_previous_line>', 'noremap'],
321 \ ['<C-t>', '<denite:do_action:tabopen>', 'noremap'],
322 \ ['<C-v>', '<denite:do_action:vsplit>', 'noremap'],
323 \ ['<C-s>', '<denite:do_action:split>', 'noremap'],
324 \ ['<Esc>', '<denite:enter_mode:normal>', 'noremap'],
325 \ ['<C-N>', '<denite:assign_next_matched_text>', 'noremap'],
326 \ ['<C-P>', '<denite:assign_previous_matched_text>', 'noremap'],
327 \ ['<Up>', '<denite:assign_previous_text>', 'noremap'],
328 \ ['<Down>', '<denite:assign_next_text>', 'noremap'],
329 \ ['<C-Y>', '<denite:redraw>', 'noremap'],
332 let s:normal_mode_mappings = [
333 \ ["'", '<denite:toggle_select_down>', 'noremap'],
334 \ ['<C-n>', '<denite:jump_to_next_source>', 'noremap'],
335 \ ['<C-p>', '<denite:jump_to_previous_source>', 'noremap'],
336 \ ['<Tab>', '<denite:move_to_next_line>', 'noremap'],
337 \ ['<C-j>', '<denite:move_to_next_line>', 'noremap'],
338 \ ['<S-tab>', '<denite:move_to_previous_line>', 'noremap'],
339 \ ['<C-k>', '<denite:move_to_previous_line>', 'noremap'],
340 \ ['gg', '<denite:move_to_first_line>', 'noremap'],
341 \ ['<C-t>', '<denite:do_action:tabopen>', 'noremap'],
342 \ ['<C-v>', '<denite:do_action:vsplit>', 'noremap'],
343 \ ['<C-s>', '<denite:do_action:split>', 'noremap'],
344 \ ['q', '<denite:quit>', 'noremap'],
345 \ ['r', '<denite:redraw>', 'noremap'],
349 set foldexpr=nvim_treesitter#foldexpr()
351 require'nvim-treesitter.configs'.setup {
352 -- one of "all", "maintained" (parsers with maintainers), or a list of languages
353 ensure_installed = "maintained",
354 -- List of parsers to ignore installing
355 ignore_install = { },
356 -- Modules and its options go here
364 incremental_selection = {
367 init_selection = "gnn",
368 node_incremental = "grn",
369 scope_incremental = "grc",
370 node_decremental = "grm",
377 highlight_definitions = {
383 smart_rename = "grr",
389 goto_definition = "gnd",
390 list_definitions = "gnD",
391 list_definitions_toc = "gO",
392 goto_next_usage = "<a-*>",
393 goto_previous_usage = "<a-#>",
403 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
407 if filereadable($HOME . '/.vim/init-local.vim')
408 source ~/.vim/init-local.vim