xml: Add XML_reformat() function
[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_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 call neomake#configure#automake('w')
107 "let g:neomake_logfile = '/tmp/neomake.log'
108
109 let g:clang_compilation_database = '.'
110
111 " Speedup deoplete startup time, see deoplete FAQ
112 let g:python3_host_prog = '/usr/bin/python3'
113 " deoplete requires huge startuptime. Delay loading upon first InsertEnter.
114 let g:deoplete#enable_at_startup = 0
115 let g:deoplete#enable_smart_case = 1
116 au InsertEnter * call deoplete#enable()
117
118 "augroup pencil
119 "au!
120 "au FileType markdown,mkd call pencil#init()
121 "au FileType text call pencil#init()
122 "au FileType mail call pencil#init()
123 "au FileType tex call pencil#init()
124 "augroup END
125
126 let g:vim_markdown_folding_disabled=1
127 let g:vim_markdown_frontmatter=1
128 let g:vim_markdown_math=1
129
130
131 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
132 " Some filetype-specific settings
133
134 au FileType text,markdown,mail,tex,gitcommit,mediawiki,vimwiki setlocal spell
135 au FileType text,markdown,mail,gitcommit,mediawiki,vimwiki setlocal fo+=n
136
137 au Filetype go setlocal shiftwidth=8 tabstop=8 noexpandtab
138 au Filetype tex setlocal shiftwidth=2 tabstop=2
139
140 au FileType mediawiki setlocal wrap linebreak tw=0
141
142 "git scissor line
143 au Filetype mail syn match Statement /^\s*-*\s*>8\s*-*\s*$/
144 au Filetype mail syn match Statement /^\s*-*\s*8<\s*-*\s*$/
145
146 " Line wrap crippled with numbers shown
147 au Filetype man setlocal nonumber
148
149 " Java completion
150 au FileType java setlocal omnifunc=javacomplete#Complete
151 au FileType java JCEnable
152 " See https://github.com/artur-shaik/vim-Javacomplete2
153 " <C-j>ji <leader>ji
154 nmap <F4> <Plug>(JavaComplete-Imports-AddSmart)
155 imap <F4> <Plug>(JavaComplete-Imports-AddSmart)
156 " <C-j>ii <leader>jii
157 nmap <F5> <Plug>(JavaComplete-Imports-Add)
158 imap <F5> <Plug>(JavaComplete-Imports-Add)
159 " <C-j>I <leader>jI
160 nmap <F6> <Plug>(JavaComplete-Imports-AddMissing)
161 imap <F6> <Plug>(JavaComplete-Imports-AddMissing)
162 " <C-j>R <leader>jR
163 nmap <F7> <Plug>(JavaComplete-Imports-RemoveUnused)
164 imap <F7> <Plug>(JavaComplete-Imports-RemoveUnused)
165
166 " Minimum indenting for source code
167 au FileType java,cpp,c,cs let g:detectindent_min_indent = 4
168
169 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
170 " Some plugin-specific settings
171
172 au FileType markdown call RagtagInit()
173
174 let g:detectspelllang_langs = {}
175 let g:detectspelllang_langs.aspell =[ 'en_US', 'de_AT']
176 au BufReadPost *.java :DetectIndent
177
178 au BufEnter *.c* let b:fswitchlocs='reg:/lib/include/,rel:.'
179 au BufEnter *.h* let b:fswitchlocs='reg:/include/lib/,rel:.'
180
181 au BufEnter *.cpp,*.cc,*.cxx let b:fswitchdst='h,hxx,hpp,hh'
182 au BufEnter *.h,*.hh,*.hxx let b:fswitchdst='cc,c,cxx,cpp'
183
184 :let g:org_todo_keywords = [['TODO(t)', 'WAITING(w)', '|', 'DONE(d)'],
185 \ ['|', 'OBSOLETE(o)', 'WONT(n)'],
186 \ ['CANCELED(c)']]
187
188 let g:vimwiki_list = [{'path': '~/.vimwiki/',
189 \ 'template_path': '~/.vim/vimwiki/templates',
190 \ 'template_default': 'default',
191 \ 'template_ext': '.html'}]
192
193
194 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
195
196 runtime macros.vim
197 runtime keymaps.vim
198
199 if filereadable($HOME . '/.vim/init-local.vim')
200 source ~/.vim/init-local.vim
201 endif