1
0

update init.vim

reorganize the file a bit
This commit is contained in:
valeth 2016-04-29 17:23:22 +02:00
parent 0fea4f25c7
commit 8b2e5aff49

216
init.vim
View File

@ -1,14 +1,10 @@
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Maintainer: Patrick Auernig <patrick DOT auernig AT gmail DOT com>
" " " VIM Version: NVIM 0.1.4
" Maintainer: Patrick Auernig <patrick DOT auernig AT gmail DOT com> " " Source: https://gitlab.com/valeth/vim-config
" VIM Version: NVIM 0.1.3 " " Mirror: https://github.com/valeth/vim-config
" "
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""""""""""""""""""" " 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')
@ -22,53 +18,102 @@ if exists('$XDG_DATA_HOME')
else 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
" }}}
" Settings {{{
"""""""""""" " prompt with save dialog on exit
" Settings "
""""""""""""
set confirm set confirm
" wait only a short amount of time
set notimeout
set ttimeout set ttimeout
set timeoutlen=500 set timeoutlen=10
set visualbell t_vb=
" automatically do stuff
set autochdir set autochdir
set autowrite set autoread
set scrolloff=1 set autowriteall
" scroll n lines before hitting the border
set scrolloff=3
set sidescrolloff=5 set sidescrolloff=5
" show line numbers
set number set number
" show position
set ruler
" ignore case when searching
set ignorecase set ignorecase
set smartcase set smartcase
set listchars=tab:»\ ,trail:◆,extends:▹,precedes:◃,eol:↲,nbsp set incsearch
set gdefault
" show matching parenthesis
set showmatch set showmatch
set shortmess=aoOtTI set matchtime=3
set clipboard+=unnamed
set smartindent
set undofile " show hidden characters
set splitbelow set listchars=tab:»\ ,trail:◆,extends:,precedes:,eol:↲,nbsp
set splitright
set breakindent set breakindent
set breakindentopt=sbr set breakindentopt=sbr
let &showbreak = '↳ ' set showbreak=
set ruler set list
set showcmd
set shortmess=aoOtTI
" share yank buffer with system clipboard
set clipboard+=unnamed
" indent automatically
set autoindent
set smartindent
set undofile
set noswapfile
" change split behaviour
set splitbelow
set splitright
" show sane line lenght limit marker
set colorcolumn=+3
" wildmenu completion
set wildmenu
set wildmode=list:longest,full set wildmode=list:longest,full
set wildignore=.bak,.old,.swp,~ set wildignore+=.git
set virtualedit=block set wildignore+=*.bak,*.old,*.swp,*~
set wildignore+=*.o,*.hi
set wildignore+=*.pyc,*.class
set wildignore+=*.pdf,*.aux
set wildignore+=*.png,*.jpg
set virtualedit+=block
set foldcolumn=1 set foldcolumn=1
set foldlevel=99 set foldlevel=99
set foldmethod=syntax set foldmethod=syntax
set foldtext=myfold#text() set foldtext=myfold#text()
set visualbell
set t_vb=
set complete=.,w,b,u,t
set completeopt=longest,menuone,preview
" enable syntax highlighting and filetype detection
filetype indent on filetype indent on
filetype plugin on filetype plugin on
syntax enable syntax enable
set synmaxcol=300
" }}}
" Keyboard mappings {{{
"""""""""""""""""""""
" Keyboard mappings "
"""""""""""""""""""""
let g:mapleader = "," let g:mapleader = ","
let g:maplocalleader = "\\"
command! Wq wq command! Wq wq
command! WQ wq command! WQ wq
@ -77,7 +122,6 @@ command! W w
noremap <silent> <Leader><CR> :noh<CR> noremap <silent> <Leader><CR> :noh<CR>
nnoremap <F1> <NOP>
nnoremap U :redo<CR> nnoremap U :redo<CR>
nnoremap <C-R> <NOP> nnoremap <C-R> <NOP>
nnoremap <Leader>vl :setlocal cursorline!<CR> nnoremap <Leader>vl :setlocal cursorline!<CR>
@ -97,61 +141,121 @@ nnoremap tk :tabprev<CR>
nnoremap tl :tablast<CR> nnoremap tl :tablast<CR>
nnoremap tn :tabnew<CR> nnoremap tn :tabnew<CR>
nnoremap tq :tabclose<CR> nnoremap tq :tabclose<CR>
nnoremap <silent> <leader>il :set invlist<CR>
inoremap <F1> <NOP> nnoremap <CR> o<ESC>
" change beginning and end mappings
noremap H ^
noremap L $
vnoremap L g_
inoremap <C-a> <ESC>I
inoremap <C-e> <ESC>A
cnoremap <C-a> <HOME>
cnoremap <C-e> <END>
" movement
noremap j gj
noremap k gk
noremap gj j
noremap gj j
" go to last change
nnoremap gC `.
" stay in center when searching
nnoremap n nzzzv
nnoremap N Nzzzv
nnoremap g; g;zz
nnoremap g, g,zz
nnoremap <C-o> <C-o>zz
" toggle invlist
nnoremap <silent> <leader>il :set invlist<CR>
vnoremap <silent> <leader>il :<C-W>set invlist<CR>
" make substitutions more convenient
nnoremap <C-s> :%s/
vnoremap <C-s> :s/
nnoremap / /\v
vnoremap / /\v
" quicker escape
inoremap jk <ESC> inoremap jk <ESC>
inoremap JK <ESC> inoremap JK <ESC>
inoremap Jk <ESC> inoremap Jk <ESC>
" indent in visual mode and keep selection
vnoremap < <gv vnoremap < <gv
vnoremap > >gv vnoremap > >gv
vnoremap <silent> <leader>il :<C-W>set invlist<CR>
cnoremap sudow w !sudo tee % >/dev/null " just in case I forgot sudo again
cnoremap w! w !sudo tee % >/dev/null
tnoremap <ESC> <C-\><C-n> tnoremap <ESC> <C-\><C-n>
tnoremap <leader><ESC> <ESC>
" NOP(E)s
noremap <F1> <NOP>
noremap <Left> <NOP>
noremap <Right> <NOP>
noremap <Up> <NOP>
noremap <Down> <NOP>
" }}}
"""""""""""""""" " Autocommands {{{
" Autocommands " augroup LineReturn
"""""""""""""""" au!
aug ToggleLineNumbers au BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ execute 'normal! g`"zvzz' |
\ endif
augroup END
augroup ToggleLineNumbers
au! au!
au VimEnter,WinEnter,InsertLeave * setlocal relativenumber au VimEnter,WinEnter,InsertLeave * setlocal relativenumber
au WinLeave,InsertEnter * setlocal norelativenumber au WinLeave,InsertEnter * setlocal norelativenumber
aug END augroup END
aug CursorLineColumn augroup CursorLineColumn
au! au!
au VimEnter,WinEnter,BufWinEnter * setlocal cursorline cursorcolumn au VimEnter,WinEnter,BufWinEnter * setlocal cursorline cursorcolumn
au WinLeave * setlocal nocursorline nocursorcolumn au WinLeave * setlocal nocursorline nocursorcolumn
aug END augroup END
augroup AutoReload augroup AutoReload
au! au!
au BufWritePost $MYVIMRC source $MYVIMRC au BufWritePost $MYVIMRC source $MYVIMRC
augroup END augroup END
au FocusLost * :silent! wa
""""""""""" " keep splits equal on terminal resize
" Plugins " au VimResized * :wincmd =
"""""""""""
augroup Trailing
au!
au InsertEnter * :set invlist
au InsertLeave * :set invlist
augroup END
" }}}
" Plugins {{{
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 "
"""""""""""""""
function! ToggleColorscheme() function! ToggleColorscheme()
if g:colors_name == 'PaperColor' if g:colors_name =~ 'seoul256'
call ToggleBackground()
elseif g:colors_name =~ 'seoul256'
call ToggleSeoul256() call ToggleSeoul256()
elseif g:colors_name =~ 'Tomorrow' elseif g:colors_name =~ 'Tomorrow'
call ToggleTomorrow() call ToggleTomorrow()
else
call ToggleBackground()
endif endif
AirlineRefresh AirlineRefresh
@ -169,4 +273,6 @@ endfunction
colorscheme seoul256 colorscheme seoul256
"colorscheme PaperColor "colorscheme PaperColor
"colorscheme Tomorrow-Night "colorscheme Tomorrow-Night
" }}}
" vim:set foldmethod=marker foldlevel=0: