From 87271db105e429a402b8934259b2390d55ac7481 Mon Sep 17 00:00:00 2001 From: Max Christian Pohle Date: Tue, 18 Oct 2016 13:54:12 +0200 Subject: opens, focusses & closes NERDTree Additionally reordered many settings to make the file more readable. --- doc/shortcuts.txt | 1 + vimrc | 123 ++++++++++++++++++++++++++++++++++-------------------- 2 files changed, 78 insertions(+), 46 deletions(-) diff --git a/doc/shortcuts.txt b/doc/shortcuts.txt index 540f086..daf9003 100644 --- a/doc/shortcuts.txt +++ b/doc/shortcuts.txt @@ -9,6 +9,7 @@ gf = open file under cursor gf = open file under cursor in a tab ] = jump to the tag under the cursor in a new window = jump back from where that ^ brought you +K = keyword lookup for the word under the cursor (see :help kp) diff --git a/vimrc b/vimrc index 2af99e3..f9569e3 100644 --- a/vimrc +++ b/vimrc @@ -5,8 +5,6 @@ Plug 'tpope/vim-sensible' | " a sane and modern defa Plug 'tpope/vim-surround' | " plugin makes cs"' inside a line replace " with ' Plug 'tpope/vim-fugitive' | " the most complete GIT integration plugin Plug 'mhinz/vim-signify' | " show changes in the clutter bar -" Plug 'tpope/vim-characterize' | " normal mode: make ga show character names of Unicode chars (ga shows hex and dec values) -" Plug 'tpope/vim-repeat' | " lets . (dot) repeat plugin macros as well, specifically vim-surround " Colorschemes: ======================================. @@ -16,10 +14,26 @@ map q :bpspbnbd. " NERDTree: ==========================================. Plug 'scrooloose/nerdtree' | " replace NetRW, which is kind of buggy -map :NERDTreeToggle set winwidth=30 " keep NERDTreeWindow at least this size set winminwidth=30 " (and all other windows, so TODO: watch out) +" open or focus the NERDTree with this key binding and close it if it is the active buffer... +nnoremap + \ + \ !exists("b:NERDTree") ? ':NERDTreeFocus' : ':NERDTreeClose' + +" 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 + +" if NERDTree has the focus, pressing should jump to the next window, but if the file +" buffer is selected should select the next buffer (:bn). That is archived by :h map-expr +nnoremap + \ + \ bufname("%")=='NERD_tree_1' ? '' : ':bn' +nnoremap + \ + \ bufname("%")=='NERD_tree_1' ? '' : ':bp' " AIRLINE: ===========================================. Plug 'vim-airline/vim-airline' | " beautification of the mode line @@ -93,20 +107,19 @@ let g:pymode_rope = 0 " https://github.com/david " let g:pymode_options_max_line_length = 120 " let g:syntastic_python_flake8_args='--ignore=F821,E302,E501,E241,E301' - +Plug 'honza/vim-snippets' " dependency of ultisnips (see below) Plug 'SirVer/ultisnips' " replaces loremipsum (and many more) -Plug 'honza/vim-snippets' " dependency of ultisnips -" Trigger configuration. Do not use if you use https://github.com/Valloric/YouCompleteMe. -"" Ultisnips -let g:UltiSnipsExpandTrigger="" -let g:UltiSnipsListSnippets="" +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:UltiSnipsEditSplit = 'vertical' -" If you want :UltiSnipsEdit to split your window. -let g:UltiSnipsEditSplit="vertical" " Disabled ===========================================. " Plug 'Shougo/neocomplete.vim' | " alternative to YouCompleteMe in some cases -" Plug 'Shougo/vimproc.vim' | " dependency for other Shougo plugins +" Plug 'tpope/vim-characterize' | " normal mode: make ga show character names of Unicode chars (ga shows hex and dec values) +" Plug 'tpope/vim-repeat' | " lets . (dot) repeat plugin macros as well, specifically vim-surround call plug#end() | " all plugins are getting loaded on this line, don't remove! @@ -124,7 +137,6 @@ colorscheme base16-phd " colorscheme base16-summerfruit-dark " colorscheme base16-tommorow " colorscheme base16-default-dark -" colorscheme vividchalk | " finally set which colorscheme to use " colorscheme customizations ========================= @@ -137,60 +149,69 @@ inoremap "inoremap vnoremap < >gv| " allows indenting a selected block and keeps selection -" if NERDTree has the focus, pressing should jump to the next window, but if the file -" buffer is selected should select the next buffer (:bn). That is archived by :h map-expr -nnoremap bufname("%")=='NERD_tree_1' ? '' : ':bn' -nnoremap bufname("%")=='NERD_tree_1' ? '' : ':bp' -inoremap | " Bind CTRL+Backspace to vims version (CTRL+W) in insert mode + +" Bind CTRL+Backspace to vims version (CTRL+W) in " insert mode (only works with gvim) +inoremap + \ + \ + " settings ============================================. " set shell=/bin/bash | " many scripts rely on bash, but its path varies why it is commented out here -set mouse=a | " also supported by vim, should be default -set noshowmode | " because we are using some powerline derivat -set hidden | " allows switiching buffers even if the current buffer contains changes (displays +) +" 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 +set breakindent | " Every wrapped line will continue visually indented +set clipboard=unnamedplus | " makes copy and paste work (autoselectplus might work as well) +set complete+=d | " scan current and included files for defined name or macro +set complete+=i | " scan current and included files for completions +set concealcursor=nc | " limits the display of concealed text to normal and command mode +set conceallevel=2 | " replace escaped chars by their utf-8 representation (useful for LaTeX) set confirm | " asks 'do you want to save?' -set t_Co=256 | " required on some ssh sessions -set ts=2 sts=2 sw=2 expandtab | " indentation which i like (abbr: tabstop, softtabstop, shiftwidth) -set scrolljump=5 | " how many lines get scrolled into view when cursor reaches the screens edge set encoding=utf-8 | " set up vim's cosole encoding (not file encoding, for which there is fileencoding=) +set hidden | " allows switiching buffers even if the current buffer contains changes (displays +) +set hlsearch | " highlights all search matches (not as performant!) set ignorecase smartcase | " search with ignorecase by default, but use case sensitive search when one captical char is contained -set ttimeoutlen=10 | " set esc key timeout in ms- -set notimeout ttimeout | " improves performance but is known to cause problems on slow terminals +set lazyredraw | " disables redraw during macro exectution (improves performance) set linebreak | " wrap long lines at char 'breakat', not inside words -set nowrap | " but do not (by default) wrap long lines around -set clipboard=unnamedplus | " makes copy and paste work (autoselectplus might work as well) -set number | " turn line numbers on/off (performance decreases when they are shown) -set nocursorline | " turn visual cursor line off (improves performance) +set mouse=a | " also supported by vim, should be default set nocursorcolumn | " turn visual cursor column off (improves performance) -set ttyscroll=100 | " improves speed for terminal vim -set ttyfast | " improves speed for terminal vim -set lazyredraw | " disables redraw during macro exectution (improves performance) -set re=1 -set relativenumber | " displays current lines line no as zero point from where relative numbers are getting counted +set nocursorline | " turn visual cursor line off (improves performance) set nofoldenable | " disable code folding. I hate code folding -set spell spelllang=en,de | " enable spell checker +set norelativenumber | " we deactivate relative numbers, but have them mentioned here so we won't forget they existed +set noshowmode | " because we are using some powerline derivat set nostartofline | " when scrolling: do not move the cursor to column 1 -set thesaurus+=/home/max/.vim/thesaurus/php.txt -set hlsearch | " highlights all search matches (not as performant!) -set textwidth=100 | " line length (80 used to be default, but...) +set notimeout ttimeout | " improves performance but is known to cause problems on slow terminals +set nowrap | " but do not (by default) wrap long lines around +set number | " turn line numbers on/off (performance decreases when they are shown) +set pumheight=8 | " Determines the maximum number of items to show in the popup menu for +set redrawtime=400 | " The time in milliseconds for redrawing the display. +set scrolljump=5 | " how many lines get scrolled into view when cursor reaches the screens edge +set spell spelllang=en,de | " enable spell checker set splitbelow | " open new windows below the current one (i find that more intuitive) -set norelativenumber +set t_Co=256 | " required on some ssh sessions +set textwidth=100 | " line length (80 used to be default, but...) +set thesaurus+=/home/max/.vim/thesaurus/php.txt +set ts=2 sts=2 sw=2 expandtab | " indentation which i like (abbr: tabstop, softtabstop, shiftwidth) +set ttimeoutlen=10 | " set esc key timeout in ms- +set ttyfast | " improves speed for terminal vim +set ttyscroll=100 | " improves speed for terminal vim set writedelay=0 -set breakindent | " Every wrapped line will continue visually indented +set termguicolors | " When on, uses highlight-guifg and highlight-guibg attributes in the terminal (=24bit color) if has("multi_byte") - set encoding=utf-8 | " we need default utf-8 encoding to use cool chars as line break and so on (see below) scriptencoding utf-8 | " tell vim that we are using utf-8 here - set showbreak+=› | " symbol used in the beginning of a wrapped line + set encoding=utf-8 | " we need default utf-8 encoding to use cool chars as line break and so on (see below) set listchars=eol:↲ | " symbols used when using :set list (which displays non-printable chars) - set listchars+=trail:· | " symbols used when using :set list (which displays non-printable chars) - set listchars+=precedes:« | " symbols used when using :set list (which displays non-printable chars) set listchars+=extends:» | " symbols used when using :set list (which displays non-printable chars) + set listchars+=precedes:« | " symbols used when using :set list (which displays non-printable chars) set listchars+=tab:▸\ | " symbols used when using :set list (which displays non-printable chars) + set listchars+=trail:· | " symbols used when using :set list (which displays non-printable chars) + set showbreak+=› | " symbol used in the beginning of a wrapped line end if has("gui_running") + set toolbar+=text set guioptions+=eig set guioptions-=T | " toolbar set guioptions+=c | " use console dialogs instead of popups @@ -205,7 +226,7 @@ if bufname('%') == '' set bufhidden=wipe endif -noautocmd +" noautocmd if has("autocmd") set modeline | " set variables specific to a file, like indentation by adding a comment @@ -251,6 +272,16 @@ if has("autocmd") " highlight ColorColumn guibg=#005f87 " highlight ColorColumn guibg=#F0F0E0 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 keyword_lookups + autocmd FileType python setlocal keywordprg=pydoc + autocmd FileType vim setlocal keywordprg=:help |. + augroup END + "set omnifunc=syntaxcomplete#Complete " au BufNewFile,BufRead,BufEnter *.cpp,*.hpp set omnifunc=omni#cpp#complete#Main " Enable omni completion. -- cgit v1.2.3