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