init: Add comment on termguicolors with mosh
[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 " Breaks colors for some versions of mosh, but not if tmux is used on top of
10 " mosh. See https://github.com/mobile-shell/mosh/issues/928
11 set termguicolors
12 set number
13 set cursorline
14 set scrolloff=5
15
16 set encoding=utf-8
17
18 set listchars=tab:»­,trail:·,eol:$
19 set virtualedit=block
20
21 filetype plugin indent on
22
23 set tabstop=4
24 set shiftwidth=4
25 set expandtab
26 set smarttab
27
28 set autoindent
29 set smartindent
30
31 set incsearch
32 set hlsearch
33
34 set colorcolumn=+1
35 set mouse=a
36 set wildmode=longest,list:full
37
38 set tabpagemax=100
39
40 " Some terminals cause weired symbols due to broken cursor-shape termcodes.
41 if has('nvim')
42 "set guicursor=
43 " Workaround some broken plugins which set guicursor indiscriminately.
44 "au OptionSet guicursor noautocmd set guicursor=
45 end
46
47 syntax on
48
49 " Load some macros
50 runtime macros.vim
51
52 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
53 " Some global plugin settings
54
55 " Disable devicons on linux terminal
56 if $TERM == 'linux'
57 let g:enable_plugin_devicons=0
58 " Enable loading of devicons on all others
59 else
60 let g:enable_plugin_devicons=1
61 endif
62
63 runtime plugsetup.vim
64
65 let g:EditorConfig_exclude_patterns = ['fugitive://.*', 'scp://.*']
66
67 " Some preferences for indent detection
68 let g:detectindent_min_indent = 2
69 let g:detectindent_max_indent = 4
70 let g:detectindent_preferred_indent = 4
71
72 " Attention: Must be run after plugsetup.vim
73 " Trailing whitespace
74 highlight default link BadWhitespace SpellCap
75
76 " Setup BadWhitespace syntax match expressions.
77 function SetBadWhitespaceSyntax()
78 " Do not expose bad whitespace in help buffers or for man pages. Or, more
79 " generally, if we open the file readonly.
80 "if &ft != "help" && &ft != "man"
81 if !&readonly
82 " Make trailing whitespace be flagged as bad.
83 syn match BadWhitespace /\s\+$/ containedin=ALL
84 " Make space before tab be flagged as bad and vice versa
85 syn match BadWhitespace / \+\t/ containedin=ALL
86 syn match BadWhitespace /\t \+/ containedin=ALL
87 endif
88 endfunction
89
90 " Make trailing whitespace be flagged as bad.
91 au BufRead,BufNewFile * call SetBadWhitespaceSyntax()
92
93 let g:airline_powerline_fonts=1
94 let g:airline#extensions#tabline#enabled=1
95 let g:airline#extensions#branch#enabled=1
96
97 let g:gruvbox_contrast_light='hard'
98 let g:gruvbox_contrast_dark='hard'
99 let g:gruvbox_italic = 1
100 set bg=dark
101 colorscheme gruvbox
102
103 " let NERDTreeWinPos="right"
104 let NERDTreeHijackNetrw=0
105 let NERDTreeWinSize=22
106 let NERDTreeQuitOnOpen=1
107 "au VimEnter * if !argc() | Startify | NERDTree | wincmd w
108
109 let g:neomake_c_enabled_makers = ['clangtidy', 'clangcheck']
110 let g:neomake_cpp_enabled_makers = ['clangtidy', 'clangcheck']
111
112 " Taken from neomake
113 if OnBattery()
114 call neomake#configure#automake('w')
115 else
116 call neomake#configure#automake('nw', 1000)
117 endif
118
119 let g:clang_compilation_database = '.'
120
121 " Speedup deoplete startup time, see deoplete FAQ
122 let g:python3_host_prog = '/usr/bin/python3'
123 " deoplete requires huge startuptime. Delay loading upon first InsertEnter.
124 let g:deoplete#enable_at_startup = 0
125 let g:deoplete#enable_smart_case = 1
126 au InsertEnter * call deoplete#enable()
127
128 "augroup pencil
129 "au!
130 "au FileType markdown,mkd call pencil#init()
131 "au FileType text call pencil#init()
132 "au FileType mail call pencil#init()
133 "au FileType tex call pencil#init()
134 "augroup END
135
136 let g:vim_markdown_folding_disabled=1
137 let g:vim_markdown_frontmatter=1
138 let g:vim_markdown_math=1
139
140
141 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
142 " Some filetype-specific settings
143
144 au FileType text,markdown,mail,tex,gitcommit,mediawiki,vimwiki setlocal spell
145 au FileType text,markdown,mail,gitcommit,mediawiki,vimwiki setlocal fo+=n
146
147 au Filetype go setlocal shiftwidth=8 tabstop=8 noexpandtab
148 au Filetype tex setlocal shiftwidth=2 tabstop=2
149
150 au FileType mediawiki setlocal wrap linebreak tw=0
151
152 "git scissor line
153 au Filetype mail syn match Statement /^\s*-*\s*>8\s*-*\s*$/
154 au Filetype mail syn match Statement /^\s*-*\s*8<\s*-*\s*$/
155
156 " Line wrap crippled with numbers shown
157 au Filetype man setlocal nonumber
158
159 " Minimum indenting for source code
160 au FileType java,cpp,c,cs let g:detectindent_min_indent = 4
161 " Consider using localvimrc config file or editorconfig instead
162 "au BufReadPost *.java :DetectIndent
163
164 au BufEnter *.c* let b:fswitchlocs='reg:/lib/include/,rel:.'
165 au BufEnter *.h* let b:fswitchlocs='reg:/include/lib/,rel:.'
166
167 au BufEnter *.cpp,*.cc,*.cxx let b:fswitchdst='h,hxx,hpp,hh'
168 au BufEnter *.h,*.hh,*.hxx let b:fswitchdst='cc,c,cxx,cpp'
169
170 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
171 " Some plugin-specific settings
172
173 let g:localvimrc_persistent = 1
174
175 au FileType markdown call RagtagInit()
176
177 let g:detectspelllang_langs = {}
178 let g:detectspelllang_langs.aspell =[ 'en_US', 'de_AT']
179
180 :let g:org_todo_keywords = [['TODO(t)', 'WAITING(w)', '|', 'DONE(d)'],
181 \ ['|', 'OBSOLETE(o)', 'WONT(n)'],
182 \ ['CANCELED(c)']]
183
184 let g:vimwiki_list = [{'path': '~/.vimwiki/',
185 \ 'template_path': '~/.vim/vimwiki/templates',
186 \ 'template_default': 'default',
187 \ 'template_ext': '.html'}]
188
189 " Java completion
190 au FileType java setlocal omnifunc=javacomplete#Complete
191 au FileType java JCEnable
192 " See https://github.com/artur-shaik/vim-Javacomplete2
193 " <C-j>ji <leader>ji
194 au FileType java nmap <F4> <Plug>(JavaComplete-Imports-AddSmart)
195 au FileType java imap <F4> <Plug>(JavaComplete-Imports-AddSmart)
196 " <C-j>ii <leader>jii
197 au FileType java nmap <F5> <Plug>(JavaComplete-Imports-Add)
198 au FileType java imap <F5> <Plug>(JavaComplete-Imports-Add)
199 " <C-j>I <leader>jI
200 au FileType java nmap <F6> <Plug>(JavaComplete-Imports-AddMissing)
201 au FileType java imap <F6> <Plug>(JavaComplete-Imports-AddMissing)
202 " <C-j>R <leader>jR
203 au FileType java nmap <F7> <Plug>(JavaComplete-Imports-RemoveUnused)
204 au FileType java imap <F7> <Plug>(JavaComplete-Imports-RemoveUnused)
205
206
207 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
208
209 runtime keymaps.vim
210
211 if filereadable($HOME . '/.vim/init-local.vim')
212 source ~/.vim/init-local.vim
213 endif