From e3e4df02771889169708c67ea542e7de6821c0fe Mon Sep 17 00:00:00 2001 From: valeth Date: Fri, 6 Nov 2015 09:02:22 +0100 Subject: [PATCH] restructure core config --- core/buffer.vim | 44 ------------------- core/compat.vim | 17 ++++++++ core/control.vim | 45 ------------------- core/folding.vim | 34 --------------- core/formatting.vim | 29 ------------ core/legacy.vim | 53 ++++++++++++++++++++++ core/mappings.vim | 63 +++++++++++++++++++++++++++ core/plugins.vim | 34 +++++++++------ core/search.vim | 16 ------- core/settings.vim | 104 ++++++++++++++++++++++++++++++++++++++++++++ core/tabs.vim | 11 ----- core/tmux.vim | 25 +++++++++++ core/window.vim | 102 ------------------------------------------- 13 files changed, 282 insertions(+), 295 deletions(-) delete mode 100644 core/buffer.vim create mode 100644 core/compat.vim delete mode 100644 core/control.vim delete mode 100644 core/folding.vim delete mode 100644 core/formatting.vim create mode 100644 core/legacy.vim create mode 100644 core/mappings.vim delete mode 100644 core/search.vim create mode 100644 core/settings.vim delete mode 100644 core/tabs.vim create mode 100644 core/tmux.vim delete mode 100644 core/window.vim diff --git a/core/buffer.vim b/core/buffer.vim deleted file mode 100644 index 4b8e7bf..0000000 --- a/core/buffer.vim +++ /dev/null @@ -1,44 +0,0 @@ -set autowrite -set autoread - -command! Wq wq -command! WQ wq -command! Q q -command! W w - -" set the history far higher (default 50) -if &history < 1000 - set history=1000 -endif - -nnoremap U :redo -nnoremap - -if v:version >= 704 - set undofile - set undolevels=1000 -endif - -" write swap file to disk after n millisecs -set updatetime=1500 - -set switchbuf=useopen,usetab - -" more clipboard options -if has('xterm_clipboard') - set clipboard=unnamed,unnamedplus,autoselect -endif - -" allow explicit writing of read-only files with sudo -cnoremap sudow w !sudo tee % >/dev/null - -aug ReadonlyFiles - au BufNewFile,BufRead /var/log/* set readonly - au BufNewFile,BufRead /var/log/* set nomodifiable -aug END - -"if v:version >= 704 - "set cryptmethod=blowfish - - "au BufReadPost * if &key != "" | set noswapfile nowritebackup viminfo= nobackup noshelltemp history=0 secure | endif -"endif diff --git a/core/compat.vim b/core/compat.vim new file mode 100644 index 0000000..b1410a1 --- /dev/null +++ b/core/compat.vim @@ -0,0 +1,17 @@ +if ! has('nvim') + set ttimeoutlen=-1 +endif + +if v:version >= 704 + set undofile + + aug LineNumbers + au! + au VimEnter,WinEnter,InsertLeave * setlocal relativenumber + au WinLeave,InsertEnter * setlocal norelativenumber + aug END +endif + +if has('xterm_clipboard') + set clipboard=unnamed,unnamedplus,autoselect +endif diff --git a/core/control.vim b/core/control.vim deleted file mode 100644 index bd42e44..0000000 --- a/core/control.vim +++ /dev/null @@ -1,45 +0,0 @@ -nnoremap Y y$ -nnoremap j gj -nnoremap k gk - -inoremap jk -inoremap JK -inoremap Jk - -set ttimeout - -" lower timeout -set ttimeoutlen=-1 -set timeoutlen=500 - -" unset default help shortcut -nnoremap -inoremap - -let g:mapleader = "," - -" unset search highlighting -noremap :noh - -nnoremap vl :setlocal cursorline! -nnoremap vc :setlocal cursorcolumn! -nnoremap ve :setlocal colorcolumn=80 -nnoremap vn :setlocal colorcolumn=0 - -" enable mouse support -if has('mouse') - set mouse=a -endif - -" some useful backspace settings -set backspace=indent,eol,start - -" change the current directory to the one containing the current file -if has('autochdir') - set autochdir -endif - -" octal is not really that important -set nrformats-=octal - -set confirm diff --git a/core/folding.vim b/core/folding.vim deleted file mode 100644 index 17c4a61..0000000 --- a/core/folding.vim +++ /dev/null @@ -1,34 +0,0 @@ -if has('folding') - set foldcolumn=1 - set foldlevel=1 - 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 -endif diff --git a/core/formatting.vim b/core/formatting.vim deleted file mode 100644 index c2d416e..0000000 --- a/core/formatting.vim +++ /dev/null @@ -1,29 +0,0 @@ -if v:version >= 704 - set formatoptions+="j" -endif - -set autoindent -set smarttab - -" round the indent to a multiple o shiftwidth -set shiftround - -if has('smartindent') - set smartindent -endif - -" enable filetype plugins -if has('autocmd') - filetype indent on - filetype plugin on -endif - -vnoremap < >gv - -" fix indentation of an entire file -nnoremap fmt gg=G`` - -" local replace -nnoremap gr gd[{V%::s////g -nnoremap gR gD:%s////g diff --git a/core/legacy.vim b/core/legacy.vim new file mode 100644 index 0000000..e1d66e6 --- /dev/null +++ b/core/legacy.vim @@ -0,0 +1,53 @@ +if ! has('nvim') + " default options in neovim + set autoindent + set autoread + set backspace=indent,eol,start + set complete-=i + set display=lastline + "if has('multi_byte') + "set encoding=utf-8 + "endif + if v:version >= 704 + set formatoptions=tcqj + endif + if &history < 10000 + set history=10000 + endif + if has('extra_search') + set hlsearch + set incsearch + endif + if has('langmap') + set langnoremap + endif + set laststatus=2 + set listchars="tab:> ,trail:-,nbsp:+" + if has('mouse') + set mouse=a + endif + "set nocompatible + set nrformats=hex + if has('mksession') + set sessionoptions+=options + endif + set smarttab + if has('windows') + set tabpagemax=50 + endif + set tags="./tags;,tags" + set ttyfast + if has('viminfo') + set viminfo+=! + endif + if has('wildmenu') + set wildmenu + endif + + " options that have been removed from neovim + if v:version >= 704 + set cryptmethod=blowfish + + au BufReadPost * if &key != "" | set noswapfile nowritebackup viminfo= nobackup noshelltemp history=0 secure | endif + endif +endif diff --git a/core/mappings.vim b/core/mappings.vim new file mode 100644 index 0000000..be4fe2f --- /dev/null +++ b/core/mappings.vim @@ -0,0 +1,63 @@ +let g:mapleader = "," + +command! Wq wq +command! WQ wq +command! Q q +command! W w + +nnoremap U :redo +nnoremap + +" allow explicit writing of read-only files with sudo +cnoremap sudow w !sudo tee % >/dev/null + +" unset search highlighting +noremap :noh + +nnoremap vl :setlocal cursorline! +nnoremap vc :setlocal cursorcolumn! +nnoremap ve :setlocal colorcolumn=80 +nnoremap vn :setlocal colorcolumn=0 + +nnoremap Y y$ +nnoremap j gj +nnoremap k gk + +" unset default help shortcut +nnoremap +inoremap + +inoremap jk +inoremap JK +inoremap Jk + +vnoremap < >gv + +" fix indentation of an entire file +nnoremap fmt gg=G`` + +" local replace +nnoremap gr gd[{V%::s////g +nnoremap gR gD:%s////g + +if v:progname == 'nvim' + tnoremap +endif + +" highlight searches and search while typing +if has('extra_search') + if maparg('', 'n') ==# '' + nnoremap :nohlsearch + endif +endif + +nnoremap th :tabfirst +nnoremap tj :tabnext +nnoremap tk :tabprev +nnoremap tl :tablast +nnoremap tn :tabnew +nnoremap tq :tabclose + +nnoremap il :set invlist +vnoremap il :set invlist diff --git a/core/plugins.vim b/core/plugins.vim index afb4bce..d0a98f5 100644 --- a/core/plugins.vim +++ b/core/plugins.vim @@ -1,31 +1,37 @@ call plug#begin(g:vim_data_home . '/plugins') -" Always load +" always load Plug 'scrooloose/nerdcommenter' -Plug 'scrooloose/syntastic' -Plug 'jiangmiao/auto-pairs' -Plug 'majutsushi/tagbar' +Plug 'majutsushi/tagbar' Plug 'kien/ctrlp.vim' Plug 'vim-scripts/gnupg' - Plug 'tomasr/molokai' +Plug 'hoelzro/vim-polyglot' +Plug 'bling/vim-airline' "until powerline works in neovim Plug 'junegunn/seoul256.vim' -Plug 'baeuml/summerfruit256.vim' -"Plug 'zefei/vim-colortuner', { 'on': 'Colortuner' } -Plug 'godlygeek/csapprox' +"Plug 'godlygeek/csapprox' +"Plug 'jiangmiao/auto-pairs' +"Plug 'tpope/vim-commentary' -Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' } -Plug 'scrooloose/nerdtree-git-plugin', { 'on': 'NERDTreeToggle' } +" on demand loading +Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' } +Plug 'scrooloose/nerdtree-git-plugin', { 'on': 'NERDTreeToggle' } + +"Plug 'Twinside/vim-hoogle', { 'for': 'haskell' } +"Plug 'Twinside/vim-haskellConceal', { 'for': 'haskell' } +"Plug 'lukerandall/haskellmode-vim', { 'for': 'haskell' } + +Plug 'scrooloose/syntastic', {'for': ['c', 'cpp', 'python', 'sh']} if v:version >= 704 -Plug 'vim-pandoc/vim-pandoc' -Plug 'vim-pandoc/vim-pandoc-syntax' -Plug 'Valloric/YouCompleteMe', { 'do': './install.sh --clang-completer --system-libclang' } + Plug 'vim-pandoc/vim-pandoc' + Plug 'vim-pandoc/vim-pandoc-syntax' + Plug 'Valloric/YouCompleteMe', {'do': 'python2 install.py --clang-completer' } endif if v:version >= 703 -Plug 'vim-scripts/Gundo', { 'on': 'GundoToggle' } + Plug 'vim-scripts/Gundo', { 'on': 'GundoToggle' } endif call plug#end() diff --git a/core/search.vim b/core/search.vim deleted file mode 100644 index 5e4a900..0000000 --- a/core/search.vim +++ /dev/null @@ -1,16 +0,0 @@ -set ignorecase -set smartcase - -" highlight searches and search while typing -if has('extra_search') - set hlsearch - set incsearch - if maparg('', 'n') ==# '' - nnoremap :nohlsearch - endif -endif - -" load the matchit macros -if !exists('g:loaded_matchit') && findfile('plugins/matchit.vim', &rtp) ==# '' - runtime! macros/matchit.vim -endif diff --git a/core/settings.vim b/core/settings.vim new file mode 100644 index 0000000..96aa762 --- /dev/null +++ b/core/settings.vim @@ -0,0 +1,104 @@ +set confirm +set ttimeout +set timeoutlen=500 +set autochdir +set autowrite +set scrolloff=1 +set sidescrolloff=5 +set number +set ignorecase +set smartcase +set listchars=tab:»\ ,trail:◆,extends:▹,precedes:◃,eol:↲,nbsp:· +set showmatch +set shortmess=aoOtTI + +if has('smartindent') + set smartindent +endif + +" enable filetype plugins +if has('autocmd') + filetype indent on + filetype plugin on +endif + + +"if !exists('g:loaded_matchit') && findfile('plugins/matchit.vim', &rtp) ==# '' +"runtime! macros/matchit.vim +"endif + +if has('windows') + set splitbelow + set splitright +endif + +if has('linebreak') + let &showbreak = '↳ ' + + if v:version >=704 + set breakindent + set breakindentopt=sbr + endif +endif + +if has('cmdline_info') + set ruler + set showcmd +endif + +if has('wildmenu') + set wildmode=list:longest,full + set wildignore=.bak,.old,.swp,~ +endif + +if has('virtualedit') + set virtualedit=block +endif + +if has('syntax') + syntax enable +endif + +aug CursorLineColumn + au! + au VimEnter,WinEnter,BufWinEnter * setlocal cursorline cursorcolumn + au WinLeave * setlocal nocursorline nocursorcolumn +aug END + +"set visualbell +"set t_vb= + +if has('folding') + 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 +endif diff --git a/core/tabs.vim b/core/tabs.vim deleted file mode 100644 index cd9ec2f..0000000 --- a/core/tabs.vim +++ /dev/null @@ -1,11 +0,0 @@ -nnoremap th :tabfirst -nnoremap tj :tabnext -nnoremap tk :tabprev -nnoremap tl :tablast -nnoremap tn :tabnew -nnoremap tq :tabclose - -" increase the maximal number of tabpages (default 10) -if &tabpagemax < 50 - set tabpagemax=50 -endif diff --git a/core/tmux.vim b/core/tmux.vim new file mode 100644 index 0000000..f2f400f --- /dev/null +++ b/core/tmux.vim @@ -0,0 +1,25 @@ +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 diff --git a/core/window.vim b/core/window.vim deleted file mode 100644 index ca8d6bb..0000000 --- a/core/window.vim +++ /dev/null @@ -1,102 +0,0 @@ -" split the windows more 'naturally' -if has('windows') - set splitbelow - set splitright - set showtabline=2 -endif - - -" set scroll offset slightly higher so that the next or previous line can be seen -if !&scrolloff - set scrolloff=1 -endif - -" same as with scroll offset but for horizontal scrolling -if !&sidescrolloff - set sidescrolloff=5 -endif - -set number - -if v:version >= 704 - aug LineNumbers - au! - au VimEnter,WinEnter,InsertLeave * setlocal relativenumber - au WinLeave,InsertEnter * setlocal norelativenumber - aug END -endif - -if has('linebreak') - let &showbreak = '↳ ' - if v:version >=704 - set breakindent - set breakindentopt=sbr - endif -endif - -" show a ruler and show the current command in the bottom right -if has('cmdline_info') - set ruler - set showcmd -endif - -" show invisible characters -set listchars=tab:»\ ,trail:◆,extends:▹,precedes:◃,eol:↲,nbsp:· - -nnoremap il :set invlist -vnoremap il :set invlist - -if has('wildmenu') - set wildmenu - set wildmode=list:longest,full - set wildignore=.bak,.old,.swp,~ -endif - -" maximum height of a popup menu -set pumheight=10 - -" allow the cursor to be positioned where no characters are in virtual block mode -if has('virtualedit') - set virtualedit=block -endif - -" enable syntax highlighting -if has('syntax') - syntax enable -endif - -" set via $LANG -"if has('multi_byte') -"set encoding=utf-8 -"set termencoding=utf-8 -"endif - -" always show a status line -set laststatus=2 - -" show as much as possible of the last line -set display+=lastline - -" show matching brackets -set showmatch -set matchtime=2 - -" shorten some messages -set shortmess=aoOtTI - -" set the terminal colors to 256 if not in a VT -if exists($TERM) - if &t_Co == 8 && $TERM !~# '^linux' - set t_Co=256 - endif -endif - -aug CursorLineColumn - au! - au VimEnter,WinEnter,BufWinEnter * setlocal cursorline cursorcolumn - au WinLeave * setlocal nocursorline nocursorcolumn -aug END - -" disable visualbell -set visualbell -set t_vb=