let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.vim' if empty(glob(data_dir . '/autoload/plug.vim')) silent execute '!curl -fLo '.data_dir.'/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim' endif autocmd VimEnter * if len(filter(values(g:plugs), '!isdirectory(v:val.dir)')) \| PlugInstall --sync | source $MYVIMRC \| endif call plug#begin('~/.vim/plugged') Plug 'tpope/vim-surround' Plug 'jiangmiao/auto-pairs' Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } Plug 'junegunn/fzf.vim' Plug 'mtdl9/vim-log-highlighting' Plug 'machakann/vim-highlightedyank' Plug 'osyo-manga/vim-anzu' call plug#end() let mapleader = "\" set background=dark if has('termguicolors') set termguicolors endif silent! colorscheme anticuus highlight Normal ctermbg=NONE guibg=NONE ctermfg=White guifg=#FFFFFF highlight NonText ctermbg=NONE guibg=NONE highlight CursorLine ctermbg=NONE guibg=NONE highlight CursorLineNr ctermfg=Yellow guifg=#E5C07B ctermbg=NONE guibg=NONE cterm=bold gui=bold highlight HighlightedyankRegion ctermfg=Black guifg=#000000 ctermbg=Yellow guibg=yellow highlight NormalNC ctermbg=NONE guibg=NONE highlight Search ctermfg=Black guifg=#000000 ctermbg=Yellow guibg=#FFCC66 highlight LineNr ctermbg=NONE guibg=NONE highlight Visual ctermbg=Gray guibg=Gray ctermfg=Black guifg=Black let g:highlightedyank_highlight_duration = 140 let $FZF_DEFAULT_OPTS = '--bind=tab:up,shift-tab:down' let g:fzf_layout = { 'window': 'enew' } " netrw settings let g:netrw_banner = 0 let g:netrw_winsize = 20 let g:netrw_liststyle = 3 let g:netrw_browse_split = 4 let g:netrw_altv = 1 autocmd FileType netrw nnoremap :wincmd l autocmd FileType netrw nnoremap :wincmd h autocmd FileType netrw nnoremap :wincmd j autocmd FileType netrw nnoremap :wincmd k set laststatus=2 set number set relativenumber set cursorline set scrolloff=8 set noincsearch set ignorecase set smartcase set clipboard=unnamedplus set noswapfile set nobackup set undofile set undodir=~/.vim/undodir set hidden set tabstop=2 set shiftwidth=2 set softtabstop=2 set expandtab set smartindent set fillchars=eob:\ set statusline=%{exists('*anzu#search_status')?anzu#search_status():''} " --- Netrw toggle (like neo-tree) --- function! NetrwToggle() for i in range(1, winnr('$')) if getbufvar(winbufnr(i), '&filetype') ==# 'netrw' execute i . 'wincmd w' close return endif endfor let g:netrw_return_win = winnr() Lexplore endfunction function! SafeWincmd(dir) let target = winnr(a:dir) if target == winnr() return endif if getbufvar(winbufnr(target), '&filetype') ==# 'netrw' return endif execute 'wincmd ' . a:dir endfunction function! GitRoot() let l:root = systemlist('git rev-parse --show-toplevel') if v:shell_error == 0 && !empty(l:root) && !empty(l:root[0]) return l:root[0] endif return getcwd() endfunction function! SafeBdelete() if &filetype ==# 'netrw' echohl WarningMsg | echom 'Cannot delete buffer from netrw' | echohl None return endif let l:buflisted = getbufinfo({'buflisted': 1}) if len(l:buflisted) <= 1 echohl WarningMsg | echom 'Cannot delete last buffer' | echohl None return endif let l:buf = bufnr('%') bprevious execute 'bdelete ' . l:buf endfunction " --- Plugin management --- nnoremap pu :PlugUpdate nnoremap pd :PlugUpgrade nnoremap ps :PlugStatus nnoremap pi :PlugInstall " --- Search (anzu) --- nmap n (anzu-n-with-echo) nmap N (anzu-N-with-echo) nmap * (anzu-star-with-echo) nmap # (anzu-sharp-with-echo) nmap (anzu-clear-search-status) nnoremap :nohlet @/="" " --- Visual indentation --- vnoremap < >gv " --- Scrolling (centered) --- nnoremap zz nnoremap zz " --- Window navigation (matches nvim , skips netrw) --- nnoremap :call SafeWincmd('h') nnoremap :call SafeWincmd('j') nnoremap :call SafeWincmd('k') nnoremap :call SafeWincmd('l') " --- Window resize (matches nvim ) --- nnoremap :vertical resize +10 nnoremap :vertical resize -10 nnoremap :resize +10 nnoremap :resize -10 " --- Window management --- nnoremap wc :close nnoremap ws :split nnoremap wv :vsplit nnoremap wm _ nnoremap ww :wincmd w nnoremap wW :wincmd W " --- File explorer & search --- nnoremap e :call NetrwToggle() nnoremap / :execute 'lcd ' . fnameescape(GitRoot()) Rg nnoremap ff :execute 'lcd ' . fnameescape(GitRoot()) Files nnoremap fp :History nnoremap fb :Buffers nnoremap ? :History: " --- Buffers --- nnoremap bd :call SafeBdelete() nnoremap H :bprevious nnoremap L :bnext " --- Terminal --- nnoremap t :below terminal ++rows=10 " --- Misc --- nnoremap ts :execute "normal! a" . strftime('[%b %d %H:%M:%S - BR]')