""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Custom Config """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" set cursorline set number set relativenumber set showcmd set nowrap set nostartofline set sidescroll=1 set sidescrolloff=999 " general nmap :q nnoremap , :w !bash nnoremap W :set wrap! nnoremap T :vertical terminal nnoremap u :set clipboard=unnamedplus nnoremap ddkP nnoremap ddp nnoremap R :read ! " move nnoremap } nnoremap { cnoremap cnoremap nnoremap H 0 nnoremap L $ nnoremap 60l nnoremap 60h " disable syntax nnoremap s \ : if exists("syntax_on") \ syntax off \ else \ syntax enable \ endif " show current syntax nnoremap S :echo join(reverse(map(synstack(line('.'), col('.')), 'synIDattr(v:val,"name")')),' ') " Operator pending onoremap p i( onoremap ap a( " next parenthesis onoremap fp :normal! f(vi( onoremap b i{ onoremap fb :normal! f{vi{ onoremap ab a{ " block onoremap B /return " S&R nnoremap ; :%s:::g vnoremap ; :s:::g cnoremap ;\ \(\) " Fix paste bug triggered by inoremaps set t_BE= " surround with '' or "" nnoremap ' ea'bi'e nnoremap " ea"bi"e nnoremap ( ea)bi(e vnoremap ' ``>la' vnoremap " ``>la" vnoremap ( ``>la) " abbrev iabbrev @@ typebrook@gmail.com " vim_markdown let g:vim_markdown_folding_disabled = 1 let g:vim_markdown_conceal = 0 vnoremap ``>la]()i " xml fold let g:xml_syntax_folding=1 au FileType xml setlocal foldmethod=syntax """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Settings for Vimwiki """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" nnoremap tt :VimwikiTable nnoremap wg :VimwikiGoto nnoremap wa :VimwikiSearchTags nnoremap i I- l nnoremap ii I- [ ] l nmap D dd:VimwikiMakeDiaryNoteGp let g:vimwiki_list = [{'path': '~/vimwiki/', 'syntax': 'markdown', 'ext': '.md'}] " Git push quietly whenever leaving vim with VimWiki files augroup vimwikiPush autocmd! autocmd VimLeave ~/vimwiki/* :!(~/vimwiki/scripts/upload.sh > /dev/null 2>&1 &) augroup END " Configuration fro vim-instant-markdown let g:instant_markdown_autostart = 0 nnoremap md :InstantMarkdownPreview """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Redirect the output of a Vim or external command into a scratch buffer """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Copy from : https://gist.github.com/romainl/eae0a260ab9c135390c30cd370c20cd7 " " Usage: " :Redir hi ............. show the full output of command ':hi' in a scratch window " :Redir !ls -al ........ show the full output of command ':!ls -al' in a scratch window function! Redir(cmd) for win in range(1, winnr('$')) if getwinvar(win, 'scratch') execute win . 'windo close' endif endfor if a:cmd =~ '^!' let output = system(matchstr(a:cmd, '^!\zs.*')) else redir => output execute a:cmd redir END endif vnew let w:scratch = 1 setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile call setline(1, split(output, "\n")) endfunction command! -nargs=1 -complete=command Redir silent call Redir() nnoremap r :Redir """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Make Alt key works on Gnome terminal """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Solution is here: https://stackoverflow.com/questions/6778961 let c='a' while c <= 'z' exec "set =\e".c exec "imap \e".c." " let c = nr2char(1+char2nr(c)) endw set timeout ttimeoutlen=50 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => vim-racer """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" set hidden let g:racer_cmd = "~/.cargo/bin/racer" let g:racer_experimental_completer = 1 au FileType rust nmap gd (rust-def) au FileType rust nmap gs (rust-def-split) au FileType rust nmap gx (rust-def-vertical) au FileType rust nmap gd (rust-doc) """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => vim-plug """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " run :PlugInstall to install plugins call plug#begin('~/.vim/plugged') " Add indent line Plug 'Yggdroot/indentLine' Plug 'mileszs/ack.vim' Plug 'tpope/vim-surround' Plug 'lifepillar/pgsql.vim' Plug 'vimwiki/vimwiki' Plug 'iberianpig/tig-explorer.vim' Plug 'rust-lang/rust.vim' Plug 'racer-rust/vim-racer' Plug 'suan/vim-instant-markdown', {'for': 'markdown'} Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app & yarn install' } " Initialize plugin system call plug#end()