1
0

restructure core config

This commit is contained in:
valeth 2015-11-06 09:02:22 +01:00
parent 8e8df6ad01
commit e3e4df0277
13 changed files with 282 additions and 295 deletions

View File

@ -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<CR>
nnoremap <C-R> <NOP>
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

17
core/compat.vim Normal file
View File

@ -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

View File

@ -1,45 +0,0 @@
nnoremap Y y$
nnoremap j gj
nnoremap k gk
inoremap jk <ESC>
inoremap JK <ESC>
inoremap Jk <ESC>
set ttimeout
" lower timeout
set ttimeoutlen=-1
set timeoutlen=500
" unset default help shortcut
nnoremap <F1> <NOP>
inoremap <F1> <NOP>
let g:mapleader = ","
" unset search highlighting
noremap <silent> <Leader><CR> :noh<CR>
nnoremap <Leader>vl :setlocal cursorline!<CR>
nnoremap <Leader>vc :setlocal cursorcolumn!<CR>
nnoremap <Leader>ve :setlocal colorcolumn=80<CR>
nnoremap <Leader>vn :setlocal colorcolumn=0<CR>
" 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

View File

@ -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

View File

@ -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
vnoremap > >gv
" fix indentation of an entire file
nnoremap <leader>fmt gg=G<CR>``
" local replace
nnoremap gr gd[{V%::s/<C-R>///g<left><left>
nnoremap gR gD:%s/<C-R>///g<left><left>

53
core/legacy.vim Normal file
View File

@ -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

63
core/mappings.vim Normal file
View File

@ -0,0 +1,63 @@
let g:mapleader = ","
command! Wq wq
command! WQ wq
command! Q q
command! W w
nnoremap U :redo<CR>
nnoremap <C-R> <NOP>
" allow explicit writing of read-only files with sudo
cnoremap sudow w !sudo tee % >/dev/null
" unset search highlighting
noremap <silent> <Leader><CR> :noh<CR>
nnoremap <Leader>vl :setlocal cursorline!<CR>
nnoremap <Leader>vc :setlocal cursorcolumn!<CR>
nnoremap <Leader>ve :setlocal colorcolumn=80<CR>
nnoremap <Leader>vn :setlocal colorcolumn=0<CR>
nnoremap Y y$
nnoremap j gj
nnoremap k gk
" unset default help shortcut
nnoremap <F1> <NOP>
inoremap <F1> <NOP>
inoremap jk <ESC>
inoremap JK <ESC>
inoremap Jk <ESC>
vnoremap < <gv
vnoremap > >gv
" fix indentation of an entire file
nnoremap <leader>fmt gg=G<CR>``
" local replace
nnoremap gr gd[{V%::s/<C-R>///g<left><left>
nnoremap gR gD:%s/<C-R>///g<left><left>
if v:progname == 'nvim'
tnoremap <ESC> <C-\><C-n>
endif
" highlight searches and search while typing
if has('extra_search')
if maparg('<C-L>', 'n') ==# ''
nnoremap <silent><C-L> :nohlsearch<CR><C-L>
endif
endif
nnoremap th :tabfirst<CR>
nnoremap tj :tabnext<CR>
nnoremap tk :tabprev<CR>
nnoremap tl :tablast<CR>
nnoremap tn :tabnew<CR>
nnoremap tq :tabclose<CR>
nnoremap <silent> <leader>il :set invlist<CR>
vnoremap <silent> <leader>il :<C-W>set invlist<CR>

View File

@ -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()

View File

@ -1,16 +0,0 @@
set ignorecase
set smartcase
" highlight searches and search while typing
if has('extra_search')
set hlsearch
set incsearch
if maparg('<C-L>', 'n') ==# ''
nnoremap <silent><C-L> :nohlsearch<CR><C-L>
endif
endif
" load the matchit macros
if !exists('g:loaded_matchit') && findfile('plugins/matchit.vim', &rtp) ==# ''
runtime! macros/matchit.vim
endif

104
core/settings.vim Normal file
View File

@ -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

View File

@ -1,11 +0,0 @@
nnoremap th :tabfirst<CR>
nnoremap tj :tabnext<CR>
nnoremap tk :tabprev<CR>
nnoremap tl :tablast<CR>
nnoremap tn :tabnew<CR>
nnoremap tq :tabclose<CR>
" increase the maximal number of tabpages (default 10)
if &tabpagemax < 50
set tabpagemax=50
endif

25
core/tmux.vim Normal file
View File

@ -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 = "\<Esc>]2;vim\<Esc>\\" . &t_ti
let &t_te = "\<Esc>]2;". previous_title . "\<Esc>\\" . &t_te
noremap <silent><C-h> :call TmuxOrSplitSwitch('h', 'L')<cr>
noremap <silent><C-l> :call TmuxOrSplitSwitch('l', 'R')<cr>
noremap <silent><C-k> :call TmuxOrSplitSwitch('k', 'U')<cr>
noremap <silent><C-j> :call TmuxOrSplitSwitch('j', 'D')<cr>
noremap <silent><C-b> :call TmuxOrSplitSwitch('b', 'l')<cr>
else
noremap <C-h> <C-w>h
noremap <C-j> <C-w>j
noremap <C-k> <C-w>k
noremap <C-l> <C-w>l
endif

View File

@ -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 <silent> <leader>il :set invlist<CR>
vnoremap <silent> <leader>il :<C-W>set invlist<CR>
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=