diff --git a/init.vim b/init.vim index c401752..9156bc3 100644 --- a/init.vim +++ b/init.vim @@ -1,14 +1,10 @@ -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" " -" Maintainer: Patrick Auernig " -" VIM Version: NVIM 0.1.3 " -" " -""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" Maintainer: Patrick Auernig +" VIM Version: NVIM 0.1.4 +" Source: https://gitlab.com/valeth/vim-config +" Mirror: https://github.com/valeth/vim-config -""""""""""""""""""" -" XDG Directories " -""""""""""""""""""" +" XDG Directories {{{ let g:vim_config_home = split(&rtp, ',', 0)[0] if exists('$XDG_CACHE_HOME') @@ -22,53 +18,102 @@ if exists('$XDG_DATA_HOME') else let g:vim_data_home = expand('$HOME/.local/share/') . v:progname endif +" }}} +" Settings {{{ -"""""""""""" -" Settings " -"""""""""""" +" prompt with save dialog on exit set confirm + +" wait only a short amount of time +set notimeout set ttimeout -set timeoutlen=500 +set timeoutlen=10 +set visualbell t_vb= + +" automatically do stuff set autochdir -set autowrite -set scrolloff=1 +set autoread +set autowriteall + +" scroll n lines before hitting the border +set scrolloff=3 set sidescrolloff=5 + +" show line numbers set number + +" show position +set ruler + +" ignore case when searching set ignorecase set smartcase -set listchars=tab:»\ ,trail:◆,extends:▹,precedes:◃,eol:↲,nbsp:· +set incsearch +set gdefault + +" show matching parenthesis set showmatch -set shortmess=aoOtTI -set clipboard+=unnamed -set smartindent -set undofile -set splitbelow -set splitright +set matchtime=3 + + +" show hidden characters +set listchars=tab:»\ ,trail:◆,extends:❯,precedes:❮,eol:↲,nbsp:· set breakindent set breakindentopt=sbr -let &showbreak = '↳ ' -set ruler -set showcmd +set showbreak=↳ +set list + +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 wildignore=.bak,.old,.swp,~ -set virtualedit=block +set wildignore+=.git +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 foldlevel=99 set foldmethod=syntax 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 plugin on syntax enable +set synmaxcol=300 +" }}} - -""""""""""""""""""""" -" Keyboard mappings " -""""""""""""""""""""" +" Keyboard mappings {{{ let g:mapleader = "," +let g:maplocalleader = "\\" command! Wq wq command! WQ wq @@ -77,7 +122,6 @@ command! W w noremap :noh -nnoremap nnoremap U :redo nnoremap nnoremap vl :setlocal cursorline! @@ -97,61 +141,121 @@ nnoremap tk :tabprev nnoremap tl :tablast nnoremap tn :tabnew nnoremap tq :tabclose -nnoremap il :set invlist -inoremap +nnoremap o + +" change beginning and end mappings +noremap H ^ +noremap L $ +vnoremap L g_ +inoremap I +inoremap A +cnoremap +cnoremap + +" 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 zz + +" toggle invlist +nnoremap il :set invlist +vnoremap il :set invlist + +" make substitutions more convenient +nnoremap :%s/ +vnoremap :s/ + +nnoremap / /\v +vnoremap / /\v + +" quicker escape inoremap jk inoremap JK inoremap Jk +" indent in visual mode and keep selection vnoremap < >gv -vnoremap il :set invlist -cnoremap sudow w !sudo tee % >/dev/null +" just in case I forgot sudo again +cnoremap w! w !sudo tee % >/dev/null tnoremap +tnoremap +" NOP(E)s +noremap +noremap +noremap +noremap +noremap +" }}} -"""""""""""""""" -" Autocommands " -"""""""""""""""" -aug ToggleLineNumbers +" Autocommands {{{ +augroup LineReturn + au! + au BufReadPost * + \ if line("'\"") > 0 && line("'\"") <= line("$") | + \ execute 'normal! g`"zvzz' | + \ endif +augroup END + +augroup ToggleLineNumbers au! au VimEnter,WinEnter,InsertLeave * setlocal relativenumber au WinLeave,InsertEnter * setlocal norelativenumber -aug END +augroup END -aug CursorLineColumn +augroup CursorLineColumn au! au VimEnter,WinEnter,BufWinEnter * setlocal cursorline cursorcolumn au WinLeave * setlocal nocursorline nocursorcolumn -aug END +augroup END augroup AutoReload au! au BufWritePost $MYVIMRC source $MYVIMRC augroup END +au FocusLost * :silent! wa -""""""""""" -" Plugins " -""""""""""" +" keep splits equal on terminal resize +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') runtime! plugins/**/*.vim call plug#end() +" }}} - -""""""""""""""" -" Colorscheme " -""""""""""""""" +" Colorscheme {{{ function! ToggleColorscheme() - if g:colors_name == 'PaperColor' - call ToggleBackground() - elseif g:colors_name =~ 'seoul256' + if g:colors_name =~ 'seoul256' call ToggleSeoul256() elseif g:colors_name =~ 'Tomorrow' call ToggleTomorrow() + else + call ToggleBackground() endif AirlineRefresh @@ -169,4 +273,6 @@ endfunction colorscheme seoul256 "colorscheme PaperColor "colorscheme Tomorrow-Night +" }}} +" vim:set foldmethod=marker foldlevel=0: