diff options
| author | Max Christian Pohle | 2016-10-18 13:54:12 +0200 |
|---|---|---|
| committer | Max Christian Pohle | 2016-10-18 13:54:12 +0200 |
| commit | 87271db105e429a402b8934259b2390d55ac7481 (patch) | |
| tree | 077fbbbfdf294d7f18e1c8cf2d18d04aafc4c2bb /vimrc | |
| parent | 4b53f1d6d472c0a621d29d194e43c72e54d23ec3 (diff) | |
| download | vim-87271db105e429a402b8934259b2390d55ac7481.tar.bz2 vim-87271db105e429a402b8934259b2390d55ac7481.zip | |
<leader><leader> opens, focusses & closes NERDTree
Additionally reordered many settings to make the file more readable.
Diffstat (limited to 'vimrc')
| -rw-r--r-- | vimrc | 123 |
1 files changed, 77 insertions, 46 deletions
| @@ -5,8 +5,6 @@ Plug 'tpope/vim-sensible' | " a sane and modern defa | |||
| 5 | Plug 'tpope/vim-surround' | " plugin makes cs"' inside a line replace " with ' | 5 | Plug 'tpope/vim-surround' | " plugin makes cs"' inside a line replace " with ' |
| 6 | Plug 'tpope/vim-fugitive' | " the most complete GIT integration plugin | 6 | Plug 'tpope/vim-fugitive' | " the most complete GIT integration plugin |
| 7 | Plug 'mhinz/vim-signify' | " show changes in the clutter bar | 7 | Plug 'mhinz/vim-signify' | " show changes in the clutter bar |
| 8 | " Plug 'tpope/vim-characterize' | " normal mode: make ga show character names of Unicode chars (ga shows hex and dec values) | ||
| 9 | " Plug 'tpope/vim-repeat' | " lets . (dot) repeat plugin macros as well, specifically vim-surround | ||
| 10 | 8 | ||
| 11 | 9 | ||
| 12 | " Colorschemes: ======================================. | 10 | " Colorschemes: ======================================. |
| @@ -16,10 +14,26 @@ map <leader>q :bp<bar>sp<bar>bn<bar>bd<CR>. | |||
| 16 | 14 | ||
| 17 | " NERDTree: ==========================================. | 15 | " NERDTree: ==========================================. |
| 18 | Plug 'scrooloose/nerdtree' | " replace NetRW, which is kind of buggy | 16 | Plug 'scrooloose/nerdtree' | " replace NetRW, which is kind of buggy |
| 19 | map <leader><leader> :NERDTreeToggle<CR> | ||
| 20 | set winwidth=30 " keep NERDTreeWindow at least this size | 17 | set winwidth=30 " keep NERDTreeWindow at least this size |
| 21 | set winminwidth=30 " (and all other windows, so TODO: watch out) | 18 | set winminwidth=30 " (and all other windows, so TODO: watch out) |
| 22 | 19 | ||
| 20 | " open or focus the NERDTree with this key binding and close it if it is the active buffer... | ||
| 21 | nnoremap <expr> | ||
| 22 | \ <leader><leader> | ||
| 23 | \ !exists("b:NERDTree") ? ':NERDTreeFocus<CR>' : ':NERDTreeClose<CR>' | ||
| 24 | |||
| 25 | " close NERDTree if it is the last remaining window (taken from the official documentation) | ||
| 26 | autocmd bufenter * | ||
| 27 | \ if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif | ||
| 28 | |||
| 29 | " if NERDTree has the focus, pressing <Tab> should jump to the next window, but if the file | ||
| 30 | " buffer is selected <Tab> should select the next buffer (:bn). That is archived by :h map-expr | ||
| 31 | nnoremap <expr> | ||
| 32 | \ <Tab> | ||
| 33 | \ bufname("%")=='NERD_tree_1' ? '<C-W><C-W>' : ':bn<CR>' | ||
| 34 | nnoremap <expr> | ||
| 35 | \ <S-Tab> | ||
| 36 | \ bufname("%")=='NERD_tree_1' ? '<C-W><C-W>' : ':bp<CR>' | ||
| 23 | 37 | ||
| 24 | " AIRLINE: ===========================================. | 38 | " AIRLINE: ===========================================. |
| 25 | Plug 'vim-airline/vim-airline' | " beautification of the mode line | 39 | Plug 'vim-airline/vim-airline' | " beautification of the mode line |
| @@ -93,20 +107,19 @@ let g:pymode_rope = 0 " https://github.com/david | |||
| 93 | " let g:pymode_options_max_line_length = 120 | 107 | " let g:pymode_options_max_line_length = 120 |
| 94 | " let g:syntastic_python_flake8_args='--ignore=F821,E302,E501,E241,E301' | 108 | " let g:syntastic_python_flake8_args='--ignore=F821,E302,E501,E241,E301' |
| 95 | 109 | ||
| 96 | 110 | Plug 'honza/vim-snippets' " dependency of ultisnips (see below) | |
| 97 | Plug 'SirVer/ultisnips' " replaces loremipsum (and many more) | 111 | Plug 'SirVer/ultisnips' " replaces loremipsum (and many more) |
| 98 | Plug 'honza/vim-snippets' " dependency of ultisnips | 112 | let g:UltiSnipsExpandTrigger = '<C-j>'| " Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe. |
| 99 | " Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe. | 113 | let g:UltiSnipsJumpForwardTrigger = '<C-j>'| " \ |
| 100 | "" Ultisnips | 114 | let g:UltiSnipsJumpBackwardTrigger = '<C-k>'| " \ |
| 101 | let g:UltiSnipsExpandTrigger="<c-tab>" | 115 | " let g:UltiSnipsListSnippets = '<c-s-tab>'| " YouCompleteMe includes those, so this isn't necessary |
| 102 | let g:UltiSnipsListSnippets="<c-s-tab>" | 116 | " let g:UltiSnipsEditSplit = 'vertical' |
| 103 | 117 | ||
| 104 | " If you want :UltiSnipsEdit to split your window. | ||
| 105 | let g:UltiSnipsEditSplit="vertical" | ||
| 106 | 118 | ||
| 107 | " Disabled ===========================================. | 119 | " Disabled ===========================================. |
| 108 | " Plug 'Shougo/neocomplete.vim' | " alternative to YouCompleteMe in some cases | 120 | " Plug 'Shougo/neocomplete.vim' | " alternative to YouCompleteMe in some cases |
| 109 | " Plug 'Shougo/vimproc.vim' | " dependency for other Shougo plugins | 121 | " Plug 'tpope/vim-characterize' | " normal mode: make ga show character names of Unicode chars (ga shows hex and dec values) |
| 122 | " Plug 'tpope/vim-repeat' | " lets . (dot) repeat plugin macros as well, specifically vim-surround | ||
| 110 | 123 | ||
| 111 | call plug#end() | " all plugins are getting loaded on this line, don't remove! | 124 | call plug#end() | " all plugins are getting loaded on this line, don't remove! |
| 112 | 125 | ||
| @@ -124,7 +137,6 @@ colorscheme base16-phd | |||
| 124 | " colorscheme base16-summerfruit-dark | 137 | " colorscheme base16-summerfruit-dark |
| 125 | " colorscheme base16-tommorow | 138 | " colorscheme base16-tommorow |
| 126 | " colorscheme base16-default-dark | 139 | " colorscheme base16-default-dark |
| 127 | " colorscheme vividchalk | " finally set which colorscheme to use | ||
| 128 | 140 | ||
| 129 | 141 | ||
| 130 | " colorscheme customizations ========================= | 142 | " colorscheme customizations ========================= |
| @@ -137,60 +149,69 @@ inoremap <C-Space> <C-x><C-o> | |||
| 137 | "inoremap <C-@> <C-Space> | 149 | "inoremap <C-@> <C-Space> |
| 138 | vnoremap < <gv| " allows deindenting a selected block and keeps selection | 150 | vnoremap < <gv| " allows deindenting a selected block and keeps selection |
| 139 | vnoremap > >gv| " allows indenting a selected block and keeps selection | 151 | vnoremap > >gv| " allows indenting a selected block and keeps selection |
| 140 | " if NERDTree has the focus, pressing <Tab> should jump to the next window, but if the file | 152 | |
| 141 | " buffer is selected <Tab> should select the next buffer (:bn). That is archived by :h map-expr | 153 | " Bind CTRL+Backspace to vims version (CTRL+W) in " <CR> insert mode (only works with gvim) |
| 142 | nnoremap <expr> <Tab> bufname("%")=='NERD_tree_1' ? '<C-W><C-W>' : ':bn<CR>' | 154 | inoremap |
| 143 | nnoremap <expr> <S-Tab> bufname("%")=='NERD_tree_1' ? '<C-W><C-W>' : ':bp<CR>' | 155 | \ <C-Backspace> |
| 144 | inoremap <C-Backspace> <C-W>| " Bind CTRL+Backspace to vims version (CTRL+W) in insert mode | 156 | \ <C-W> |
| 157 | |||
| 145 | 158 | ||
| 146 | 159 | ||
| 147 | " settings ============================================. | 160 | " settings ============================================. |
| 148 | " set shell=/bin/bash | " many scripts rely on bash, but its path varies why it is commented out here | 161 | " set shell=/bin/bash | " many scripts rely on bash, but its path varies why it is commented out here |
| 149 | set mouse=a | " also supported by vim, should be default | 162 | " set selectmode=mouse,key,cmd | " enters vim's select mode when pressing shift-left or shift-END |
| 150 | set noshowmode | " because we are using some powerline derivat | 163 | " set keymodel=startsel,stopsel | " makes shift-left, shift-right available for selecting text |
| 151 | set hidden | " allows switiching buffers even if the current buffer contains changes (displays +) | 164 | set breakindent | " Every wrapped line will continue visually indented |
| 165 | set clipboard=unnamedplus | " makes copy and paste work (autoselectplus might work as well) | ||
| 166 | set complete+=d | " scan current and included files for defined name or macro | ||
| 167 | set complete+=i | " scan current and included files for completions | ||
| 168 | set concealcursor=nc | " limits the display of concealed text to normal and command mode | ||
| 169 | set conceallevel=2 | " replace escaped chars by their utf-8 representation (useful for LaTeX) | ||
| 152 | set confirm | " asks 'do you want to save?' | 170 | set confirm | " asks 'do you want to save?' |
| 153 | set t_Co=256 | " required on some ssh sessions | ||
| 154 | set ts=2 sts=2 sw=2 expandtab | " indentation which i like (abbr: tabstop, softtabstop, shiftwidth) | ||
| 155 | set scrolljump=5 | " how many lines get scrolled into view when cursor reaches the screens edge | ||
| 156 | set encoding=utf-8 | " set up vim's cosole encoding (not file encoding, for which there is fileencoding=) | 171 | set encoding=utf-8 | " set up vim's cosole encoding (not file encoding, for which there is fileencoding=) |
| 172 | set hidden | " allows switiching buffers even if the current buffer contains changes (displays +) | ||
| 173 | set hlsearch | " highlights all search matches (not as performant!) | ||
| 157 | set ignorecase smartcase | " search with ignorecase by default, but use case sensitive search when one captical char is contained | 174 | set ignorecase smartcase | " search with ignorecase by default, but use case sensitive search when one captical char is contained |
| 158 | set ttimeoutlen=10 | " set esc key timeout in ms- | 175 | set lazyredraw | " disables redraw during macro exectution (improves performance) |
| 159 | set notimeout ttimeout | " improves performance but is known to cause problems on slow terminals | ||
| 160 | set linebreak | " wrap long lines at char 'breakat', not inside words | 176 | set linebreak | " wrap long lines at char 'breakat', not inside words |
| 161 | set nowrap | " but do not (by default) wrap long lines around | 177 | set mouse=a | " also supported by vim, should be default |
| 162 | set clipboard=unnamedplus | " makes copy and paste work (autoselectplus might work as well) | ||
| 163 | set number | " turn line numbers on/off (performance decreases when they are shown) | ||
| 164 | set nocursorline | " turn visual cursor line off (improves performance) | ||
| 165 | set nocursorcolumn | " turn visual cursor column off (improves performance) | 178 | set nocursorcolumn | " turn visual cursor column off (improves performance) |
| 166 | set ttyscroll=100 | " improves speed for terminal vim | 179 | set nocursorline | " turn visual cursor line off (improves performance) |
| 167 | set ttyfast | " improves speed for terminal vim | ||
| 168 | set lazyredraw | " disables redraw during macro exectution (improves performance) | ||
| 169 | set re=1 | ||
| 170 | set relativenumber | " displays current lines line no as zero point from where relative numbers are getting counted | ||
| 171 | set nofoldenable | " disable code folding. I hate code folding | 180 | set nofoldenable | " disable code folding. I hate code folding |
| 172 | set spell spelllang=en,de | " enable spell checker | 181 | set norelativenumber | " we deactivate relative numbers, but have them mentioned here so we won't forget they existed |
| 182 | set noshowmode | " because we are using some powerline derivat | ||
| 173 | set nostartofline | " when scrolling: do not move the cursor to column 1 | 183 | set nostartofline | " when scrolling: do not move the cursor to column 1 |
| 174 | set thesaurus+=/home/max/.vim/thesaurus/php.txt | 184 | set notimeout ttimeout | " improves performance but is known to cause problems on slow terminals |
| 175 | set hlsearch | " highlights all search matches (not as performant!) | 185 | set nowrap | " but do not (by default) wrap long lines around |
| 176 | set textwidth=100 | " line length (80 used to be default, but...) | 186 | set number | " turn line numbers on/off (performance decreases when they are shown) |
| 187 | set pumheight=8 | " Determines the maximum number of items to show in the popup menu for | ||
| 188 | set redrawtime=400 | " The time in milliseconds for redrawing the display. | ||
| 189 | set scrolljump=5 | " how many lines get scrolled into view when cursor reaches the screens edge | ||
| 190 | set spell spelllang=en,de | " enable spell checker | ||
| 177 | set splitbelow | " open new windows below the current one (i find that more intuitive) | 191 | set splitbelow | " open new windows below the current one (i find that more intuitive) |
| 178 | set norelativenumber | 192 | set t_Co=256 | " required on some ssh sessions |
| 193 | set textwidth=100 | " line length (80 used to be default, but...) | ||
| 194 | set thesaurus+=/home/max/.vim/thesaurus/php.txt | ||
| 195 | set ts=2 sts=2 sw=2 expandtab | " indentation which i like (abbr: tabstop, softtabstop, shiftwidth) | ||
| 196 | set ttimeoutlen=10 | " set esc key timeout in ms- | ||
| 197 | set ttyfast | " improves speed for terminal vim | ||
| 198 | set ttyscroll=100 | " improves speed for terminal vim | ||
| 179 | set writedelay=0 | 199 | set writedelay=0 |
| 180 | set breakindent | " Every wrapped line will continue visually indented | 200 | set termguicolors | " When on, uses highlight-guifg and highlight-guibg attributes in the terminal (=24bit color) |
| 181 | 201 | ||
| 182 | if has("multi_byte") | 202 | if has("multi_byte") |
| 183 | set encoding=utf-8 | " we need default utf-8 encoding to use cool chars as line break and so on (see below) | ||
| 184 | scriptencoding utf-8 | " tell vim that we are using utf-8 here | 203 | scriptencoding utf-8 | " tell vim that we are using utf-8 here |
| 185 | set showbreak+=› | " symbol used in the beginning of a wrapped line | 204 | set encoding=utf-8 | " we need default utf-8 encoding to use cool chars as line break and so on (see below) |
| 186 | set listchars=eol:↲ | " symbols used when using :set list (which displays non-printable chars) | 205 | set listchars=eol:↲ | " symbols used when using :set list (which displays non-printable chars) |
| 187 | set listchars+=trail:· | " symbols used when using :set list (which displays non-printable chars) | ||
| 188 | set listchars+=precedes:« | " symbols used when using :set list (which displays non-printable chars) | ||
| 189 | set listchars+=extends:» | " symbols used when using :set list (which displays non-printable chars) | 206 | set listchars+=extends:» | " symbols used when using :set list (which displays non-printable chars) |
| 207 | set listchars+=precedes:« | " symbols used when using :set list (which displays non-printable chars) | ||
| 190 | set listchars+=tab:▸\ | " symbols used when using :set list (which displays non-printable chars) | 208 | set listchars+=tab:▸\ | " symbols used when using :set list (which displays non-printable chars) |
| 209 | set listchars+=trail:· | " symbols used when using :set list (which displays non-printable chars) | ||
| 210 | set showbreak+=› | " symbol used in the beginning of a wrapped line | ||
| 191 | end | 211 | end |
| 192 | 212 | ||
| 193 | if has("gui_running") | 213 | if has("gui_running") |
| 214 | set toolbar+=text | ||
| 194 | set guioptions+=eig | 215 | set guioptions+=eig |
| 195 | set guioptions-=T | " toolbar | 216 | set guioptions-=T | " toolbar |
| 196 | set guioptions+=c | " use console dialogs instead of popups | 217 | set guioptions+=c | " use console dialogs instead of popups |
| @@ -205,7 +226,7 @@ if bufname('%') == '' | |||
| 205 | set bufhidden=wipe | 226 | set bufhidden=wipe |
| 206 | endif | 227 | endif |
| 207 | 228 | ||
| 208 | noautocmd | 229 | " noautocmd |
| 209 | 230 | ||
| 210 | if has("autocmd") | 231 | if has("autocmd") |
| 211 | set modeline | " set variables specific to a file, like indentation by adding a comment | 232 | set modeline | " set variables specific to a file, like indentation by adding a comment |
| @@ -251,6 +272,16 @@ if has("autocmd") | |||
| 251 | " highlight ColorColumn guibg=#005f87 | 272 | " highlight ColorColumn guibg=#005f87 |
| 252 | " highlight ColorColumn guibg=#F0F0E0 | 273 | " highlight ColorColumn guibg=#F0F0E0 |
| 253 | augroup END " } | 274 | augroup END " } |
| 275 | |||
| 276 | |||
| 277 | " hitting K over a keyword shows a help in a buffer. | ||
| 278 | " Here we define the commands used to look those keywords up | ||
| 279 | " as per file type... | ||
| 280 | augroup keyword_lookups | ||
| 281 | autocmd FileType python setlocal keywordprg=pydoc | ||
| 282 | autocmd FileType vim setlocal keywordprg=:help |. | ||
| 283 | augroup END | ||
| 284 | |||
| 254 | "set omnifunc=syntaxcomplete#Complete | 285 | "set omnifunc=syntaxcomplete#Complete |
| 255 | " au BufNewFile,BufRead,BufEnter *.cpp,*.hpp set omnifunc=omni#cpp#complete#Main | 286 | " au BufNewFile,BufRead,BufEnter *.cpp,*.hpp set omnifunc=omni#cpp#complete#Main |
| 256 | " Enable omni completion. | 287 | " Enable omni completion. |
