61806e6cd52c48015658fde838301a871b15f2a3
[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 syntax on
42
43 " Load some macros
44 runtime macros.vim
45
46 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
47 " Some global plugin settings
48
49 " Disable devicons on linux terminal
50 if $TERM == 'linux'
51 let g:enable_plugin_devicons=0
52 " Enable loading of devicons on all others
53 else
54 let g:enable_plugin_devicons=1
55 endif
56
57 runtime plugsetup.vim
58
59 let g:EditorConfig_exclude_patterns = ['fugitive://.*', 'scp://.*']
60
61 " Some preferences for indent detection
62 let g:detectindent_min_indent = 2
63 let g:detectindent_max_indent = 4
64 let g:detectindent_preferred_indent = 4
65
66 " Attention: Must be run after plugsetup.vim
67 " Trailing whitespace
68 highlight default link BadWhitespace SpellCap
69
70 " Setup BadWhitespace syntax match expressions.
71 function SetBadWhitespaceSyntax()
72 " Do not expose bad whitespace in help buffers or for man pages. Or, more
73 " generally, if we open the file readonly.
74 "if &ft != "help" && &ft != "man"
75 if !&readonly
76 " Make trailing whitespace be flagged as bad.
77 syn match BadWhitespace /\s\+$/ containedin=ALL
78 " Make space before tab be flagged as bad and vice versa
79 syn match BadWhitespace / \+\t/ containedin=ALL
80 syn match BadWhitespace /\t \+/ containedin=ALL
81 endif
82 endfunction
83
84 " Make trailing whitespace be flagged as bad.
85 au BufRead,BufNewFile * call SetBadWhitespaceSyntax()
86
87 let g:airline_powerline_fonts=1
88 let g:airline#extensions#tabline#enabled=1
89 let g:airline#extensions#branch#enabled=1
90
91 let g:gruvbox_contrast_light='hard'
92 let g:gruvbox_contrast_dark='hard'
93 let g:gruvbox_italic = 1
94 set bg=dark
95 colorscheme gruvbox
96
97 " let NERDTreeWinPos="right"
98 let NERDTreeHijackNetrw=0
99 let NERDTreeWinSize=22
100 let NERDTreeQuitOnOpen=1
101 "au VimEnter * if !argc() | Startify | NERDTree | wincmd w
102
103 let g:neomake_c_enabled_makers = ['clangtidy', 'clangcheck']
104 let g:neomake_cpp_enabled_makers = ['clangtidy', 'clangcheck']
105
106 " Taken from neomake
107 if OnBattery()
108 call neomake#configure#automake('w')
109 else
110 call neomake#configure#automake('nw', 1000)
111 endif
112
113 let g:clang_compilation_database = '.'
114
115 " Speedup deoplete startup time, see deoplete FAQ
116 let g:python3_host_prog = '/usr/bin/python3'
117 " deoplete requires huge startuptime. Delay loading upon first InsertEnter.
118 let g:deoplete#enable_at_startup = 0
119 let g:deoplete#enable_smart_case = 1
120 au InsertEnter * call deoplete#enable()
121
122 "augroup pencil
123 "au!
124 "au FileType markdown,mkd call pencil#init()
125 "au FileType text call pencil#init()
126 "au FileType mail call pencil#init()
127 "au FileType tex call pencil#init()
128 "augroup END
129
130 let g:vim_markdown_folding_disabled=1
131 let g:vim_markdown_frontmatter=1
132 let g:vim_markdown_math=1
133
134
135 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
136 " Some filetype-specific settings
137
138 au FileType text,markdown,mail,tex,gitcommit,mediawiki,vimwiki setlocal spell
139 au FileType text,markdown,mail,gitcommit,mediawiki,vimwiki setlocal fo+=n
140 au Filetype mail setlocal formatoptions+=o
141 " Add | for block quotation, such that gq respects it
142 au Filetype mail setlocal comments+=n:\|
143
144 au Filetype go setlocal shiftwidth=8 tabstop=8 noexpandtab
145 au Filetype tex setlocal shiftwidth=2 tabstop=2
146
147 au FileType mediawiki setlocal wrap linebreak tw=0
148
149 "git scissor line
150 au Filetype mail syn match Statement /^\s*-*\s*>8\s*-*\s*$/
151 au Filetype mail syn match Statement /^\s*-*\s*8<\s*-*\s*$/
152
153 " Line wrap crippled with numbers shown
154 au Filetype man setlocal nonumber
155
156 " Minimum indenting for source code
157 au FileType java,cpp,c,cs let g:detectindent_min_indent = 4
158 " Consider using localvimrc config file or editorconfig instead
159 "au BufReadPost *.java :DetectIndent
160
161 au BufEnter *.c* let b:fswitchlocs='reg:/lib/include/,rel:.'
162 au BufEnter *.h* let b:fswitchlocs='reg:/include/lib/,rel:.'
163
164 au BufEnter *.cpp,*.cc,*.cxx let b:fswitchdst='h,hxx,hpp,hh'
165 au BufEnter *.h,*.hh,*.hxx let b:fswitchdst='cc,c,cxx,cpp'
166 au BufNewFile *.{h,hpp,hxx} call AddIncludeGuards()
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