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