08935f1364cd14ec878892cce241e9d45de6b6a5
[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 colorcolumn=+1
35 set mouse=a
36 set wildmenu
37 set wildmode=longest,list:full
38
39 set tabpagemax=100
40
41 " Some terminals cause weired symbols due to broken cursor-shape termcodes.
42 if has('nvim')
43 "set guicursor=
44 " Workaround some broken plugins which set guicursor indiscriminately.
45 "au OptionSet guicursor noautocmd set guicursor=
46 end
47
48 syntax on
49
50 " Load some macros
51 runtime macros.vim
52
53 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
54 " Some global plugin settings
55
56 " Disable devicons on linux terminal
57 if $TERM == 'linux'
58 let g:enable_plugin_devicons=0
59 " Enable loading of devicons on all others
60 else
61 let g:enable_plugin_devicons=1
62 endif
63
64 runtime plugsetup.vim
65
66 let g:EditorConfig_exclude_patterns = ['fugitive://.*', 'scp://.*']
67
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
72
73 " Attention: Must be run after plugsetup.vim
74 " Trailing whitespace
75 highlight default link BadWhitespace SpellCap
76
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"
82 if !&readonly
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
88 endif
89 endfunction
90
91 " Make trailing whitespace be flagged as bad.
92 au BufRead,BufNewFile * call SetBadWhitespaceSyntax()
93
94 let g:airline_powerline_fonts=1
95 let g:airline#extensions#tabline#enabled=1
96 let g:airline#extensions#branch#enabled=1
97
98 let g:gruvbox_contrast_light='hard'
99 let g:gruvbox_contrast_dark='hard'
100 let g:gruvbox_italic = 1
101 set bg=dark
102 colorscheme gruvbox
103
104 " let NERDTreeWinPos="right"
105 let NERDTreeHijackNetrw=0
106 let NERDTreeWinSize=22
107 let NERDTreeQuitOnOpen=1
108 "au VimEnter * if !argc() | Startify | NERDTree | wincmd w
109
110 let g:neomake_c_enabled_makers = ['clangtidy', 'clangcheck']
111 let g:neomake_cpp_enabled_makers = ['clangtidy', 'clangcheck']
112
113 " Taken from neomake
114 if OnBattery()
115 call neomake#configure#automake('w')
116 else
117 call neomake#configure#automake('nw', 1000)
118 endif
119
120 let g:clang_compilation_database = '.'
121
122 " Speedup deoplete startup time, see deoplete FAQ
123 let g:python3_host_prog = '/usr/bin/python3'
124 " deoplete requires huge startuptime. Delay loading upon first InsertEnter.
125 let g:deoplete#enable_at_startup = 0
126 let g:deoplete#enable_smart_case = 1
127 au InsertEnter * call deoplete#enable()
128
129 "augroup pencil
130 "au!
131 "au FileType markdown,mkd call pencil#init()
132 "au FileType text call pencil#init()
133 "au FileType mail call pencil#init()
134 "au FileType tex call pencil#init()
135 "augroup END
136
137 let g:vim_markdown_folding_disabled=1
138 let g:vim_markdown_frontmatter=1
139 let g:vim_markdown_math=1
140
141
142 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
143 " Some filetype-specific settings
144
145 au FileType text,markdown,mail,tex,gitcommit,mediawiki,vimwiki setlocal spell
146 au FileType text,markdown,mail,gitcommit,mediawiki,vimwiki setlocal fo+=n
147
148 au Filetype go setlocal shiftwidth=8 tabstop=8 noexpandtab
149 au Filetype tex setlocal shiftwidth=2 tabstop=2
150
151 au FileType mediawiki setlocal wrap linebreak tw=0
152
153 "git scissor line
154 au Filetype mail syn match Statement /^\s*-*\s*>8\s*-*\s*$/
155 au Filetype mail syn match Statement /^\s*-*\s*8<\s*-*\s*$/
156
157 " Line wrap crippled with numbers shown
158 au Filetype man setlocal nonumber
159
160 " Minimum indenting for source code
161 au FileType java,cpp,c,cs let g:detectindent_min_indent = 4
162 " Consider using localvimrc config file or editorconfig instead
163 "au BufReadPost *.java :DetectIndent
164
165 au BufEnter *.c* let b:fswitchlocs='reg:/lib/include/,rel:.'
166 au BufEnter *.h* let b:fswitchlocs='reg:/include/lib/,rel:.'
167
168 au BufEnter *.cpp,*.cc,*.cxx let b:fswitchdst='h,hxx,hpp,hh'
169 au BufEnter *.h,*.hh,*.hxx let b:fswitchdst='cc,c,cxx,cpp'
170 au BufNewFile *.{h,hpp,hxx} call AddIncludeGuards()
171
172 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
173 " Some plugin-specific settings
174
175 let g:localvimrc_persistent = 1
176
177 au FileType markdown call RagtagInit()
178
179 let g:detectspelllang_langs = {}
180 let g:detectspelllang_langs.aspell =[ 'en_US', 'de_AT']
181
182 :let g:org_todo_keywords = [['TODO(t)', 'WAITING(w)', '|', 'DONE(d)'],
183 \ ['|', 'OBSOLETE(o)', 'WONT(n)'],
184 \ ['CANCELED(c)']]
185
186 let g:vimwiki_list = [{'path': '~/.vimwiki/',
187 \ 'template_path': '~/.vim/vimwiki/templates',
188 \ 'template_default': 'default',
189 \ 'template_ext': '.html'}]
190
191 " Java completion
192 au FileType java setlocal omnifunc=javacomplete#Complete
193 au FileType java JCEnable
194 " See https://github.com/artur-shaik/vim-Javacomplete2
195 " <C-j>ji <leader>ji
196 au FileType java nmap <F4> <Plug>(JavaComplete-Imports-AddSmart)
197 au FileType java imap <F4> <Plug>(JavaComplete-Imports-AddSmart)
198 " <C-j>ii <leader>jii
199 au FileType java nmap <F5> <Plug>(JavaComplete-Imports-Add)
200 au FileType java imap <F5> <Plug>(JavaComplete-Imports-Add)
201 " <C-j>I <leader>jI
202 au FileType java nmap <F6> <Plug>(JavaComplete-Imports-AddMissing)
203 au FileType java imap <F6> <Plug>(JavaComplete-Imports-AddMissing)
204 " <C-j>R <leader>jR
205 au FileType java nmap <F7> <Plug>(JavaComplete-Imports-RemoveUnused)
206 au FileType java imap <F7> <Plug>(JavaComplete-Imports-RemoveUnused)
207
208
209 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
210
211 runtime keymaps.vim
212
213 if filereadable($HOME . '/.vim/init-local.vim')
214 source ~/.vim/init-local.vim
215 endif