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