diff options
Diffstat (limited to 'vimrc')
l---------[-rw-r--r--] | vimrc | 584 |
1 files changed, 1 insertions, 583 deletions
@@ -1,583 +1 @@ | |||
1 | " vim: textwidth=160 tabstop=2 shiftwidth=2 tw=160 colorcolumn=160 | vimrc-full \ No newline at end of file | |
2 | |||
3 | " START: LOADING PLUGINS | ||
4 | " ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ | ||
5 | call plug#begin() | ||
6 | |||
7 | Plug 'tpope/vim-surround' | " plugin makes cs"' inside a line replace " with ' | ||
8 | Plug 'tpope/vim-fugitive' | " the most complete GIT integration plugin | ||
9 | Plug 'godlygeek/tabular' | " align code on a sign, like :Tab/= | ||
10 | Plug 'ryanoasis/vim-devicons' | " eye candy icons | ||
11 | Plug 'mhinz/vim-signify' | " uses the sign column to indicate added, modified and removed lines | ||
12 | |||
13 | " TESTING: | " plugins which I am currently trying... | ||
14 | " Plug 'rkitover/vimpager' | ||
15 | " Plug 'wting/gitsessions.vim' | " worth a try: restore sessions based on the git repo you are working in | ||
16 | " Plug 'Shougo/neocomplete.vim' | " alternative to YouCompleteMe in some cases | ||
17 | " Plug 'tpope/vim-characterize' | " normal mode: make ga show character names of Unicode chars (ga shows hex and dec values) | ||
18 | |||
19 | " Colorschemes: | ||
20 | Plug 'chriskempson/base16-vim' | " not just one high quality color scheme (all named base16-*) | ||
21 | |||
22 | " SCRATCH: | " Unobtrusive scratch window | ||
23 | Plug 'mtth/scratch.vim' | ||
24 | nnoremap <F2> :ScratchPreview<CR> | ||
25 | |||
26 | " VIM_ROOTER: | " Unobtrusive scratch window | ||
27 | Plug 'airblade/vim-rooter' | " makes :lcd changes to projects (git-)root (code-completion, gf, grep, find) | ||
28 | |||
29 | " BUFEXPLORER: | " a buffer to list all buffers has the advantage, that default /-searches work in there | ||
30 | Plug 'jlanzarotta/bufexplorer' | ||
31 | nnoremap <F12> :ToggleBufExplorer<CR> | ||
32 | " autocmd BufEnter * lcd %:p:h | " Plugin vim-rooter get used instead (which is much more sane as well) | ||
33 | |||
34 | " AIRLINE: a fancy status line ========================================================================================= | ||
35 | Plug 'vim-airline/vim-airline' | " beautification of the mode line | ||
36 | set laststatus=2 | " required by AirLine, without status line does not appear until a window split | ||
37 | let g:airline_extensions = ['tabline', 'branch', 'syntastic', 'tagbar', 'whitespace', 'ycm'] | ||
38 | let b:airline_whitespace_checks = ['indent', 'trailing', 'long', 'mixed-indent-file'] | ||
39 | let g:airline_section_c = "" | " was: %F | ||
40 | let g:airline#extensions#tagbar#flags = 'f' | " even though the airline extension is off this controls :h tagbar-extend | ||
41 | let g:airline#extensions#tabline#left_sep = ' ' | ||
42 | let g:airline#extensions#tabline#left_alt_sep = ' | ' | ||
43 | let g:airline#extensions#tabline#fnamemod = ':t:.' | " let airline just show the filename without its path | ||
44 | let g:airline#extensions#tabline#disable_refresh = 1 | | ||
45 | let g:airline#extensions#tabline#enabled = 1 | | ||
46 | let g:airline#extensions#tabline#show_buffers = 1 | | ||
47 | let g:airline#extensions#tabline#show_tabs = 0 | | ||
48 | let g:airline#extensions#tagbar#enabled = 0 | | ||
49 | let g:airline#extensions#whitespace#enabled = 1 | | ||
50 | let g:airline#extensions#wordcount#enabled = 0 | | ||
51 | let g:airline_detect_modified = 0 | | ||
52 | let g:airline_detect_paste = 0 | | ||
53 | let g:airline_exclude_preview = 0 | | ||
54 | let g:airline_inactive_collapse = 1 | | ||
55 | let g:airline_powerline_fonts = 1 | | ||
56 | " AIRLINE_Theme: | ||
57 | Plug 'vim-airline/vim-airline-themes' | " airline themes to match any light and dark terminal using :AirlineTheme | ||
58 | let g:airline_theme='base16' | " specifies which colorscheme should airline uses | ||
59 | " let g:airline_theme='badcat' | " specifies which colorscheme should airline uses | ||
60 | " let g:airline_theme='papercolor' | " specifies which colorscheme should ionirline uses | ||
61 | |||
62 | |||
63 | " NERDTree: replaces NetRW, as long as it has so many bugs | ||
64 | Plug 'scrooloose/nerdtree' | " | ||
65 | let NERDTreeCascadeSingleChildDir = 0 | " I don't get how one can use <m> to create files in that included directory | ||
66 | let NERDTreeShowBookmarks = 1 | " show bookmarks by default (when opening for the first time) | ||
67 | let NERDTreeIgnore = ['\.aux$'] | ||
68 | |||
69 | " depending on if NERDTree has the focus: | ||
70 | nnoremap <expr> | ||
71 | \ <leader><leader> | ||
72 | \ bufwinnr("%")==g:NERDTree.GetWinNum() ? ':NERDTreeClose<CR>' : ':NERDTreeFind<CR>' | ||
73 | nnoremap <expr> | ||
74 | \ <Tab> | ||
75 | \ bufwinnr("%")==g:NERDTree.GetWinNum() ? '<C-W><C-W>' : ':bn<CR>' | ||
76 | nnoremap <expr> | ||
77 | \ <S-Tab> | ||
78 | \ bufwinnr("%")==g:NERDTree.GetWinNum() ? '<C-W><C-W>' : ':bp<CR>' | ||
79 | " close NERDTree if it is the last remaining window (taken from the official documentation) | ||
80 | " autocmd bufenter * | ||
81 | " \ if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif | ||
82 | " | ||
83 | " exec current line as a command, insert output of command (from: https://youtu.be/MquaityA1SM?t=35m45s) | ||
84 | nnoremap Q !!$SHELL<CR> | ||
85 | |||
86 | |||
87 | " Additional: ========================================. | ||
88 | Plug 'sheerun/vim-polyglot' " better syntax highlighting/indentation for multiple languages | ||
89 | let g:javascript_conceal_function = "ƒ" | ||
90 | let g:javascript_conceal_null = "ø" | ||
91 | let g:javascript_conceal_this = "@" | ||
92 | let g:javascript_conceal_return = "⇚" | ||
93 | let g:javascript_conceal_undefined = "¿" | ||
94 | let g:javascript_conceal_NaN = "ℕ" | ||
95 | let g:javascript_conceal_prototype = "¶" | ||
96 | let g:javascript_conceal_static = "•" | ||
97 | let g:javascript_conceal_super = "Ω" | ||
98 | let g:javascript_conceal_arrow_function = "⇒" | ||
99 | |||
100 | Plug 'majutsushi/tagbar' " superseeds taglist-plus, which isn't maintained any more | ||
101 | let g:tagbar_autoclose = 1 | ||
102 | let g:tagbar_autofocus = 1 | ||
103 | let g:tagbar_autoshowtag = 1 | ||
104 | let g:tagbar_compact = 0 | ||
105 | let g:tagbar_indent = 0 | ||
106 | let g:tagbar_foldlevel = 99 | ||
107 | nnoremap <leader>l :TagbarToggle<CR>| " bind TagBar to Hotkey Ctrl+L | ||
108 | nnoremap <F9> :TagbarToggle<CR>| " bind TagBar to Hotkey Ctrl+L | ||
109 | |||
110 | |||
111 | " Autocompleter: =====================================. | ||
112 | Plug 'Valloric/MatchTagAlways' " highlights the closing tag/brace/... | ||
113 | Plug 'Valloric/YouCompleteMe' | ||
114 | let g:ycm_add_preview_to_completeopt = 1 " reuse existing preview window | ||
115 | let g:ycm_autoclose_preview_window_after_insertion = 1 | ||
116 | let g:ycm_collect_identifiers_from_tags_files = 1 " Let YCM read tags from Ctags file | ||
117 | let g:ycm_seed_identifiers_with_syntax = 1 " Completion for programming language's keyword | ||
118 | let g:ycm_complete_in_comments = 1 " Completion in comments | ||
119 | let g:ycm_complete_in_strings = 1 " Completion in string | ||
120 | let g:ycm_error_symbol = '✖' " insert this as an error symbol in the gutter bar | ||
121 | let g:ycm_min_num_of_chars_for_completion = 1 | ||
122 | let g:ycm_use_ultisnips_completer = 1 " Default 1, just ensure | ||
123 | let g:ycm_warning_symbol = '➔' " insert this as a warning symbol in the gutter bar | ||
124 | let g:ycm_confirm_extra_conf = 0 " security is overrated | ||
125 | let g:ycm_key_list_select_completion = ['<Down>'] | ||
126 | let g:ycm_key_list_previous_completion = ['<Up>'] | ||
127 | let g:ycm_global_ycm_extra_conf = '~/src/ycm_extra_conf.py' | ||
128 | let g:ycm_semantic_triggers = { 'c': [ 're!.' ] } | ||
129 | " disable <tab>-key for YCM so that it can be used with ultisnips | ||
130 | " let g:ycm_key_list_select_completion=[] | ||
131 | " let g:ycm_key_list_previous_completion=[] | ||
132 | " | ||
133 | " Plug 'rdnetto/YCM-Generator' " you better use cmake to generate json build commands, like: | ||
134 | " 'cmake -D CMAKE_EXPORT_COMPILE_COMMANDS=1 ..' can be used to generate a .ycm-extra.conf compatible json file | ||
135 | |||
136 | |||
137 | |||
138 | Plug 'scrooloose/syntastic' | ||
139 | set statusline+=%#warningmsg# | ||
140 | set statusline+=%{SyntasticStatuslineFlag()} | ||
141 | " set statusline+=%* | ||
142 | set signcolumn=yes " always show the column | ||
143 | let g:LatexBox_latexmk_preview_continuously = 1 | ||
144 | let g:LatexBox_viewer = "evince" | ||
145 | let g:syntastic_always_populate_loc_list = 1 | ||
146 | let g:syntastic_auto_loc_list = 0 | ||
147 | let g:syntastic_check_on_open = 1 | ||
148 | let g:syntastic_check_on_wq = 0 | ||
149 | let g:syntastic_quiet_messages = {"type":"style"} | ||
150 | " filter ( = do not display) style/formatting errors and warnings | ||
151 | let g:syntastic_error_symbol = '✖' | ||
152 | let g:syntastic_style_error_symbol = '✗' | ||
153 | let g:syntastic_warning_symbol = '➔' | ||
154 | let g:syntastic_style_warning_symbol = '≈' | ||
155 | |||
156 | Plug 'davidhalter/jedi-vim' " jedi gets used to display python function signatures | ||
157 | let g:jedi#completions_enabled = 0 " we do not need completions, because we have YouCompleteMe | ||
158 | let g:jedi#show_call_signatures = 1 " which sadly does not support signatures like jedi | ||
159 | let g:jedi#show_call_signatures_delay = 0 | ||
160 | let g:jedi#auto_vim_configure = 0 | ||
161 | let g:pymode_rope = 0 " https://github.com/davidhalter/jedi-vim/issues/163 | ||
162 | " autocmd FileType python jedi.preload_module('os', 'sys', 'math') | ||
163 | " let g:pymode_options_max_line_length = 120 | ||
164 | " let g:syntastic_python_flake8_args='--ignore=F821,E302,E501,E241,E301' | ||
165 | |||
166 | " ULTISNIPS: code snippet ============================================================================================== | ||
167 | Plug 'honza/vim-snippets' " dependency of ultisnips (see below) | ||
168 | Plug 'SirVer/ultisnips' " replaces loremipsum (and many more) | ||
169 | "let g:UltiSnipsExpandTrigger = '<C-j>'| " Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe. | ||
170 | "let g:UltiSnipsJumpForwardTrigger = '<C-j>'| " \ | ||
171 | "let g:UltiSnipsJumpBackwardTrigger = '<C-k>'| " \ | ||
172 | "let g:UltiSnipsListSnippets = '<C-`>'| " YouCompleteMe includes those, so this isn't necessary | ||
173 | "let g:UltiSnipsExpandTrigger = '<leader><tab>'| " Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe. | ||
174 | "let g:UltiSnipsJumpForwardTrigger = '<PageDown>'| " \ | ||
175 | "let g:UltiSnipsJumpBackwardTrigger = '<PageUp>'| " \ | ||
176 | "let g:UltiSnipsListSnippets = '<leader><leader>'| " YouCompleteMe includes those, so this isn't necessary | ||
177 | " UltiSnips triggering | ||
178 | " let g:UltiSnipsExpandTrigger = "<nop>" | ||
179 | " let g:ulti_expand_or_jump_res = 0 | ||
180 | " function ExpandSnippetOrCarriageReturn() | ||
181 | " let snippet = UltiSnips#ExpandSnippetOrJump() | ||
182 | " if g:ulti_expand_or_jump_res > 0 | ||
183 | " return snippet | ||
184 | " else | ||
185 | " return "\<CR>" | ||
186 | " endif | ||
187 | " endfunction | ||
188 | " inoremap <expr> <CR> pumvisible() ? "\<C-R>=ExpandSnippetOrCarriageReturn()\<CR>" : "\<CR>" | ||
189 | " set completeopt-=preview | ||
190 | " let g:UltiSnipsEditSplit = 'vertical' | ||
191 | |||
192 | |||
193 | |||
194 | call plug#end() | " all plugins are getting loaded on this line, don't remove! | ||
195 | " ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ | ||
196 | " END: LOADING PLUGINS | ||
197 | |||
198 | |||
199 | "======================================================================================================================= | ||
200 | " GENERAL: | ||
201 | "======================================================================================================================= | ||
202 | filetype on | ||
203 | filetype plugin on | ||
204 | filetype indent on | ||
205 | |||
206 | syntax on | " enable syntax highlighting | ||
207 | syntax sync minlines=60 | " how many preceding lines will be parsed? (has performance impact) | ||
208 | |||
209 | "======================================================================================================================= | ||
210 | " SPELL_CHECKING: | ||
211 | "======================================================================================================================= | ||
212 | set spell | " enable spell checker | ||
213 | set spelllang=en,de | " languages for the spell checker | ||
214 | set spellsuggest=10 | " how many words will z= suggest? | ||
215 | set thesaurus+=/home/max/.vim/thesaurus/php.txt | ||
216 | let g:spellfile_URL='http://ftp.vim.org/vim/runtime/spell' | ||
217 | |||
218 | set dictionary=/usr/share/dict/cracklib-small | ||
219 | set complete+=k " make default completer <C-N> respect the dictionary | ||
220 | |||
221 | "======================================================================================================================= | ||
222 | " SETTINGS: | ||
223 | "======================================================================================================================= | ||
224 | set noautochdir | " When on, Vim will change the current working directory | ||
225 | set shell=/bin/bash | " many scripts rely on bash, but its path varies why it is commented out here | ||
226 | set breakindent | " Every wrapped line will continue visually indented | ||
227 | set clipboard=unnamedplus | " makes copy and paste work (autoselectplus might work as well) | ||
228 | set cmdheight=2 | " sets the command line's height | ||
229 | set complete+=d | " scan current and included files for defined name or macro | ||
230 | set complete+=i | " scan current and included files for completions | ||
231 | set concealcursor=nc | " limits the display of concealed text to normal and command mode | ||
232 | set conceallevel=2 | " replace escaped chars by their utf-8 representation (useful for LaTeX) | ||
233 | set confirm | " asks 'do you want to save?' | ||
234 | set encoding=utf-8 | " set up vim's cosole encoding (not file encoding, for which there is fileencoding=) | ||
235 | set hidden | " allows switiching buffers even if the current buffer contains changes (displays +) | ||
236 | set hlsearch | " highlights all search matches (not as performant!) | ||
237 | set ignorecase smartcase | " search with ignorecase by default, but use case sensitive search when one captical char is contained | ||
238 | set lazyredraw | " disables redraw during macro exectution (improves performance) | ||
239 | set linebreak | " wrap long lines at char 'breakat', not inside words | ||
240 | set mouse=n | " allow mouse in normal mode only, so one can use the terminals c&p feature in insert mode | ||
241 | set mousemodel=popup | " only in gvim: right click opens a popup-menu | ||
242 | set nocursorcolumn | " turn visual cursor column off (improves performance) | ||
243 | set nocursorline | " turn visual cursor line off (improves performance) | ||
244 | set nrformats+=alpha | " allows CTRL-A & CTRL-X to increment and decrement letters, not just numbers | ||
245 | set nofoldenable | " disable code folding. I hate code folding | ||
246 | set foldcolumn=4 | " if code folding gets used display it in the clutter bar, where line numbers live | ||
247 | set relativenumber | " relative line numbers can speed up navigation | ||
248 | set noshowmode | " because we are using some powerline derivat | ||
249 | set nostartofline | " when scrolling: do not move the cursor to column 1 | ||
250 | set notimeout ttimeout | " improves performance but is known to cause problems on slow terminals | ||
251 | set nowrap | " but do not (by default) wrap long lines around | ||
252 | set number | " turn line numbers on/off (performance decreases when they are shown) | ||
253 | set pumheight=8 | " Determines the maximum number of items to show in the popup menu for | ||
254 | set path+=** | " allow recursive searches for files | ||
255 | set redrawtime=400 | " The time in milliseconds for redrawing the display. | ||
256 | " set restorescreen | " restores the console after exiting vim | ||
257 | " set shada+=n~/.vim/shada | " shada file to use | ||
258 | set scrolljump=5 | " how many lines get scrolled into view when cursor reaches the screens edge | ||
259 | set splitbelow | " open new windows below the current one (i find that more intuitive) | ||
260 | set shiftround | " indent/unindent snaps to multiple of shiftwidth | ||
261 | " set showcmd | " essential: show keys of combined commands in the lower right corner (BUT SLOW, makes cursor flickering) | ||
262 | set noshowcmd | " essential: show keys of combined commands in the lower right corner (BUT SLOW, makes cursor flickering) | ||
263 | set winwidth=30 | " keep NERDTreeWindow at least this size | ||
264 | set winminwidth=30 | " (and all other windows, so TODO: watch out) | ||
265 | set tags+=../tags | ||
266 | " set textwidth=100 | " line length (80 used to be default, but...) | ||
267 | set textwidth=120 | " better done with modeline | ||
268 | set colorcolumn=120 | " better done with modeline | ||
269 | set ts=4 sts=4 sw=4 expandtab | " better done with a modeline | ||
270 | set ttimeoutlen=10 | " set esc key timeout in ms- | ||
271 | set updatetime=1000 | " updates the screen more often | ||
272 | set writedelay=0 | ||
273 | set lcs+=space:· | " local space char | ||
274 | "======================================================================================================================= | ||
275 | " COLORSCHEME: | ||
276 | " set term=xtermc | " may be required on solaris | ||
277 | set t_Co=256 | " required on some ssh sessions | ||
278 | let &t_Co=256 | ||
279 | set background=light | " hint how the terminal background looks like | ||
280 | |||
281 | " set termguicolors | ||
282 | let base16colorspace=256 | ||
283 | if filereadable(expand("~/.vimrc_background")) | ||
284 | source ~/.vimrc_background | ||
285 | else | ||
286 | colorscheme base16-phd | ||
287 | " colorscheme base16-embers | ||
288 | " colorscheme base16-flat | ||
289 | " colorscheme base16-summerfruit-dark | ||
290 | " colorscheme base16-tommorow | ||
291 | " colorscheme base16-default-dark | ||
292 | endif | ||
293 | |||
294 | highlight normal ctermbg=NONE | " uses the default terminal background color as background (allows transparency) | ||
295 | highlight CursorLineNr ctermbg=black ctermfg=NONE | ||
296 | |||
297 | |||
298 | highlight Cursor guibg=green | ||
299 | " let &t_EI .= "\<Esc>[0 q" | ||
300 | " let &t_SI = "\<Esc>]12;green\x7" | ||
301 | if has('autocmd') | ||
302 | autocmd VimEnter * let &t_EI .= "\<Esc>[0 q" | ||
303 | autocmd VimEnter * let &t_SI = "\<Esc>]12;black\x7" | ||
304 | autocmd VimLeave * silent !echo -ne "\033]112\007" | ||
305 | endif | ||
306 | |||
307 | "======================================================================================================================= | ||
308 | if has("multi_byte") | ||
309 | scriptencoding utf-8 | " tell vim that we are using utf-8 here | ||
310 | set encoding=utf-8 | " we need default utf-8 encoding to use cool chars as line break and so on (see below) | ||
311 | set termencoding=&encoding | " once we use special chars we assume everybody uses a terminal supporting those | ||
312 | |||
313 | set listchars= | " initialize empty listchars | ||
314 | set listchars+=extends:» | " symbols used when using :set list (which displays non-printable chars) | ||
315 | set listchars+=precedes:« | " symbols used when using :set list (which displays non-printable chars) | ||
316 | |||
317 | set listchars+=tab:˲\ | " symbols used when using :set list (which displays non-printable chars) | ||
318 | set listchars+=trail:· | " symbols used when using :set list (which displays non-printable chars) | ||
319 | " set listchars+=eol:↲ | " symbols used when using :set list (which displays non-printable chars) | ||
320 | " set listchars+=space:· | " symbols used when using :set list (which displays non-printable chars) | ||
321 | set showbreak+=› | " symbol used in the beginning of a wrapped line | ||
322 | set list | ||
323 | end | ||
324 | |||
325 | if has('cscope') " compiled with cscope support? | ||
326 | " http://vim.wikia.com/wiki/Cscope | ||
327 | set cscopetag cscopeverbose | ||
328 | |||
329 | if has('quickfix') | ||
330 | set cscopequickfix=s-,c-,d-,i-,t-,e- | ||
331 | endif | ||
332 | |||
333 | cnoreabbrev csa cs add | ||
334 | cnoreabbrev csf cs find | ||
335 | cnoreabbrev csk cs kill | ||
336 | cnoreabbrev csr cs reset | ||
337 | cnoreabbrev css cs show | ||
338 | cnoreabbrev csh cs help | ||
339 | |||
340 | command! -nargs=0 Cscope cs add $VIMSRC/src/cscope.out $VIMSRC/src | ||
341 | endif | ||
342 | |||
343 | " GUI_VERSION: | ||
344 | if has("gui_running") | ||
345 | set toolbar+=text | ||
346 | set guioptions+=eig | ||
347 | set guioptions-=T | " toolbar | ||
348 | set guioptions+=c | " use console dialogs instead of popups | ||
349 | set guioptions+=a | " autoselect: copy&paste using middleclick | ||
350 | set guioptions-=m | " remove menu | ||
351 | set guioptions-=e | " do not display tabs | ||
352 | set guioptions-=L | " do not show left scrollbar | ||
353 | set guioptions-=r | " do not show right scrollbar | ||
354 | set winaltkeys=menu | " behave like other windows: ALT-key can be used to open the menu (and cannot be :remaped) | ||
355 | set guifont=Dejavu\ Sans\ Mono\ for\ Powerline\ 12 | ||
356 | " set guifont=Droid\ Sans\ Mono\ for\ Powerline\ 12 | ||
357 | " set selectmode=mouse,key,cmd | " enters vim's select mode when pressing shift-left or shift-END | ||
358 | " set keymodel=startsel,stopsel | " makes shift-left, shift-right available for selecting text | ||
359 | endif | ||
360 | |||
361 | " NEOVIM_incompatible: | ||
362 | if !has('nvim') | " settings which have been removed from neovim | ||
363 | set ttymouse=xterm2 | ||
364 | set ttyscroll=100 | " improves speed for terminal vim, incomp. with nvim | ||
365 | set ttyfast | " improves speed for terminal vim (incomp. with nvim) | ||
366 | " set termguicolors | " When on, uses highlight-guifg and highlight-guibg attributes in the terminal (=24bit color) incomp. with nvim | ||
367 | endif | ||
368 | |||
369 | if has("autocmd") | ||
370 | set modeline | " set variables specific to a file, like indentation by adding a comment | ||
371 | " set default completion function in case YouCompleteMe cannot help | ||
372 | set omnifunc=syntaxcomplete#Complete | ||
373 | |||
374 | " automatically reload this file when it gets edited | ||
375 | if !exists("*OnConfigChange") | ||
376 | function OnConfigChange() | ||
377 | autocmd! |" Remove all vimrc autocommands | ||
378 | source $MYVIMRC | ||
379 | AirlineRefresh | ||
380 | endfunction | ||
381 | autocmd BufWritePost $MYVIMRC call OnConfigChange() | ||
382 | endif | ||
383 | |||
384 | augroup set_window_title " { | ||
385 | " autocmd BufWinEnter quickfix setl statusline=%t | ||
386 | " autocmd BufEnter * let &titlestring = hostname() . "[vim(" . expand("%:t") . ")]" | ||
387 | autocmd CursorHold * let &titlestring = "%t|".$USER."@".hostname().":%{expand(\"%:~:.:h\")}%=%y" | ||
388 | set title | ||
389 | " autocmd CursorHold * let &titlestring = "Vim (".airline#extensions#tagbar#currenttag().")" | ||
390 | |||
391 | " set window title for screen(3) | ||
392 | if &term == "screen" | ||
393 | set t_ts=k | ||
394 | set t_fs=\ | ||
395 | endif | ||
396 | if &term == "screen" || &term == "xterm" | ||
397 | set titlelen=40 | ||
398 | set title | ||
399 | endif | ||
400 | augroup END | ||
401 | |||
402 | " hitting K over a keyword shows a help in a buffer. | ||
403 | " Here we define the commands used to look those keywords up | ||
404 | " as per file type... | ||
405 | augroup filetype_specific | ||
406 | autocmd FileType python setlocal keywordprg=pydoc | ||
407 | autocmd FileType vim setlocal keywordprg=:help |. | ||
408 | autocmd FileType c,cpp setlocal equalprg=clang-format | ||
409 | autocmd FileType c,cpp setlocal breakat-=- | ||
410 | |||
411 | " keyboard mapping for xml alike languages | ||
412 | " Alt-Up : Move cursor up one tag | ||
413 | " Alt-Down: Move cursor down one tag | ||
414 | " leader-=: tidies currently selected tag and subtags and sorts attributes by name (alphabetically) | ||
415 | autocmd Filetype html,htmldjango,xml | ||
416 | \ :nnoremap | ||
417 | \ <M-Down> | ||
418 | \ :call search('^ *<', 'e')<CR>:nohlsearch<CR>| | ||
419 | \ :nnoremap | ||
420 | \ <M-Up> | ||
421 | \ :call search('^ *<', 'eb')<CR>:nohlsearch<CR>| | ||
422 | \ :nnoremap | ||
423 | \ <leader>= | ||
424 | \ vat:'<,'>!tidy -xml --wrap 0 --sort-attributes alpha 2>/dev/null<CR>vat= | ||
425 | augroup END | ||
426 | |||
427 | |||
428 | |||
429 | augroup ChangeIcon | ||
430 | "if filereadable("/usr/bin/xseticon") | ||
431 | "if filereadable("~/.vim/nvim.png") | ||
432 | " autocmd VimEnter * silent :execute "!xseticon -id $WINDOWID ~/.vim/nvim.png" | ||
433 | " autocmd VimLeave * silent :execute "!xseticon -id $WINDOWID /usr/share/icons/gnome/32x32/apps/xfce-terminal.png" | ||
434 | "endif | ||
435 | "endif | ||
436 | augroup END | ||
437 | |||
438 | if has('nvim') | ||
439 | autocmd BufEnter term://* set nobuflisted | ||
440 | else | ||
441 | augroup vimonly | ||
442 | autocmd VimLeave * call system("echo -n $'" . escape(getreg(), "'") . "' | xsel -ib") | ||
443 | augroup END | ||
444 | endif | ||
445 | |||
446 | |||
447 | augroup ToggleQuickFix | ||
448 | function! ToggleQuickFix() | ||
449 | if exists("g:qwindow") | ||
450 | lclose | ||
451 | unlet g:qwindow | ||
452 | else | ||
453 | try | ||
454 | lopen 10 | ||
455 | let g:qwindow = 1 | ||
456 | catch | ||
457 | echo "No Errors found!" | ||
458 | endtry | ||
459 | endif | ||
460 | endfunction | ||
461 | function! QFixToggle(forced) | ||
462 | if exists("g:qfix_win") && a:forced == 0 | ||
463 | cclose | ||
464 | unlet g:qfix_win | ||
465 | else | ||
466 | copen 10 | ||
467 | let g:qfix_win = bufnr("$") | ||
468 | endif | ||
469 | endfunction | ||
470 | |||
471 | nmap <script> <silent> <F3> :call ToggleQuickFix()<CR> | ||
472 | nmap <script> <silent> <F4> :call QFixToggle(0)<CR> | ||
473 | augroup END | ||
474 | |||
475 | |||
476 | augroup extra_whitespace " { | ||
477 | highlight ExtraWhitespace ctermbg=red guibg=red | ||
478 | autocmd BufEnter * syn match ExtraWhitespace /\s\+$/ | ||
479 | augroup END "} | ||
480 | |||
481 | augroup CurrentFileName | ||
482 | highlight CurrentFileName ctermbg=yellow guibg=yellow | ||
483 | |||
484 | " highlight the current files name inside the document... | ||
485 | let @g = ":exe ':match CurrentFileName /'.escape(expand('%:t'), '.').'/'" | ||
486 | " put the current files name after the cursor... | ||
487 | let @f = ":exe ':normal a'.expand('%:t')" | ||
488 | |||
489 | " autocmd BufEnter * @f | ||
490 | augroup END | ||
491 | |||
492 | if bufname('%') == '' | ||
493 | set bufhidden=wipe | ||
494 | endif | ||
495 | endif | ||
496 | |||
497 | |||
498 | " ====================================================================================================================== | ||
499 | " SHORTCUTS: custom shortcuts | ||
500 | inoremap <C-Space> <C-x><C-o> | ||
501 | "inoremap <C-@> <C-Space> | ||
502 | |||
503 | " Bind CTRL+Backspace to vims version (CTRL+W) in " <CR> insert mode (only works with gvim) | ||
504 | inoremap | ||
505 | \ <C-Backspace> | ||
506 | \ <C-W> | ||
507 | |||
508 | " INDENTATION: allows deindenting a selected block and keeps selection | ||
509 | vnoremap < <gv | ||
510 | vnoremap > >gv | ||
511 | |||
512 | " close current buffer with <leader>q... | ||
513 | nnoremap <leader>q :bp<bar>sp<bar>bn<bar>bd<CR>. | ||
514 | |||
515 | nnoremap <silent> <F5> :make<CR> | ||
516 | nnoremap <silent> <F6> :silent syntax sync fromstart<CR>:nohlsearch<CR>:silent match<CR> | ||
517 | nnoremap <leader>r :syntax sync fromstart | ||
518 | |||
519 | |||
520 | " INSERT_MODE_MAPPINGS: | ||
521 | " default copy&paste insert key binding (just in insert mode, so it doesn't conflict | ||
522 | " with visual block mode). | ||
523 | inoremap <C-V> <C-R>+ | ||
524 | inoremap <C-S> <C-O>:w<CR> | ||
525 | |||
526 | " NEOVIM_SPECIFIC: | ||
527 | if has('nvim') " only neovim... | ||
528 | " shortcut \t opens a terminal in a horizontal split | ||
529 | nnoremap <leader>t :new +terminal<CR> | ||
530 | endif | ||
531 | |||
532 | " ====================================================================================================================== | ||
533 | " Deprecated with this configuration, but still useful when deactivating some Plugins | ||
534 | |||
535 | " NETRW: obsolete with NERDTree | ||
536 | let g:netrw_alto = 0 | " open files on the right | ||
537 | let g:netrw_altv = 1 | " open files on the right | ||
538 | let g:netrw_banner = 0 | " display help messages? | ||
539 | let g:netrw_browse_split = 4 | " 4=open in previous window | ||
540 | let g:netrw_fastbrowse = 2 | " manually refresh direcory list (avoids display errors) | ||
541 | let g:netrw_hide = 1 | " show not-hidden files only | ||
542 | let g:netrw_keepdir = 0 | ||
543 | let g:netrw_list_hide = '^\..*' | " Explore mode: hide files starting with dot | ||
544 | let g:netrw_liststyle = 3 | " 3=tree | ||
545 | let g:netrw_preview = 0 | " | ||
546 | let g:netrw_winsize = 20 | " window size in percent | ||
547 | |||
548 | |||
549 | "set omnifunc=syntaxcomplete#Complete | ||
550 | " au BufNewFile,BufRead,BufEnter *.cpp,*.hpp set omnifunc=omni#cpp#complete#Main | ||
551 | " Enable omni completion. | ||
552 | " autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS | ||
553 | " autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags | ||
554 | " auto complete closing tag name when entering </-[space] | ||
555 | " autocmd Filetype html,markdown,xml iabbrev </ </<C-X><C-O> | ||
556 | " autocmd FileType python setlocal omnifunc=jedi#completions | ||
557 | " following autocommands are there to call neovim functions... | ||
558 | " autocmd FileType python setlocal omnifunc=pythoncomplete#Complete | ||
559 | " autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS | ||
560 | " autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags | ||
561 | " " Enable heavy omni completion. | ||
562 | " if !exists('g:neocomplete#sources#omni#input_patterns') | ||
563 | " let g:neocomplete#sources#omni#input_patterns = {} | ||
564 | " endif | ||
565 | " if filereadable(expand("~/.vimrc_background")) | ||
566 | " let base16colorspace=256 | ||
567 | " source ~/.vimrc_background | ||
568 | " endif | ||
569 | " set colorcolumn=80 | " show an indicator (different background in column 80) | ||
570 | " set title | ||
571 | " set t_ts=^[k | ||
572 | " set t_fs=^[\ | ||
573 | " auto BufEnter * :set title | let &titlestring = 'v:' . expand('%') | ||
574 | " auto VimLeave * :set t_ts=^[k^[\ | ||
575 | " | ||
576 | " ALTERNATIVE: | | ||
577 | " LightLine_and_MiniBufExplorer: =====================. | ||
578 | " Plug 'itchyny/lightline.vim' | ||
579 | " let g:lightline = { | ||
580 | " \ 'colorscheme': 'PaperColor', | ||
581 | " \ 'separator': { 'left': "\ue0b0", 'right': "\ue0b2" }, | ||
582 | " \ 'subseparator': { 'left': "\ue0b1", 'right': "\ue0b3" } | ||
583 | " \ } | ||