1 " My personal vim, nvim, gvim configuration
2 " Author: Stefan Huber <shuber@sthu.org>
5 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
9 " Breaks colors for some versions of mosh, but not if tmux is used on top of
10 " mosh. See https://github.com/mobile-shell/mosh/issues/928
18 set listchars=tab:»,trail:·,eol:$
21 filetype plugin indent on
40 set wildmode=longest,list:full
49 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
50 " Some global plugin settings
52 " Disable devicons on linux terminal
54 let g:enable_plugin_devicons=0
55 " Enable loading of devicons on all others
57 let g:enable_plugin_devicons=1
62 let g:EditorConfig_exclude_patterns = ['fugitive://.*', 'scp://.*']
64 " Some preferences for indent detection
65 let g:detectindent_min_indent = 2
66 let g:detectindent_max_indent = 4
67 let g:detectindent_preferred_indent = 4
69 " Attention: Must be run after plugsetup.vim
71 highlight default link BadWhitespace SpellCap
73 " Setup BadWhitespace syntax match expressions.
74 function SetBadWhitespaceSyntax()
75 " Do not expose bad whitespace in help buffers or for man pages. Or, more
76 " generally, if we open the file readonly.
77 "if &ft != "help" && &ft != "man"
79 " Make trailing whitespace be flagged as bad.
80 syn match BadWhitespace /\s\+$/ containedin=ALL
81 " Make space before tab be flagged as bad and vice versa
82 syn match BadWhitespace / \+\t/ containedin=ALL
83 syn match BadWhitespace /\t \+/ containedin=ALL
87 " Make trailing whitespace be flagged as bad.
88 au BufRead,BufNewFile * call SetBadWhitespaceSyntax()
90 let g:airline_powerline_fonts=1
91 let g:airline#extensions#tabline#enabled=1
92 let g:airline#extensions#branch#enabled=1
94 let g:gruvbox_contrast_light='hard'
95 let g:gruvbox_contrast_dark='hard'
96 let g:gruvbox_italic = 1
100 " let NERDTreeWinPos="right"
101 let NERDTreeHijackNetrw=0
102 let NERDTreeWinSize=22
103 let NERDTreeQuitOnOpen=1
104 "au VimEnter * if !argc() | Startify | NERDTree | wincmd w
106 let g:neomake_c_enabled_makers = ['clangtidy', 'clangcheck']
107 let g:neomake_cpp_enabled_makers = ['clangtidy', 'clangcheck']
111 call neomake#configure#automake('w')
113 call neomake#configure#automake('nw', 1000)
116 let g:clang_compilation_database = '.'
118 " Speedup deoplete startup time, see deoplete FAQ
119 let g:python3_host_prog = '/usr/bin/python3'
120 " deoplete requires huge startuptime. Delay loading upon first InsertEnter.
121 let g:deoplete#enable_at_startup = 0
122 let g:deoplete#enable_smart_case = 1
123 au InsertEnter * call deoplete#enable()
127 "au FileType markdown,mkd call pencil#init()
128 "au FileType text call pencil#init()
129 "au FileType mail call pencil#init()
130 "au FileType tex call pencil#init()
133 let g:vim_markdown_frontmatter=1
134 let g:vim_markdown_math=1
137 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
138 " Some filetype-specific settings
140 au FileType text,markdown,asciidoc,mail,gitcommit,mediawiki,vimwiki,tex setlocal spell
141 au FileType text,markdown,asciidoc,mail,gitcommit,mediawiki,vimwiki setlocal formatoptions+=n
142 au Filetype mail setlocal formatoptions+=o
143 " Add | for block quotation, such that gq respects it
144 au Filetype mail setlocal comments+=n:\|,
146 au Filetype go setlocal shiftwidth=8 tabstop=8 noexpandtab
147 au Filetype tex setlocal shiftwidth=2 tabstop=2
149 au FileType mediawiki setlocal wrap linebreak textwidth=0
152 au Filetype mail syn match Statement /^\s*-*\s*>8\s*-*\s*$/
153 au Filetype mail syn match Statement /^\s*-*\s*8<\s*-*\s*$/
155 " Line wrap crippled with numbers shown
156 au Filetype man setlocal nonumber
158 " Minimum indenting for source code
159 au FileType java,cpp,c,cs let g:detectindent_min_indent = 4
160 " Consider using localvimrc config file or editorconfig instead
161 "au BufReadPost *.java :DetectIndent
163 au BufEnter *.c* let b:fswitchlocs='reg:/lib/include/,rel:.'
164 au BufEnter *.h* let b:fswitchlocs='reg:/include/lib/,rel:.'
166 au BufEnter *.cpp,*.cc,*.cxx let b:fswitchdst='h,hxx,hpp,hh'
167 au BufEnter *.h,*.hh,*.hxx let b:fswitchdst='cc,c,cxx,cpp'
168 au BufNewFile *.{h,hpp,hxx} call AddIncludeGuards()
170 augroup autofoldcolumn
172 au CursorHold,BufWinEnter * AutoOrigamiFoldColumn
175 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
176 " Some plugin-specific settings
178 let g:localvimrc_persistent = 1
180 au FileType markdown call RagtagInit()
182 let g:detectspelllang_langs = {}
183 let g:detectspelllang_langs.aspell =[ 'en_US', 'de_AT']
184 au FileType mail let g:VimMailSpellLangs=['de', 'en']
186 :let g:org_todo_keywords = [['TODO(t)', 'WAITING(w)', '|', 'DONE(d)'],
187 \ ['|', 'OBSOLETE(o)', 'WONT(n)'],
190 let g:vimwiki_list = [{'path': '~/.vimwiki/',
191 \ 'template_path': '~/.vim/vimwiki/templates',
192 \ 'template_default': 'default',
193 \ 'template_ext': '.html'}]
194 let g:vimwiki_global_ext = 0
197 au FileType java setlocal omnifunc=javacomplete#Complete
198 au FileType java JCEnable
200 let g:VimMailContactsProvider=['khard']
201 let g:VimMailContactsCommands={
203 \{ 'query' : "khard email --parsable --search-in-source-files",
204 \'sync': "/bin/true"}
208 " The denite settings are largely stolen from spacevim
209 let s:denite_options = {
213 \ 'start_filter' : 1,
215 \ 'highlight_matched_char' : 'MoreMsg',
216 \ 'highlight_matched_range' : 'MoreMsg',
217 \ 'direction': 'rightbelow',
220 augroup spacevim_layer_denite
222 autocmd FileType denite call s:denite_my_settings()
225 function! s:denite_my_settings() abort
226 nnoremap <silent><buffer><expr> i
227 \ denite#do_map('open_filter_buffer')
228 nnoremap <silent><buffer><expr> '
229 \ denite#do_map('toggle_select').'j'
230 nnoremap <silent><buffer><expr> q
231 \ denite#do_map('quit')
232 nnoremap <silent><buffer><expr> <C-t>
233 \ denite#do_map('do_action', 'tabopen')
234 nnoremap <silent><buffer><expr> <C-v>
235 \ denite#do_map('do_action', 'vsplit')
236 nnoremap <silent><buffer><expr> <C-s>
237 \ denite#do_map('do_action', 'split')
238 nnoremap <silent><buffer><expr> <CR>
239 \ denite#do_map('do_action')
240 nnoremap <silent><buffer><expr> p
241 \ denite#do_map('do_action', 'preview')
242 nnoremap <silent><buffer><Tab> j
243 nnoremap <silent><buffer><S-Tab> k
246 " FIND and GREP COMMANDS
248 " Ripgrep command on grep source
249 call denite#custom#var('grep', 'command', ['rg'])
250 call denite#custom#var('grep', 'default_opts',
251 \ ['--vimgrep', '--no-heading'])
252 call denite#custom#var('grep', 'recursive_opts', [])
253 call denite#custom#var('grep', 'pattern_opt', ['--regexp'])
254 call denite#custom#var('grep', 'separator', ['--'])
255 call denite#custom#var('grep', 'final_opts', [])
258 let s:insert_mode_mappings = [
259 \ ['jk', '<denite:enter_mode:normal>', 'noremap'],
260 \ ['<Tab>', '<denite:move_to_next_line>', 'noremap'],
261 \ ['<C-j>', '<denite:move_to_next_line>', 'noremap'],
262 \ ['<S-tab>', '<denite:move_to_previous_line>', 'noremap'],
263 \ ['<C-k>', '<denite:move_to_previous_line>', 'noremap'],
264 \ ['<C-t>', '<denite:do_action:tabopen>', 'noremap'],
265 \ ['<C-v>', '<denite:do_action:vsplit>', 'noremap'],
266 \ ['<C-s>', '<denite:do_action:split>', 'noremap'],
267 \ ['<Esc>', '<denite:enter_mode:normal>', 'noremap'],
268 \ ['<C-N>', '<denite:assign_next_matched_text>', 'noremap'],
269 \ ['<C-P>', '<denite:assign_previous_matched_text>', 'noremap'],
270 \ ['<Up>', '<denite:assign_previous_text>', 'noremap'],
271 \ ['<Down>', '<denite:assign_next_text>', 'noremap'],
272 \ ['<C-Y>', '<denite:redraw>', 'noremap'],
275 let s:normal_mode_mappings = [
276 \ ["'", '<denite:toggle_select_down>', 'noremap'],
277 \ ['<C-n>', '<denite:jump_to_next_source>', 'noremap'],
278 \ ['<C-p>', '<denite:jump_to_previous_source>', 'noremap'],
279 \ ['<Tab>', '<denite:move_to_next_line>', 'noremap'],
280 \ ['<C-j>', '<denite:move_to_next_line>', 'noremap'],
281 \ ['<S-tab>', '<denite:move_to_previous_line>', 'noremap'],
282 \ ['<C-k>', '<denite:move_to_previous_line>', 'noremap'],
283 \ ['gg', '<denite:move_to_first_line>', 'noremap'],
284 \ ['<C-t>', '<denite:do_action:tabopen>', 'noremap'],
285 \ ['<C-v>', '<denite:do_action:vsplit>', 'noremap'],
286 \ ['<C-s>', '<denite:do_action:split>', 'noremap'],
287 \ ['q', '<denite:quit>', 'noremap'],
288 \ ['r', '<denite:redraw>', 'noremap'],
291 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
295 if filereadable($HOME . '/.vim/init-local.vim')
296 source ~/.vim/init-local.vim