d5ad8eb35da2dd34a5830ff217202f285db3b164
[vimconf.git] / init.vim
1 " My personal vim, nvim, gvim configuration
2 " Author: Stefan Huber <shuber@sthu.org>
3
4
5 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
6 " Some global settings
7
8 set nocompatible
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
11 set termguicolors
12 set number
13 set cursorline
14 set scrolloff=5
15
16 set encoding=utf-8
17
18 set listchars=tab:»­,trail:·,eol:$
19 set virtualedit=block
20
21 filetype plugin indent on
22
23 set tabstop=4
24 set shiftwidth=4
25 set expandtab
26 set smarttab
27
28 set autoindent
29 set smartindent
30
31 set incsearch
32 set hlsearch
33
34 set foldcolumn=4
35 set foldlevelstart=20
36
37 set colorcolumn=+1
38 set mouse=a
39 set wildmenu
40 set wildmode=longest,list:full
41
42 set tabpagemax=100
43
44 syntax on
45
46 " Load some macros
47 runtime macros.vim
48
49 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
50 " Some global plugin settings
51
52 " Disable devicons on linux terminal
53 if $TERM == 'linux'
54 let g:enable_plugin_devicons=0
55 " Enable loading of devicons on all others
56 else
57 let g:enable_plugin_devicons=1
58 endif
59
60 runtime plugsetup.vim
61
62 let g:EditorConfig_exclude_patterns = ['fugitive://.*', 'scp://.*']
63
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
68
69 " Attention: Must be run after plugsetup.vim
70 " Trailing whitespace
71 highlight default link BadWhitespace SpellCap
72
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"
78 if !&readonly
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
84 endif
85 endfunction
86
87 " Make trailing whitespace be flagged as bad.
88 au BufRead,BufNewFile * call SetBadWhitespaceSyntax()
89
90 let g:airline_powerline_fonts=1
91 let g:airline#extensions#tabline#enabled=1
92 let g:airline#extensions#branch#enabled=1
93
94 let g:gruvbox_contrast_light='hard'
95 let g:gruvbox_contrast_dark='hard'
96 let g:gruvbox_italic = 1
97 set bg=dark
98 colorscheme gruvbox
99
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
105
106 let g:neomake_c_enabled_makers = ['clangtidy', 'clangcheck']
107 let g:neomake_cpp_enabled_makers = ['clangtidy', 'clangcheck']
108
109 " Taken from neomake
110 if OnBattery()
111 call neomake#configure#automake('w')
112 else
113 call neomake#configure#automake('nw', 1000)
114 endif
115
116 let g:clang_compilation_database = '.'
117
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()
124
125 "augroup pencil
126 "au!
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()
131 "augroup END
132
133 let g:vim_markdown_frontmatter=1
134 let g:vim_markdown_math=1
135
136
137 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
138 " Some filetype-specific settings
139
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:\|,
145
146 au Filetype go setlocal shiftwidth=8 tabstop=8 noexpandtab
147 au Filetype tex setlocal shiftwidth=2 tabstop=2
148
149 au FileType mediawiki setlocal wrap linebreak textwidth=0
150
151 "git scissor line
152 au Filetype mail syn match Statement /^\s*-*\s*>8\s*-*\s*$/
153 au Filetype mail syn match Statement /^\s*-*\s*8<\s*-*\s*$/
154
155 " Line wrap crippled with numbers shown
156 au Filetype man setlocal nonumber
157
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
162
163 au BufEnter *.c* let b:fswitchlocs='reg:/lib/include/,rel:.'
164 au BufEnter *.h* let b:fswitchlocs='reg:/include/lib/,rel:.'
165
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()
169
170 augroup autofoldcolumn
171 au!
172 au CursorHold,BufWinEnter * AutoOrigamiFoldColumn
173 augroup END
174
175 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
176 " Some plugin-specific settings
177
178 let g:localvimrc_persistent = 1
179
180 au FileType markdown call RagtagInit()
181
182 let g:detectspelllang_langs = {}
183 let g:detectspelllang_langs.aspell =[ 'en_US', 'de_AT']
184 au FileType mail let g:VimMailSpellLangs=['de', 'en']
185
186 :let g:org_todo_keywords = [['TODO(t)', 'WAITING(w)', '|', 'DONE(d)'],
187 \ ['|', 'OBSOLETE(o)', 'WONT(n)'],
188 \ ['CANCELED(c)']]
189
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
195
196 " Java completion
197 au FileType java setlocal omnifunc=javacomplete#Complete
198 au FileType java JCEnable
199
200 let g:VimMailContactsProvider=['khard']
201 let g:VimMailContactsCommands={
202 \'khard':
203 \{ 'query' : "khard email --parsable --search-in-source-files",
204 \'sync': "/bin/true"}
205 \}
206
207 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
208
209 runtime keymaps.vim
210
211 if filereadable($HOME . '/.vim/init-local.vim')
212 source ~/.vim/init-local.vim
213 endif