unclutter init.vim
This commit is contained in:
parent
60f3c7763a
commit
e077f353f8
148
init.vim
148
init.vim
@ -1,14 +1,14 @@
|
|||||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||||
" "
|
" "
|
||||||
" Maintainer: Patrick Auernig <patrick DOT auernig AT gmail DOT com> "
|
" Maintainer: Patrick Auernig <patrick DOT auernig AT gmail DOT com> "
|
||||||
" 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]
|
let g:vim_config_home = split(&rtp, ',', 0)[0]
|
||||||
|
|
||||||
if exists('$XDG_CACHE_HOME')
|
if exists('$XDG_CACHE_HOME')
|
||||||
@ -23,17 +23,10 @@ else
|
|||||||
let g:vim_data_home = expand('$HOME/.local/share/') . v:progname
|
let g:vim_data_home = expand('$HOME/.local/share/') . v:progname
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" automatically reload config
|
|
||||||
augroup myvimrc
|
|
||||||
au!
|
|
||||||
au BufWritePost $MYVIMRC source $MYVIMRC
|
|
||||||
augroup END
|
|
||||||
|
|
||||||
|
|
||||||
"""""""""""""""""""""""""""""""""""
|
|
||||||
" Settings: All kinds of settings "
|
|
||||||
"""""""""""""""""""""""""""""""""""
|
|
||||||
|
|
||||||
|
""""""""""""
|
||||||
|
" Settings "
|
||||||
|
""""""""""""
|
||||||
set confirm
|
set confirm
|
||||||
set ttimeout
|
set ttimeout
|
||||||
set timeoutlen=500
|
set timeoutlen=500
|
||||||
@ -60,64 +53,22 @@ set showcmd
|
|||||||
set wildmode=list:longest,full
|
set wildmode=list:longest,full
|
||||||
set wildignore=.bak,.old,.swp,~
|
set wildignore=.bak,.old,.swp,~
|
||||||
set virtualedit=block
|
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 indent on
|
||||||
filetype plugin on
|
filetype plugin on
|
||||||
syntax enable
|
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 = ","
|
let g:mapleader = ","
|
||||||
|
|
||||||
command! Wq wq
|
command! Wq wq
|
||||||
@ -161,48 +112,39 @@ cnoremap sudow w !sudo tee % >/dev/null
|
|||||||
|
|
||||||
tnoremap <ESC> <C-\><C-n>
|
tnoremap <ESC> <C-\><C-n>
|
||||||
|
|
||||||
" highlight searches and search while typing
|
|
||||||
if maparg('<C-L>', 'n') ==# ''
|
""""""""""""""""
|
||||||
nnoremap <silent><C-L> :nohlsearch<CR><C-L>
|
" Autocommands "
|
||||||
endif
|
""""""""""""""""
|
||||||
|
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)
|
" Plugins "
|
||||||
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
|
|
||||||
|
|
||||||
|
|
||||||
"""""""""""""""""""""""""""""""""""""""""
|
|
||||||
" Plugins: Plugin loading with vim-plug "
|
|
||||||
"""""""""""""""""""""""""""""""""""""""""
|
|
||||||
call plug#begin(g:vim_data_home . '/plugins')
|
call plug#begin(g:vim_data_home . '/plugins')
|
||||||
runtime! plugins/**/*.vim
|
runtime! plugins/**/*.vim
|
||||||
call plug#end()
|
call plug#end()
|
||||||
|
|
||||||
""""""""""""""""
|
|
||||||
" Colorscheme: "
|
"""""""""""""""
|
||||||
""""""""""""""""
|
" Colorscheme "
|
||||||
|
"""""""""""""""
|
||||||
"colorscheme seoul256
|
"colorscheme seoul256
|
||||||
colorscheme molokai
|
colorscheme molokai
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user