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