From bbb6ae5cfbd95fef907d092f71cc69fb4130a9ae Mon Sep 17 00:00:00 2001 From: Jannik ZANDER Date: Sat, 7 Jul 2018 07:23:29 +0200 Subject: [PATCH] Vimrc cleanup --- .vim/vimrc | 284 +++++++++++++++++------------------------------------ 1 file changed, 91 insertions(+), 193 deletions(-) diff --git a/.vim/vimrc b/.vim/vimrc index 946aa54..b15c3b6 100644 --- a/.vim/vimrc +++ b/.vim/vimrc @@ -1,4 +1,4 @@ -" section: environment {{{1 +" options " --------------------- silent !mkdir -p ~/.local/share/vim/{swap,backup,undo} @@ -7,64 +7,96 @@ set backupdir=~/.local/share/vim/backup set undodir=~/.local/share/vim/undo set viminfo+=n~/.local/share/vim/viminfo -" section: options {{{1 -" --------------------- -"set autoindent +set undofile +set fileformats=unix,dos,mac +set printoptions=paper:letter +set shell=/bin/bash + set autoread set autowrite " automatically save before commands like :next and :make + +"set autoindent set backspace=2 -if exists('+breakindent') - set breakindent showbreak=\ + -endif -set cmdheight=2 -setglobal commentstring=#\ %s -set complete-=i " searching includes can be slow -"if has("win32") || has("win64") -" does not work for msys2 +set breakindent showbreak=\ + + set clipboard=unnamed -"else "set clipboard=unnamedplus -"endif -set fileformats=unix,dos,mac + "set foldmethod=syntax "set foldlevel=1 "set foldclose=all "set foldopen+=jump + set guioptions+=a "set guioptions-=m "menu bar set guioptions-=T "toolbar set guioptions-=r "scroolbar + +set complete-=i " searching includes can be slow set history=200 set incsearch " incremental search set laststatus=2 " always show status line set lazyredraw set linebreak + set mouse=nvi set mousemodel=popup + set number -"set pastetoggle= -set printoptions=paper:letter set scrolloff=1 set shiftround set shortmess=aoOtI -"set showcmd " show (partial) command in status line. +set cmdheight=2 +set showcmd " show (partial) command in status line. + set showmatch " show matching brackets. set sidescrolloff=5 set smartcase " case insensitive searches become sensitive with capitals "setglobal tags=./tags; +" set timeoutlen=500 " leader key timeout set ttimeoutlen=50 " make esc work faster + set visualbell -if exists('+undofile') - set undofile -endif set virtualedit=block set updatetime=250 + set wildmenu set wildmode=longest:full,full set wildignore+=tags,.*.un~,*.pyc set winaltkeys=no -set shell=/bin/bash + +" visual +""""""""""""""""""""""""""""""""""""""""" + +highlight Normal guibg=black guifg=white +set background=dark +set t_Co=256 + +" switch syntax highlighting on, when the terminal has colors +if (&t_Co > 2 || has("gui_running")) && has("syntax") + if exists("&guifont") + if has("mac") + set guifont=monaco:h11 + elseif has("unix") + set guifont=inconsolata\ 11 + elseif has("win32") +" set guifont=consolas:h11,courier\ new:h10 + set guifont=consolas:h10:cANSI:qDRAFT + endif + endif + + + if exists("syntax_on") || exists("syntax_manual") + else + syntax on + endif +endif + + +" make +""""""""""""""""""""""""""""""""""""""""" + set path=.,,**,C:\programs\IAR\\\ System\EWB_V850_V360\common\bin "set makeprg=cmake\ --build\ . @@ -80,35 +112,34 @@ set errorformat=\ %#%f(%l):\ %m " set errorformat=%f(%l)\ :\ %m "endif +" grep +""""""""""""""""""""""""""""""""""""""""" + if executable('ag') set grepprg=ag\ --vimgrep\ --skip-vcs-ignores\ --path-to-ignore\ ~/.ignore\ --cpp\ --cc set grepformat^=%f:%l:%c:%m " file:line:coloumn:message endif -"syn match pythonDefStatement /^\s*\%(def\|class\)/ -" \ nextgroup=pythonFunction skipwhite -"syn region pythonFunctionFold start="^\z(\s*\)\%(def\|class\)\>" -" \ end="\ze\%(\s*\n\)\+\%(\z1\s\)\@!." fold transparent -"hi link pythonDefStatement Statement +" settings +""""""""""""""""""""""""""""""""""""""""" -"let g:syntastic_quiet_messages = { "type": "style" } +" block cursor in normal mode +let &t_ti.="\e[1 q" +let &t_SI.="\e[5 q" +let &t_EI.="\e[1 q" +let &t_te.="\e[0 q" -" plugin settings {{{1 +" netrw let g:netrw_liststyle=3 let g:netrw_banner = 0 let g:netrw_sort_sequence = '[\/]$,*' -"let g:markdown_fenced_languages = ['html', 'python', 'bash=sh'] -"let g:markdown_syntax_conceal = 0 - - -"for airline +" airline let g:airline#extensions#tabline#enabled = 1 - - +" editorconfig let g:editorconfig_exclude_patterns = ['fugitive://.*', 'scp://.*'] let g:editorconfig_verbose = 1 @@ -118,186 +149,53 @@ else let g:editorconfig_core_mode = "python_builtin" endif -"set colorcolumn=80 -"highlight ColorColumn ctermbg=9 -" block cursor in normal mode -let &t_ti.="\e[1 q" -let &t_SI.="\e[5 q" -let &t_EI.="\e[1 q" -let &t_te.="\e[0 q" - -let python_folding = 1 -" }}}2 -" section: commands {{{1 -"----------------------- - -if has("cscope") - set nocscopetag - set cscopequickfix=s-,c-,d-,i-,t-,e- - set nocscopeverbose - if filereadable(".git/cscope.out") - cscope add .git/cscope.out - endif - set cscopeverbose - - function! Cscoperebuild() - cscope kill .git/cscope.out - silent execute "!./.git/hooks/cscope" - if v:shell_error - redraw! - echohl errormsg | echo "unable to run cscope command." | echohl none - else - if filereadable(".git/cscope.out") - redraw! - cscope add .git/cscope.out - else - redraw! - echohl errormsg | echo "unable to read cscope database." | echohl none - endif - endif - endfunction - - command! Cscope call Cscoperebuild() -endif" - - -" section: mappings {{{1 -" ---------------------- -" +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" mappings +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" let mapleader = "," -" Grep the word under cursor +" grep under cursor nnoremap * :silent grep \| copen " redraws the screen -" Quickly edit/reload the vimrc file -nmap ev :e $MYVIMRC -nmap sv :so $MYVIMRC +" buffers +nnoremap b :buffer -" Minibufferexplorer -nnoremap b :MBEToggle -"let g:miniBufExplMapWindowNavVim = 1 -"let g:miniBufExplMapCTabSwitchBufs = 1 -" -" Tagbar -nnoremap t :TagbarToggle - -" copy/paste from system clipboard -if has("win32") -vnoremap y "*y -vnoremap d "*d -nnoremap p "*p -nnoremap P "*P - -vnoremap p "*p -vnoremap P "*P -else -" nnoremap y "*y -" nnoremap p "*p -" nnoremap Y "+y -" nnoremap P "+p -" nnoremap y "*y -" nnoremap yy "*yy -" noremap p "*p -" noremap P "*P -endif +" tags +nnoremap t :tags -if has("cscope") -" cnoreabbrev csa -" \ ((getcmdtype() == ':' && getcmdpos() <= 4)? 'cs add' : 'csa') -" cnoreabbrev csf -" \ ((getcmdtype() == ':' && getcmdpos() <= 4)? 'cs find' : 'csf') -" cnoreabbrev csk -" \ ((getcmdtype() == ':' && getcmdpos() <= 4)? 'cs kill' : 'csk') -" cnoreabbrev csr -" \ ((getcmdtype() == ':' && getcmdpos() <= 4)? 'cs reset' : 'csr') -" cnoreabbrev css -" \ ((getcmdtype() == ':' && getcmdpos() <= 4)? 'cs show' : 'css') -" cnoreabbrev csh -" \ ((getcmdtype() == ':' && getcmdpos() <= 4)? 'cs help' : 'csh') - - nnoremap fa :call CscopeFindInteractive(expand('')) - nnoremap l :call ToggleLocationList() - - " s: Find this C symbol - nnoremap fs :call CscopeFind('s', expand('')) - " g: Find this definition - nnoremap fg :call CscopeFind('g', expand('')) - " d: Find functions called by this function - nnoremap fd :call CscopeFind('d', expand('')) - " c: Find functions calling this function - nnoremap fc :call CscopeFind('c', expand('')) - " t: Find this text string - nnoremap ft :call CscopeFind('t', expand('')) - " e: Find this egrep pattern - nnoremap fe :call CscopeFind('e', expand('')) - " f: Find this file - nnoremap ff :call CscopeFind('f', expand('')) - " i: Find files #including this file - nnoremap fi :call CscopeFind('i', expand('')) - - "todo: figure out how to get cstag output in quickfix or a popup menu. - map :cstag =expand("") -endif - -" Ctrl-P +" ctrl-p let g:ctrlp_user_command = ['.git/', 'git --git-dir=%s/.git ls-files -oc --exclude-standard'] let g:ctrlp_map = '' let g:ctrlp_cmd = 'CtrlP' -" Maps Ctrl-[h,j,k,l,+,-] to windows split navigations and resizing -nnoremap -nnoremap -nnoremap -nnoremap +" ctrl-hjkl to windows navigation and resizing +nnoremap +nnoremap +nnoremap +nnoremap + if bufwinnr(1) -nnoremap j :exe "resize " . (winheight(0) * 2/3) -nnoremap k :exe "resize " . (winheight(0) * 3/2) +nnoremap :exe "resize " . (winheight(0) * 2/3) +nnoremap :exe "resize " . (winheight(0) * 3/2) endif " folding noremap za -" In the quickfix window, is used to jump to the error under the -" cursor, so undefine the mapping there. -autocmd BufReadPost quickfix nnoremap -" section: autocommands {{{1 -" -------------------------- + +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" autocommands +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + if has("autocmd") filetype plugin indent on + autocmd BufReadPost quickfix nnoremap autocmd bufnewfile,bufread *.md set filetype=markdown autocmd bufnewfile,bufread *.gradle set filetype=groovy -endif " has("autocmd") -" }}}1 -" section: visual {{{1 -" -------------------- - -" switch syntax highlighting on, when the terminal has colors -if (&t_Co > 2 || has("gui_running")) && has("syntax") - if exists("&guifont") - if has("mac") - set guifont=monaco:h11 - elseif has("unix") - set guifont=inconsolata\ 11 - elseif has("win32") -" set guifont=consolas:h11,courier\ new:h10 - set guifont=Consolas:h10:cANSI:qDRAFT - endif - endif - - - if exists("syntax_on") || exists("syntax_manual") - else - syntax on - endif endif -"colorscheme dark default -highlight Normal guibg=black guifg=white -set background=dark -set t_Co=256 -" }}}1 - +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" if filereadable(expand('~/.vim/vimrc.local')) source ~/.vim/vimrc.local endif -- 2.43.0