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