From 0c225499227c94b089b65fc0a9f5752e0d2b16f5 Mon Sep 17 00:00:00 2001 From: Charlie Root Date: Thu, 17 Aug 2017 00:00:42 +0200 Subject: restructured vimrc for faster loading, added menus --- vimrc-full | 959 ++++++++++++++++++++++++++++++++----------------------------- 1 file changed, 500 insertions(+), 459 deletions(-) diff --git a/vimrc-full b/vimrc-full index 5b12fd7..5e9f790 100644 --- a/vimrc-full +++ b/vimrc-full @@ -1,12 +1,18 @@ " vim: noai:ts=2:sw=2:sts=2 iskeyword+=\:,\!,\<,\>,\-,\& +"======================================================================================================================= +" GENERAL: +"======================================================================================================================= + set textwidth=120 | " better done with modeline set ts=4 sts=4 sw=4 expandtab | " better done with a modeline set redrawtime=1000 | " Timeout in milliseconds for redrawing the display / CTRL+L to retry -" scripts from the default vim installation, which do not get loaded by default, but are useful. -" silent :runtime macros/editexisting.vim -packadd! editexisting +if filereadable("/bin/bash") + set shell=/bin/bash | " many scripts rely on bash, but its path varies why it is commented out here +elseif filereadable("/usr/local/bin/bash") + set shell=/usr/local/bin/bash +endif if has("multi_byte") scriptencoding utf-8 | " tell vim that we are using utf-8 here @@ -30,6 +36,82 @@ if has("multi_byte") " set fillchars+=stlnc:\― | " end +if has('persistent_undo') + set undofile | " preserve undo history when closing and reopening buffers (see :help undo-persistenece) + + if isdirectory('/dev/shm') + set undodir=/dev/shm/ | " save undo file in memory. That is volatile, but fast and we have GIT for longer lasting undos + elseif isdirectory('/tmp/') + set undodir=/tmp/ + endif +endif + +" scripts from the default vim installation, which do not get loaded by default, but are useful. +if filereadable('macros/editexisting') + silent :runtime macros/editexisting.vim +endif + + +"======================================================================================================================= +if has('cscope') " compiled with cscope support? + " http://vim.wikia.com/wiki/Cscope + set cscopetag | " CTRL-] uses cscope first, then ctags + set cscopeverbose + + if has('quickfix') + set cscopequickfix=s+,c+,d+,i+,t+,e+ + endif + + if has('menu') + menu &CScope.add + \ :cscope add . + + menu &CScope.show + \ :cscope show + + menu &CScope.reset + \ :cscope reset + + menu &CScope.-Sep- + \ : + + menu &Cscope.find.C\ symbol + \ :cscope find s + + menu &Cscope.find.definition + \ :cscope find g + + menu &Cscope.find.functions\ called\ by\ this + \ :cscope find d + + menu &Cscope.find.functions\ calling\ this + \ :cscope find c + + menu &Cscope.find.text\ string + \ :cscope find t + + menu &Cscope.find.egrep\ pattern + \ :cscope find e + + menu &Cscope.find.this\ file + \ :cscope find f + + menu &Cscope.find.files\ including\ this\ file + \ :cscope find i + + menu &Cscope.find.places\ where\ this\ symbol\ is\ assigned\ a\ value + \ :cscope find a + endif + " cnoreabbrev csa cs add + " cnoreabbrev csf cs find + " cnoreabbrev csk cs kill + " cnoreabbrev csr cs reset + " cnoreabbrev css cs show + " cnoreabbrev csh cs help + let @c = ":cs find s " +endif + + " ======================================================================================================================= " SETTINGS: " ======================================================================================================================= @@ -96,430 +178,116 @@ set equalalways | " do not evenly size windows when opening new or set nocursorline | " turn visual cursor line off (improves performance) "======================================================================================================================= -if has('persistent_undo') - set undofile | " preserve undo history when closing and reopening buffers (see :help undo-persistenece) - if isdirectory('/dev/shm') - set undodir=/dev/shm/ | " save undo file in memory. That is volatile, but fast and we have GIT for longer lasting undos - elseif isdirectory('/tmp/') - set undodir=/tmp/ - endif -endif -" START: LOADING PLUGINS -" ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ -call plug#begin() -Plug 'tpope/vim-surround' | " plugin makes cs"' inside a line replace " with ' -Plug 'tpope/vim-fugitive' | " the most complete GIT integration plugin -Plug 'godlygeek/tabular' | " align code on a sign, like :Tab/= -Plug 'mhinz/vim-signify' | " uses the sign column to indicate added, modified and removed lines -let g:signify_vcs_list = [ 'git' ] | " use signify only with git (improves speed when loading buffers, see :h signify) -let g:signify_cursorhold_insert = 1 -let g:signify_cursorhold_normal = 1 -let g:signify_update_on_bufenter = 0 -let g:signify_update_on_focusgained = 1 +"======================================================================================================================= +" SPELL_CHECKING: +"======================================================================================================================= +let g:spellfile_URL='http://ftp.vim.org/vim/runtime/spell' +set nospell | " disable spell checker by default +set spelllang=en,de | " languages for the spell checker +set spellsuggest=10 | " how many words will z= suggest? +set thesaurus+=~/.vim/thesaurus/php.txt -" TESTING: | " plugins which I am currently trying... -" Plug 'rkitover/vimpager' -" found this command instead (use as PAGER): -" man -P 'nvim -R -u NORC -c":%!col -b" -c":set buftype=nowrite filetype=man" -' ls -" -" Plug 'Shougo/neocomplete.vim' | " alternative to YouCompleteMe in some cases -" Plug 'tpope/vim-characterize' | " normal mode: make ga show character names of Unicode chars (ga shows hex and dec values) +set dictionary=/usr/share/dict/cracklib-small +set complete+=k " make default completer respect the dictionary -" Colorschemes: -Plug 'chriskempson/base16-vim' | " not just one high quality color scheme (all named base16-*) -" Plug 'ryanoasis/vim-devicons' | " eye candy icons -" SCRATCH: | " Unobtrusive scratch window -Plug 'mtth/scratch.vim' -nnoremap :ScratchPreview -" BUFEXPLORER: | " a buffer to list all buffers has the advantage, that default /-searches work in there -Plug 'jlanzarotta/bufexplorer' -nnoremap :ToggleBufExplorer +if has('autocmd') + " autocmd VimEnter * let &t_EI .= "\[0 q" + " autocmd VimEnter * let &t_SI = "\]12;green\x7" + autocmd VimLeave * silent !echo -ne "\033]112\007" +endif -" NERDTree: replaces NetRW, as long as it has so many bugs -Plug 'scrooloose/nerdtree' | " -let NERDTreeIgnore = ['\.aux$'] -let NERDTreeCascadeSingleChildDir = 0 | " I don't get how one can use to create files in that included directory -let NERDTreeChDirMode = 0 -let NERDTreeHiddenFirst = 1 -let NERDTreeMinimalUI = 1 -let NERDTreeShowBookmarks = 1 | " show bookmarks by default (when opening for the first time) -let NERDTreeWinSize = 40 +" GUI_VERSION: +if has("gui_running") + set guicursor=a:block-blinkon100 + set browsedir=buffer + set toolbar+=text + set guiheadroom=0 + set guioptions+=eig + set guioptions-=T | " toolbar + set guioptions+=c | " use console dialogs instead of popups + set guioptions+=a | " autoselect: copy&paste using middleclick + set guioptions+=m | " remove menu + set guioptions-=e | " do not display tabs + set guioptions-=L | " do not show left scrollbar + set guioptions-=r | " do not show right scrollbar + set winaltkeys=menu | " behave like other windows: ALT-key can be used to open the menu (and cannot be :remaped) + " set guifont=Dejavu\ Sans\ Mono\ for\ Powerline\ 10 + " set guifont=Source\ Code\ Pro\ Semi-Bold\ 10 + " set guifont=Droid\ Sans\ Mono\ for\ Powerline\ 12 + set guifont=Dejavu\ Sans\ Mono\ For\ Powerline\ Semibold +" set selectmode=mouse,key,cmd | " enters vim's select mode when pressing shift-left or shift-END +" set keymodel=startsel,stopsel | " makes shift-left, shift-right available for selecting text +endif -" depending on if NERDTree has the focus: -nnoremap - \ - \ bufwinnr("%")==g:NERDTree.GetWinNum() ? ':NERDTreeClose' : ':NERDTreeFind' -nnoremap - \ - \ bufwinnr("%")==g:NERDTree.GetWinNum() ? '' : ':bn' -nnoremap - \ - \ bufwinnr("%")==g:NERDTree.GetWinNum() ? '' : ':bp' -" close NERDTree if it is the last remaining window (taken from the official documentation) -" autocmd bufenter * -" \ if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif -" +" NEOVIM_incompatible: +if !has('nvim') | " settings which have been removed from neovim + set ttymouse=xterm2 + set ttyscroll=100 | " improves speed for terminal vim, incomp. with nvim + set ttyfast | " improves speed for terminal vim (incomp. with nvim) + set nottybuiltin | " use external termcaps + " set termguicolors | " When on, uses highlight-guifg and highlight-guibg attributes in the terminal (=24bit color) incomp. with nvim + " + let g:loaded_ruby_provider = 1 " disable ruby support + let g:loaded_python_provider = 1 " disable pthon3 -" Additional: ========================================. -Plug 'sheerun/vim-polyglot' " better syntax highlighting/indentation for multiple languages -let g:javascript_conceal_function = "ƒ" -let g:javascript_conceal_null = "ø" -let g:javascript_conceal_this = "@" -let g:javascript_conceal_return = "⇚" -let g:javascript_conceal_undefined = "¿" -let g:javascript_conceal_NaN = "ℕ" -let g:javascript_conceal_prototype = "¶" -let g:javascript_conceal_static = "•" -let g:javascript_conceal_super = "Ω" -let g:javascript_conceal_arrow_function = "⇒" + if version >= 702 " clean up (see: http://vim.wikia.com/wiki/VimTip396) + autocmd BufWinLeave * call clearmatches() + endif +endif -Plug 'majutsushi/tagbar' " superseeds taglist-plus, which isn't maintained any more -let g:tagbar_autoclose = 0 -let g:tagbar_autofocus = 1 -let g:tagbar_autoshowtag = 0 -let g:tagbar_compact = 1 -let g:tagbar_indent = 0 -let g:tagbar_foldlevel = 99 -nnoremap l :TagbarToggle| " bind TagBar to Hotkey Ctrl+L -nnoremap :TagbarToggle| " also bind TagBar to Hotkey F9 +if has("autocmd") + set modeline | " set variables specific to a file, like indentation by adding a comment + " set default completion function in case YouCompleteMe cannot help + set omnifunc=syntaxcomplete#Complete + " automatically reload this file when it gets edited + if !exists("*OnConfigChange") + function OnConfigChange() + autocmd! |" Remove all vimrc autocommands + source $MYVIMRC + exec lightline#colorscheme() + exec lightline#update() + " AirlineRefresh + endfunction + autocmd BufWritePost $MYVIMRC call OnConfigChange() + endif -" AIRLINE: a fancy status line ========================================================================================= -set laststatus=2 | " required by AirLine, without status line does not appear until a window split -set background=light + augroup set_window_title " { + " autocmd BufWinEnter quickfix setl statusline=%t + " autocmd BufEnter * let &titlestring = hostname() . "[vim(" . expand("%:t") . ")]" + autocmd CursorHold * let &titlestring = "%t|".$USER."@".hostname().":%{expand(\"%:~:.:h\")}%=%y" + set title + " autocmd CursorHold * let &titlestring = "Vim (".airline#extensions#tagbar#currenttag().")" -Plug 'itchyny/lightline.vim' -Plug 'taohex/lightline-buffer' + " set window title for screen(3) + if &term == "screen" + set t_ts=k + set t_fs=\ + endif + if &term == "screen" || &term == "xterm" + set titlelen=40 + set title + endif + augroup END -" lightline-buffer ui settings -" replace these symbols with ascii characters if your environment does not support unicode -let g:lightline_buffer_logo = ' ' -let g:lightline_buffer_readonly_icon = '' -let g:lightline_buffer_modified_icon = '✭' -let g:lightline_buffer_git_icon = ' ' -let g:lightline_buffer_ellipsis_icon = '..' -let g:lightline_buffer_expand_left_icon = '◀ ' -let g:lightline_buffer_expand_right_icon = ' ▶' -let g:lightline_buffer_active_buffer_left_icon = '' -let g:lightline_buffer_active_buffer_right_icon = '' -let g:lightline_buffer_separator_icon = ' ' + " hitting K over a keyword shows a help in a buffer. + " Here we define the commands used to look those keywords up + " as per file type... + augroup filetype_specific + autocmd FileType python setlocal keywordprg=pydoc + autocmd FileType vim setlocal keywordprg=:help |. + autocmd FileType c,cpp setlocal equalprg=clang-format + autocmd FileType c,cpp setlocal breakat-=- + " autocmd FileType c,cpp setlocal iskeyword-=_ -" lightline-buffer function settings -let g:lightline_buffer_show_bufnr = 0 -let g:lightline_buffer_rotate = 0 -let g:lightline_buffer_fname_mod = ':t' -let g:lightline_buffer_excludes = ['vimfiler'] -let g:lightline_buffer_maxflen = 30 -let g:lightline_buffer_maxfextlen = 3 -let g:lightline_buffer_minflen = 16 -let g:lightline_buffer_minfextlen = 3 -let g:lightline_buffer_reservelen = 20 - -let g:lightline = { - \ 'colorscheme': 'Tomorrow_Night_Bright', - \ 'separator': { 'left': "\ue0b0", 'right': "\ue0b2" }, - \ 'subseparator': { 'left': "\ue0b1", 'right': "\ue0b3" }, - \ 'active': { - \ 'left': [ [ 'mode', 'paste', 'readonly' ], - \ [ 'gitbranch', 'absolutepath' ], - \ [ 'tagbar' ] ], - \ 'right': [ [ 'lineinfo', 'percent' ], - \ [ 'spell', 'fileencoding', 'fileformat', 'filetype' ] ], - \ }, - \ 'tabline': { - \ 'left': [ [ 'bufferinfo' ], [ 'bufferbefore', 'buffercurrent', 'bufferafter' ], ], - \ 'right': [ [ 'close' ] ], - \ }, - \ 'component': { - \ 'tagbar': '%{tagbar#currenttag("%s", "", "fs")}', - \ }, - \ 'component_expand': { - \ 'buffercurrent': 'lightline#buffer#buffercurrent2', - \ }, - \ 'component_type': { - \ 'buffercurrent': 'tabsel', - \ }, - \ 'component_function': { - \ 'bufferbefore': 'lightline#buffer#bufferbefore', - \ 'bufferafter': 'lightline#buffer#bufferafter', - \ 'bufferinfo': 'lightline#buffer#bufferinfo', - \ 'getcwd': 'getcwd', - \ 'gitbranch': 'fugitive#head' - \ }, - \ } - -" Autocompleter: ===================================== -if has("python") - " YouCompleteMe: ===================================================================================================== - " Plug 'Valloric/MatchTagAlways' " highlights the closing tag/brace/... - Plug 'Valloric/YouCompleteMe' - " Plug 'vim-scripts/dbext.vim' " dependency to allow db related completions - let g:ycm_server_python_interpreter = "python3" - let g:ycm_add_preview_to_completeopt = 1 " reuse existing preview window - let g:ycm_autoclose_preview_window_after_insertion = 1 - let g:ycm_collect_identifiers_from_tags_files = 0 " Let YCM read tags from Ctags file - let g:ycm_seed_identifiers_with_syntax = 1 " Completion for programming language's keyword - let g:ycm_complete_in_comments = 1 " Completion in comments - let g:ycm_complete_in_strings = 1 " Completion in string - let g:ycm_error_symbol = '✖' " insert this as an error symbol in the gutter bar - let g:ycm_min_num_of_chars_for_completion = 1 - let g:ycm_use_ultisnips_completer = 1 " Default 1, just ensure - let g:ycm_warning_symbol = '➔' " insert this as a warning symbol in the gutter bar - let g:ycm_confirm_extra_conf = 0 " security is overrated - let g:ycm_key_list_select_completion = [''] - let g:ycm_key_list_previous_completion = [''] - let g:ycm_global_ycm_extra_conf = '.ycm_extra_conf.py' - let g:ycm_semantic_triggers = { 'c': [ 're!.' ] } - let g:ycm_python_binary_path = 'python' " the python interpreter of choice (for code checking) - " let g:ycm_disable_for_files_larger_than_kb = 16384 " we have faaast computers, don't we? - - " disable -key for YCM so that it can be used with ultisnips - let g:ycm_key_list_select_completion=[] - let g:ycm_key_list_previous_completion=[] - - - " SYNTASTIC: ========================================================================================================= - Plug 'scrooloose/syntastic' - set statusline+=%#warningmsg# - set statusline+=%{SyntasticStatuslineFlag()} - let g:LatexBox_latexmk_preview_continuously = 1 - let g:LatexBox_viewer = "evince" - let g:syntastic_always_populate_loc_list = 1 - let g:syntastic_auto_loc_list = 0 - let g:syntastic_check_on_open = 1 - let g:syntastic_check_on_wq = 0 - " let g:syntastic_quiet_messages = {"type":"style"} - " - " E221: multiple spaces before Operator - let g:syntastic_python_flake8_args = '--max-complexity=10 --max-line-length=120 --exclude venv --doctests --exit-zero --ignore=E221' - " filter ( = do not display) style/formatting errors and warnings - let g:syntastic_error_symbol = '✖' - let g:syntastic_style_error_symbol = '✗' - let g:syntastic_warning_symbol = '➔' - let g:syntastic_style_warning_symbol = '≈' - - " ULTISNIPS: code snippet ============================================================================================== - Plug 'honza/vim-snippets' " dependency of ultisnips (see below) - Plug 'SirVer/ultisnips' " replaces loremipsum (and many more) - "let g:UltiSnipsExpandTrigger = ''| " Trigger configuration. Do not use if you use https://github.com/Valloric/YouCompleteMe. - "let g:UltiSnipsJumpForwardTrigger = ''| " \ - "let g:UltiSnipsJumpBackwardTrigger = ''| " \ - "let g:UltiSnipsListSnippets = ''| " YouCompleteMe includes those, so this isn't necessary - "let g:UltiSnipsExpandTrigger = ''| " Trigger configuration. Do not use if you use https://github.com/Valloric/YouCompleteMe. - "let g:UltiSnipsJumpForwardTrigger = ''| " \ - "let g:UltiSnipsJumpBackwardTrigger = ''| " \ - "let g:UltiSnipsListSnippets = ''| " YouCompleteMe includes those, so this isn't necessary - - " Plug 'rhysd/vim-clang-format' - Plug 'kana/vim-operator-user' " dependency, which allows overriding the = operator for indentation - autocmd FileType c,cpp,objc map = :pyf /usr/share/clang/clang-format.py - " let g:clang_format#detect_style_file = 1 - " autocmd FileType c,cpp,objc map = (operator-clang-format) - - " JEDI: ============================================================================================================== - Plug 'davidhalter/jedi-vim' " jedi gets used to display python function signatures - let g:jedi#completions_enabled = 0 " we do not need completions, because we have YouCompleteMe - let g:jedi#show_call_signatures = 1 " which sadly does not support signatures like jedi - let g:jedi#show_call_signatures_delay = 0 - let g:jedi#auto_vim_configure = 0 - let g:pymode_rope = 0 " https://github.com/davidhalter/jedi-vim/issues/163 - " autocmd FileType python jedi.preload_module('os', 'sys', 'math') - " let g:pymode_options_max_line_length = 120 - " let g:syntastic_python_flake8_args='--ignore=F821,E302,E501,E241,E301' -endif - - -call plug#end() | " all plugins are getting loaded on this line, don't remove! -" ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ -" END: LOADING PLUGINS - - -" COLORSCHEME: -" uses the default terminal background color as background (allows transparency) -function! ExtendColorTheme() - " let g:colors_name="" - " set background=light - filetype on - filetype plugin on - filetype indent on - - syntax on | " enable syntax highlighting - syntax sync minlines=60 | " how many preceding lines will be parsed? (has performance impact) - " highlight Normal ctermbg=NONE ctermfg=black - - highlight! CursorLineNr cterm=inverse | " ctermbg=black ctermfg=NONE - highlight! Pmenu ctermbg=LightYellow ctermfg=blue - highlight! PmenuSel ctermbg=blue ctermfg=LightYellow cterm=bold - - highlight! link PmenuSbar Pmenu - highlight! PmenuThumb cterm=inverse - highlight! MoreMsg cterm=inverse - highlight! link Folded LineNr - highlight! Cursor guibg=#729fcf ctermbg=yellow - highlight! link VertSplit LineNr - highlight! SpellBad ctermbg=none - highlight! SpecialKey ctermfg=19 - highlight! WhiteSpace ctermfg=19 - - highlight! link TabLine LineNr - highlight! TabLineSel ctermbg=blue ctermfg=black - highlight! link TabLineFill LineNr - highlight! Search ctermbg=12 ctermfg=0 -endfunction -autocmd ColorScheme * call ExtendColorTheme() - - -if filereadable(expand("~/.config/base16-shell/colortest")) - let g:base16_shell_path="~/.config/base16-shell/scripts" -endif - -let base16colorspace=256 -if filereadable(expand("~/.vimrc_background")) - source ~/.vimrc_background -else - colorscheme base16-phd -endif - - - -"======================================================================================================================= -" GENERAL: -"======================================================================================================================= - -if filereadable("/bin/bash") - set shell=/bin/bash | " many scripts rely on bash, but its path varies why it is commented out here -elseif filereadable("/usr/local/bin/bash") - set shell=/usr/local/bin/bash -endif - - -"======================================================================================================================= -" SPELL_CHECKING: -"======================================================================================================================= -let g:spellfile_URL='http://ftp.vim.org/vim/runtime/spell' -set nospell | " disable spell checker by default -set spelllang=en,de | " languages for the spell checker -set spellsuggest=10 | " how many words will z= suggest? -set thesaurus+=/home/max/.vim/thesaurus/php.txt - -set dictionary=/usr/share/dict/cracklib-small -set complete+=k " make default completer respect the dictionary - - - -if has('autocmd') - " autocmd VimEnter * let &t_EI .= "\[0 q" - " autocmd VimEnter * let &t_SI = "\]12;green\x7" - autocmd VimLeave * silent !echo -ne "\033]112\007" -endif - -"======================================================================================================================= -if has('cscope') " compiled with cscope support? - " http://vim.wikia.com/wiki/Cscope - set cscopetag | " CTRL-] uses cscope first, then ctags - set cscopeverbose - - if has('quickfix') - set cscopequickfix=s+,c+,d+,i+,t+,e+ - endif - - " cnoreabbrev csa cs add - " cnoreabbrev csf cs find - " cnoreabbrev csk cs kill - " cnoreabbrev csr cs reset - " cnoreabbrev css cs show - " cnoreabbrev csh cs help - let @c = ":cs find s " -endif - -" GUI_VERSION: -if has("gui_running") - set guicursor=a:block-blinkon100 - set browsedir=buffer - set toolbar+=text - set guiheadroom=0 - set guioptions+=eig - set guioptions-=T | " toolbar - set guioptions+=c | " use console dialogs instead of popups - set guioptions+=a | " autoselect: copy&paste using middleclick - set guioptions+=m | " remove menu - set guioptions-=e | " do not display tabs - set guioptions-=L | " do not show left scrollbar - set guioptions-=r | " do not show right scrollbar - set winaltkeys=menu | " behave like other windows: ALT-key can be used to open the menu (and cannot be :remaped) - " set guifont=Dejavu\ Sans\ Mono\ for\ Powerline\ 10 - " set guifont=Source\ Code\ Pro\ Semi-Bold\ 10 - " set guifont=Droid\ Sans\ Mono\ for\ Powerline\ 12 - set guifont=Dejavu\ Sans\ Mono\ For\ Powerline\ Semibold -" set selectmode=mouse,key,cmd | " enters vim's select mode when pressing shift-left or shift-END -" set keymodel=startsel,stopsel | " makes shift-left, shift-right available for selecting text -endif - -" NEOVIM_incompatible: -if !has('nvim') | " settings which have been removed from neovim - set ttymouse=xterm2 - set ttyscroll=100 | " improves speed for terminal vim, incomp. with nvim - set ttyfast | " improves speed for terminal vim (incomp. with nvim) - set nottybuiltin | " use external termcaps - " set termguicolors | " When on, uses highlight-guifg and highlight-guibg attributes in the terminal (=24bit color) incomp. with nvim - " - let g:loaded_ruby_provider = 1 " disable ruby support - let g:loaded_python_provider = 1 " disable pthon3 -endif - -if has("autocmd") - set modeline | " set variables specific to a file, like indentation by adding a comment - " set default completion function in case YouCompleteMe cannot help - set omnifunc=syntaxcomplete#Complete - - " automatically reload this file when it gets edited - if !exists("*OnConfigChange") - function OnConfigChange() - autocmd! |" Remove all vimrc autocommands - source $MYVIMRC - exec lightline#colorscheme() - exec lightline#update() - " AirlineRefresh - endfunction - autocmd BufWritePost $MYVIMRC call OnConfigChange() - endif - - augroup set_window_title " { - " autocmd BufWinEnter quickfix setl statusline=%t - " autocmd BufEnter * let &titlestring = hostname() . "[vim(" . expand("%:t") . ")]" - autocmd CursorHold * let &titlestring = "%t|".$USER."@".hostname().":%{expand(\"%:~:.:h\")}%=%y" - set title - " autocmd CursorHold * let &titlestring = "Vim (".airline#extensions#tagbar#currenttag().")" - - " set window title for screen(3) - if &term == "screen" - set t_ts=k - set t_fs=\ - endif - if &term == "screen" || &term == "xterm" - set titlelen=40 - set title - endif - augroup END - - " hitting K over a keyword shows a help in a buffer. - " Here we define the commands used to look those keywords up - " as per file type... - augroup filetype_specific - autocmd FileType python setlocal keywordprg=pydoc - autocmd FileType vim setlocal keywordprg=:help |. - autocmd FileType c,cpp setlocal equalprg=clang-format - autocmd FileType c,cpp setlocal breakat-=- - " autocmd FileType c,cpp setlocal iskeyword-=_ - - " the following helps to make file=/etc/something work with gf, but disallows filenames with an equal sign in them - autocmd FileType conf setlocal isfname-== + " the following helps to make file=/etc/something work with gf, but disallows filenames with an equal sign in them + autocmd FileType conf setlocal isfname-== " keyboard mapping for xml alike languages " Alt-Up : Move cursor up one tag @@ -642,11 +410,6 @@ if has("autocmd") menu &Verify.Highlight\ current\ file\ name \ :execute ':match ColorColumn /'.escape(expand('%:t'), '.').'/' - - - menu &CScope.add - \ :cscope add . - menu &Window.-Sep- : menu &Window.Quickfix\ List @@ -666,64 +429,297 @@ if has("autocmd") - " exec current line as a command, insert output of command (from: https://youtu.be/MquaityA1SM?t=35m45s) - nnoremap Q !!$SHELL + " exec current line as a command, insert output of command (from: https://youtu.be/MquaityA1SM?t=35m45s) + nnoremap Q !!$SHELL + + " autocmd BufEnter * @f + augroup END + + " autocmd VimEnter * set nobuflisted +endif + + +" ====================================================================================================================== +" SHORTCUTS: custom shortcuts +" inoremap +" inoremap + +" Bind CTRL+Backspace to vims version (CTRL+W) in " insert mode (only works with gvim) +inoremap + \ + \ + +" INDENTATION: allows deindenting a selected block and keeps selection +vnoremap < >gv + +" make shift-home select to the beginning of the line +nnoremap v^ +nnoremap v$ + +nnoremap vj +vnoremap j +nnoremap vk +vnoremap k + + +" close current buffer with q... +nnoremap q :bpspbnbd. + +nnoremap :make +nnoremap :silent syntax sync fromstart:nohlsearch:silent match:silent 2match:silent 3match +nnoremap r :syntax sync fromstart + + +" INSERT_MODE_MAPPINGS: +" default copy&paste insert key binding (just in insert mode, so it doesn't conflict +" with visual block mode)- would have been nice, but collides with c-w for digraphs +" inoremap + +" +inoremap :w + +" NEOVIM_SPECIFIC: +if has('nvim') " only neovim... + " shortcut \t opens a terminal in a horizontal split + nnoremap t :new +terminal +endif + + + +" START: LOADING PLUGINS +" ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ +call plug#begin() + +Plug 'tpope/vim-surround' | " plugin makes cs"' inside a line replace " with ' +Plug 'tpope/vim-fugitive' | " the most complete GIT integration plugin +Plug 'godlygeek/tabular' | " align code on a sign, like :Tab/= +Plug 'mhinz/vim-signify' | " uses the sign column to indicate added, modified and removed lines +let g:signify_vcs_list = [ 'git' ] | " use signify only with git (improves speed when loading buffers, see :h signify) +let g:signify_cursorhold_insert = 1 +let g:signify_cursorhold_normal = 1 +let g:signify_update_on_bufenter = 0 +let g:signify_update_on_focusgained = 1 + +" TESTING: | " plugins which I am currently trying... +" Plug 'rkitover/vimpager' +" found this command instead (use as PAGER): +" man -P 'nvim -R -u NORC -c":%!col -b" -c":set buftype=nowrite filetype=man" -' ls +" +" Plug 'Shougo/neocomplete.vim' | " alternative to YouCompleteMe in some cases +" Plug 'tpope/vim-characterize' | " normal mode: make ga show character names of Unicode chars (ga shows hex and dec values) + +" Colorschemes: +Plug 'chriskempson/base16-vim' | " not just one high quality color scheme (all named base16-*) +" Plug 'ryanoasis/vim-devicons' | " eye candy icons + +" SCRATCH: | " Unobtrusive scratch window +Plug 'mtth/scratch.vim' +nnoremap :ScratchPreview + +" BUFEXPLORER: | " a buffer to list all buffers has the advantage, that default /-searches work in there +Plug 'jlanzarotta/bufexplorer' +nnoremap :ToggleBufExplorer + +" NERDTree: replaces NetRW, as long as it has so many bugs +Plug 'scrooloose/nerdtree' | " +let NERDTreeIgnore = ['\.aux$'] +let NERDTreeCascadeSingleChildDir = 0 | " I don't get how one can use to create files in that included directory +let NERDTreeChDirMode = 0 +let NERDTreeHiddenFirst = 1 +let NERDTreeMinimalUI = 1 +let NERDTreeShowBookmarks = 1 | " show bookmarks by default (when opening for the first time) +let NERDTreeWinSize = 40 + + +" depending on if NERDTree has the focus: +nnoremap + \ + \ bufwinnr("%")==g:NERDTree.GetWinNum() ? ':NERDTreeClose' : ':NERDTreeFind' +nnoremap + \ + \ bufwinnr("%")==g:NERDTree.GetWinNum() ? '' : ':bn' +nnoremap + \ + \ bufwinnr("%")==g:NERDTree.GetWinNum() ? '' : ':bp' +" close NERDTree if it is the last remaining window (taken from the official documentation) +" autocmd bufenter * +" \ if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif +" + +" Additional: ========================================. +Plug 'sheerun/vim-polyglot' " better syntax highlighting/indentation for multiple languages +let g:javascript_conceal_function = "ƒ" +let g:javascript_conceal_null = "ø" +let g:javascript_conceal_this = "@" +let g:javascript_conceal_return = "⇚" +let g:javascript_conceal_undefined = "¿" +let g:javascript_conceal_NaN = "ℕ" +let g:javascript_conceal_prototype = "¶" +let g:javascript_conceal_static = "•" +let g:javascript_conceal_super = "Ω" +let g:javascript_conceal_arrow_function = "⇒" - " autocmd BufEnter * @f - augroup END +Plug 'majutsushi/tagbar' " superseeds taglist-plus, which isn't maintained any more +let g:tagbar_autoclose = 0 +let g:tagbar_autofocus = 1 +let g:tagbar_autoshowtag = 0 +let g:tagbar_compact = 1 +let g:tagbar_indent = 0 +let g:tagbar_foldlevel = 99 +nnoremap l :TagbarToggle| " bind TagBar to Hotkey Ctrl+L +nnoremap :TagbarToggle| " also bind TagBar to Hotkey F9 - " autocmd VimEnter * set nobuflisted -endif +" AIRLINE: a fancy status line ========================================================================================= +set laststatus=2 | " required by AirLine, without status line does not appear until a window split +set background=light -" ====================================================================================================================== -" SHORTCUTS: custom shortcuts -" inoremap -" inoremap +Plug 'itchyny/lightline.vim' +Plug 'taohex/lightline-buffer' -" Bind CTRL+Backspace to vims version (CTRL+W) in " insert mode (only works with gvim) -inoremap - \ - \ +" lightline-buffer ui settings +" replace these symbols with ascii characters if your environment does not support unicode +let g:lightline_buffer_logo = ' ' +let g:lightline_buffer_readonly_icon = '' +let g:lightline_buffer_modified_icon = '✭' +let g:lightline_buffer_git_icon = ' ' +let g:lightline_buffer_ellipsis_icon = '..' +let g:lightline_buffer_expand_left_icon = '◀ ' +let g:lightline_buffer_expand_right_icon = ' ▶' +let g:lightline_buffer_active_buffer_left_icon = '' +let g:lightline_buffer_active_buffer_right_icon = '' +let g:lightline_buffer_separator_icon = ' ' -" INDENTATION: allows deindenting a selected block and keeps selection -vnoremap < >gv +" lightline-buffer function settings +let g:lightline_buffer_show_bufnr = 0 +let g:lightline_buffer_rotate = 0 +let g:lightline_buffer_fname_mod = ':t' +let g:lightline_buffer_excludes = ['vimfiler'] +let g:lightline_buffer_maxflen = 30 +let g:lightline_buffer_maxfextlen = 3 +let g:lightline_buffer_minflen = 16 +let g:lightline_buffer_minfextlen = 3 +let g:lightline_buffer_reservelen = 20 -" make shift-home select to the beginning of the line -nnoremap v^ -nnoremap v$ +let g:lightline = { + \ 'colorscheme': 'Tomorrow_Night_Bright', + \ 'separator': { 'left': "\ue0b0", 'right': "\ue0b2" }, + \ 'subseparator': { 'left': "\ue0b1", 'right': "\ue0b3" }, + \ 'active': { + \ 'left': [ [ 'mode', 'paste', 'readonly' ], + \ [ 'gitbranch', 'absolutepath' ], + \ [ 'tagbar' ] ], + \ 'right': [ [ 'lineinfo', 'percent' ], + \ [ 'spell', 'fileencoding', 'fileformat', 'filetype' ] ], + \ }, + \ 'tabline': { + \ 'left': [ [ 'bufferinfo' ], [ 'bufferbefore', 'buffercurrent', 'bufferafter' ], ], + \ 'right': [ [ 'close' ] ], + \ }, + \ 'component': { + \ 'tagbar': '%{tagbar#currenttag("%s", "", "fs")}', + \ }, + \ 'component_expand': { + \ 'buffercurrent': 'lightline#buffer#buffercurrent2', + \ }, + \ 'component_type': { + \ 'buffercurrent': 'tabsel', + \ }, + \ 'component_function': { + \ 'bufferbefore': 'lightline#buffer#bufferbefore', + \ 'bufferafter': 'lightline#buffer#bufferafter', + \ 'bufferinfo': 'lightline#buffer#bufferinfo', + \ 'getcwd': 'getcwd', + \ 'gitbranch': 'fugitive#head' + \ }, + \ } -nnoremap vj -vnoremap j -nnoremap vk -vnoremap k +" Autocompleter: ===================================== +if has("python") + " YouCompleteMe: ===================================================================================================== + " Plug 'Valloric/MatchTagAlways' " highlights the closing tag/brace/... + Plug 'Valloric/YouCompleteMe' + " Plug 'vim-scripts/dbext.vim' " dependency to allow db related completions + let g:ycm_server_python_interpreter = "python3" + let g:ycm_add_preview_to_completeopt = 1 " reuse existing preview window + let g:ycm_autoclose_preview_window_after_insertion = 1 + let g:ycm_collect_identifiers_from_tags_files = 0 " Let YCM read tags from Ctags file + let g:ycm_seed_identifiers_with_syntax = 1 " Completion for programming language's keyword + let g:ycm_complete_in_comments = 1 " Completion in comments + let g:ycm_complete_in_strings = 1 " Completion in string + let g:ycm_error_symbol = '✖' " insert this as an error symbol in the gutter bar + let g:ycm_min_num_of_chars_for_completion = 1 + let g:ycm_use_ultisnips_completer = 1 " Default 1, just ensure + let g:ycm_warning_symbol = '➔' " insert this as a warning symbol in the gutter bar + let g:ycm_confirm_extra_conf = 0 " security is overrated + let g:ycm_key_list_select_completion = [''] + let g:ycm_key_list_previous_completion = [''] + let g:ycm_global_ycm_extra_conf = '.ycm_extra_conf.py' + let g:ycm_semantic_triggers = { 'c': [ 're!.' ] } + let g:ycm_python_binary_path = 'python' " the python interpreter of choice (for code checking) + " let g:ycm_disable_for_files_larger_than_kb = 16384 " we have faaast computers, don't we? + " disable -key for YCM so that it can be used with ultisnips + let g:ycm_key_list_select_completion=[] + let g:ycm_key_list_previous_completion=[] -" close current buffer with q... -nnoremap q :bpspbnbd. -nnoremap :make -nnoremap :silent syntax sync fromstart:nohlsearch:silent match:silent 2match:silent 3match -nnoremap r :syntax sync fromstart + " SYNTASTIC: ========================================================================================================= + Plug 'scrooloose/syntastic' + set statusline+=%#warningmsg# + set statusline+=%{SyntasticStatuslineFlag()} + let g:LatexBox_latexmk_preview_continuously = 1 + let g:LatexBox_viewer = "evince" + let g:syntastic_always_populate_loc_list = 1 + let g:syntastic_auto_loc_list = 0 + let g:syntastic_check_on_open = 1 + let g:syntastic_check_on_wq = 0 + " let g:syntastic_quiet_messages = {"type":"style"} + " + " E221: multiple spaces before Operator + let g:syntastic_python_flake8_args = '--max-complexity=10 --max-line-length=120 --exclude venv --doctests --exit-zero --ignore=E221' + " filter ( = do not display) style/formatting errors and warnings + let g:syntastic_error_symbol = '✖' + let g:syntastic_style_error_symbol = '✗' + let g:syntastic_warning_symbol = '➔' + let g:syntastic_style_warning_symbol = '≈' + " ULTISNIPS: code snippet ============================================================================================== + Plug 'honza/vim-snippets' " dependency of ultisnips (see below) + Plug 'SirVer/ultisnips' " replaces loremipsum (and many more) + "let g:UltiSnipsExpandTrigger = ''| " Trigger configuration. Do not use if you use https://github.com/Valloric/YouCompleteMe. + "let g:UltiSnipsJumpForwardTrigger = ''| " \ + "let g:UltiSnipsJumpBackwardTrigger = ''| " \ + "let g:UltiSnipsListSnippets = ''| " YouCompleteMe includes those, so this isn't necessary + "let g:UltiSnipsExpandTrigger = ''| " Trigger configuration. Do not use if you use https://github.com/Valloric/YouCompleteMe. + "let g:UltiSnipsJumpForwardTrigger = ''| " \ + "let g:UltiSnipsJumpBackwardTrigger = ''| " \ + "let g:UltiSnipsListSnippets = ''| " YouCompleteMe includes those, so this isn't necessary -" INSERT_MODE_MAPPINGS: -" default copy&paste insert key binding (just in insert mode, so it doesn't conflict -" with visual block mode)- would have been nice, but collides with c-w for digraphs -" inoremap + -" -inoremap :w + " Plug 'rhysd/vim-clang-format' + Plug 'kana/vim-operator-user' " dependency, which allows overriding the = operator for indentation + autocmd FileType c,cpp,objc map = :pyf /usr/share/clang/clang-format.py + " let g:clang_format#detect_style_file = 1 + " autocmd FileType c,cpp,objc map = (operator-clang-format) -" NEOVIM_SPECIFIC: -if has('nvim') " only neovim... - " shortcut \t opens a terminal in a horizontal split - nnoremap t :new +terminal + " JEDI: ============================================================================================================== + Plug 'davidhalter/jedi-vim' " jedi gets used to display python function signatures + let g:jedi#completions_enabled = 0 " we do not need completions, because we have YouCompleteMe + let g:jedi#show_call_signatures = 1 " which sadly does not support signatures like jedi + let g:jedi#show_call_signatures_delay = 0 + let g:jedi#auto_vim_configure = 0 + let g:pymode_rope = 0 " https://github.com/davidhalter/jedi-vim/issues/163 + " autocmd FileType python jedi.preload_module('os', 'sys', 'math') + " let g:pymode_options_max_line_length = 120 + " let g:syntastic_python_flake8_args='--ignore=F821,E302,E501,E241,E301' endif +call plug#end() | " all plugins are getting loaded on this line, don't remove! +" ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ +" END: LOADING PLUGINS " ====================================================================================================================== -" Deprecated with this configuration, but still useful when deactivating some Plugins +" Deprecated with this configuration, but still useful when deactivating some Plugins " NETRW: obsolete with NERDTree let g:netrw_alto = 0 | " open files on the right let g:netrw_altv = 1 | " open files on the right @@ -737,7 +733,55 @@ let g:netrw_liststyle = 3 | " 3=tree let g:netrw_preview = 0 | " let g:netrw_winsize = 20 | " window size in percent +" ====================================================================================================================== +" COLORSCHEME: +" uses the default terminal background color as background (allows transparency) +function! ExtendColorTheme() + " let g:colors_name="" + " set background=light + filetype on + filetype plugin on + filetype indent on + + syntax on | " enable syntax highlighting + syntax sync minlines=60 | " how many preceding lines will be parsed? (has performance impact) + " highlight Normal ctermbg=NONE ctermfg=black + + highlight! CursorLineNr cterm=inverse | " ctermbg=black ctermfg=NONE + highlight! Pmenu ctermbg=LightYellow ctermfg=blue + highlight! PmenuSel ctermbg=blue ctermfg=LightYellow cterm=bold + + highlight! link PmenuSbar Pmenu + highlight! PmenuThumb cterm=inverse + highlight! MoreMsg cterm=inverse + highlight! link Folded LineNr + highlight! Cursor guibg=#729fcf ctermbg=yellow + highlight! link VertSplit LineNr + highlight! SpellBad ctermbg=none + highlight! SpecialKey ctermfg=19 + highlight! WhiteSpace ctermfg=19 + + highlight! link TabLine LineNr + highlight! TabLineSel ctermbg=blue ctermfg=black + highlight! link TabLineFill LineNr + highlight! Search ctermbg=12 ctermfg=0 +endfunction +autocmd! ColorScheme * call ExtendColorTheme() + +if filereadable(expand("~/.config/base16-shell/colortest")) + let g:base16_shell_path="~/.config/base16-shell/scripts" +endif + +let base16colorspace=256 +if filereadable(expand("~/.vimrc_background")) + source ~/.vimrc_background +else + colorscheme base16-phd +endif + + +" ====================================================================================================================== highlight WordBold ctermbg=LightYellow ctermfg=black cterm=bold gui=bold guibg=LightYellow guifg=black let w:m1 = 0 function! HighlightWordUnderCursor() @@ -751,11 +795,7 @@ function! HighlightWordUnderCursor() silent! call matchadd('WordBold', '\<'.l:currentword.'\>', -1, w:m1) endif endfunction - autocmd! CursorHold,CursorHoldI * call HighlightWordUnderCursor() -if version >= 702 " clean up (see: http://vim.wikia.com/wiki/VimTip396) - autocmd BufWinLeave * call clearmatches() -endif " avoids openin an empty buffer when restoring bufferlist from viminfo... @@ -774,4 +814,5 @@ endif " autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS " autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags " +" " set termguicolors -- cgit v1.2.3