From e077f353f8bc06913b7f45f31bb9a61303ccc1a4 Mon Sep 17 00:00:00 2001 From: valeth Date: Wed, 18 Nov 2015 12:44:36 +0100 Subject: [PATCH] unclutter init.vim --- init.vim | 148 +++++++++++++++++-------------------------------------- 1 file changed, 45 insertions(+), 103 deletions(-) diff --git a/init.vim b/init.vim index 22a830b..fda1114 100644 --- a/init.vim +++ b/init.vim @@ -1,14 +1,14 @@ """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " " " Maintainer: Patrick Auernig " -" VIM Version: NVIM 0.1.0 +" VIM Version: NVIM 0.1.0 " " " """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -""""""""""""""""""""""""" -" Core: XDG Directories " -""""""""""""""""""""""""" +""""""""""""""""""" +" XDG Directories " +""""""""""""""""""" let g:vim_config_home = split(&rtp, ',', 0)[0] if exists('$XDG_CACHE_HOME') @@ -23,17 +23,10 @@ else let g:vim_data_home = expand('$HOME/.local/share/') . v:progname endif -" automatically reload config -augroup myvimrc - au! - au BufWritePost $MYVIMRC source $MYVIMRC -augroup END - - -""""""""""""""""""""""""""""""""""" -" Settings: All kinds of settings " -""""""""""""""""""""""""""""""""""" +"""""""""""" +" Settings " +"""""""""""" set confirm set ttimeout set timeoutlen=500 @@ -60,64 +53,22 @@ set showcmd set wildmode=list:longest,full set wildignore=.bak,.old,.swp,~ set virtualedit=block +set foldcolumn=1 +set foldlevel=99 +set foldmethod=syntax +set foldtext=myfold#text() +let g:sh_fold_enabled=1 +set visualbell +set t_vb= -" enable filetype plugins filetype indent on filetype plugin on syntax enable -aug LineNumbers - au! - au VimEnter,WinEnter,InsertLeave * setlocal relativenumber - au WinLeave,InsertEnter * setlocal norelativenumber -aug END - -aug CursorLineColumn - au! - au VimEnter,WinEnter,BufWinEnter * setlocal cursorline cursorcolumn - au WinLeave * setlocal nocursorline nocursorcolumn -aug END - -"set visualbell -"set t_vb= - -set foldcolumn=1 -set foldlevel=99 -set foldmethod=syntax -set foldtext=MyFoldText() -let g:sh_fold_enabled=1 - -function! MyFoldText() - " get actual numberwidth of the current document - let nw_add = (len(line('$')) - (&numberwidth - 1)) - if nw_add > 0 - let nw = &numberwidth + nw_add - else - let nw = &numberwidth - endif - - let numfold_w =(nw * &number) + &foldcolumn - let window_w = winwidth(0) - numfold_w - let onetab = strpart(' ', 0, &tabstop) - - let foldtxt_start = getline(v:foldstart) . ' …' - let foldtxt_start = substitute(foldtxt_start, '\t', onetab, 'g') - let foldtxt_start_w = len(foldtxt_start) - 2 - - let foldtxt_end = '+' . string(foldclosedend(v:foldend) - foldclosed(v:foldstart)) . '  ' - let foldtxt_end_w = len(foldtxt_end) - - let foldtxt_mid_w = window_w - (foldtxt_start_w + foldtxt_end_w) - let foldtxt_mid = repeat(' ', foldtxt_mid_w + 2) - - return foldtxt_start . foldtxt_mid . foldtxt_end -endfunction - - -""""""""""""""""""""""""""""""" -" Mappings: Keyboard mappings " -""""""""""""""""""""""""""""""" +""""""""""""""""""""" +" Keyboard mappings " +""""""""""""""""""""" let g:mapleader = "," command! Wq wq @@ -161,48 +112,39 @@ cnoremap sudow w !sudo tee % >/dev/null tnoremap -" highlight searches and search while typing -if maparg('', 'n') ==# '' - nnoremap :nohlsearch -endif + +"""""""""""""""" +" Autocommands " +"""""""""""""""" +aug ToggleLineNumbers + au! + au VimEnter,WinEnter,InsertLeave * setlocal relativenumber + au WinLeave,InsertEnter * setlocal norelativenumber +aug END + +aug CursorLineColumn + au! + au VimEnter,WinEnter,BufWinEnter * setlocal cursorline cursorcolumn + au WinLeave * setlocal nocursorline nocursorcolumn +aug END + +augroup AutoReload + au! + au BufWritePost $MYVIMRC source $MYVIMRC +augroup END -if exists('$TMUX') - function! TmuxOrSplitSwitch(wincmd, tmuxdir) - let previous_winnr = winnr() - silent! execute "wincmd " . a:wincmd - if previous_winnr == winnr() - call system("tmux select-pane -" . a:tmuxdir) - redraw! - endif - endfunction - - let previous_title = substitute(system("tmux display-message -p '#{pane_title}'"), '\n', '', '') - let &t_ti = "\]2;vim\\\" . &t_ti - let &t_te = "\]2;". previous_title . "\\\" . &t_te - - noremap :call TmuxOrSplitSwitch('h', 'L') - noremap :call TmuxOrSplitSwitch('l', 'R') - noremap :call TmuxOrSplitSwitch('k', 'U') - noremap :call TmuxOrSplitSwitch('j', 'D') - noremap :call TmuxOrSplitSwitch('b', 'l') -else - noremap h - noremap j - noremap k - noremap l -endif - - -""""""""""""""""""""""""""""""""""""""""" -" Plugins: Plugin loading with vim-plug " -""""""""""""""""""""""""""""""""""""""""" +""""""""""" +" Plugins " +""""""""""" call plug#begin(g:vim_data_home . '/plugins') runtime! plugins/**/*.vim call plug#end() -"""""""""""""""" -" Colorscheme: " -"""""""""""""""" + +""""""""""""""" +" Colorscheme " +""""""""""""""" "colorscheme seoul256 colorscheme molokai +