set shell=bash " ----------------------------------------------------------------------------- " plugins " ----------------------------------------------------------------------------- if ! filereadable(expand('~/.config/nvim/autoload/plug.vim')) echo "Downloading junegunn/vim-plug to manage plugins..." silent !mkdir -p ~/.config/nvim/autoload/ silent !curl "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim" > ~/.config/nvim/autoload/plug.vim endif let g:coc_global_extensions = [ \ 'coc-fzf-preview', \ 'coc-python', \ 'coc-git', \ 'coc-tsserver', \ 'coc-diagnostic', \ 'coc-yaml' \ ] call plug#begin('~/.config/nvim/plugged') " tools Plug 'neoclide/coc.nvim', {'branch': 'release'} Plug 'junegunn/fzf', {'dir': '~/.fzf', 'do': './install --all'} "Plug 'junegunn/fzf.vim' Plug 'sheerun/vim-polyglot' " language syntax Plug 'godlygeek/tabular' " help aligning text on tabs Plug 'tpope/vim-fugitive' " markdown Plug 'iamcco/markdown-preview.nvim', { 'do': { -> mkdp#util#install() } } Plug 'plasticboy/vim-markdown' " markdown helper. Plug 'ferrine/md-img-paste.vim' " helpers Plug 'scrooloose/nerdcommenter' " commenting tool Plug 'tpope/vim-surround' " parentheses helper Plug 'mbbill/undotree' " Persistent undo Plug 'junegunn/vim-peekaboo' " show paste buffers Plug 'farmergreg/vim-lastplace' " When reopen a buffer, puts the cursor where it was last time Plug 'christoomey/vim-tmux-navigator' " integrate movement in tmux and vim Plug 'haya14busa/vim-asterisk' " better asterisk motions Plug 'bfredl/nvim-miniyank' " nvim bugfix block copy "Plug 'terryma/vim-multiple-cursors' " multiple cursors via 'C-n' "Plug 'michaeljsmith/vim-indent-object' " define indent as a group to operate on "Plug 'liuchengxu/vim-which-key' " popuup for shortcuts like emacs " aesthetics Plug 'chriskempson/base16-vim' " base16 themes Plug 'junegunn/goyo.vim' " zen mode Plug 'junegunn/limelight.vim' " highlight current paragraph Plug 'PotatoesMaster/i3-vim-syntax' " syntax highlighting for i3 file Plug 'chrisbra/Colorizer' " show color codes Plug 'junegunn/rainbow_parentheses.vim' " colorize parentheses " file mgmt Plug 'jeetsukumaran/vim-buffergator' Plug 'scrooloose/nerdtree' "Plug 'tiagofumo/vim-nerdtree-syntax-highlight' "Plug 'vifm/vifm.vim' "Plug 'rafaqz/ranger.vim' " themes Plug 'vim-airline/vim-airline' Plug 'vim-airline/vim-airline-themes' Plug 'junegunn/seoul256.vim' call plug#end() " ----------------------------------------------------------------------------- " format " ----------------------------------------------------------------------------- set t_Co=256 " Use 256 colors if filereadable(expand("~/.vimrc_background")) let base16colorspace=256 source ~/.vimrc_background endif if has("nvim") if $TERM =~ '^\(rxvt\)\(-.*\)\?$' set notermguicolors else set termguicolors endif endif "let g:airline_theme='molokai' let g:airline_theme='qwq' "let g:airline_theme='badwolf' "let g:airline_theme='silver' "let g:airline_theme='raven' " Transparent Background (For i3 and compton) highlight Normal guibg=NONE ctermbg=NONE highlight LineNr guibg=NONE ctermbg=NONE " ----------------------------------------------------------------------------- " settings " ----------------------------------------------------------------------------- " general set cmdheight=2 " height of command bar at the bottom. 1 is default let g:BASH_Ctrl_j='off' " avoid 'C-j' being overridden to newline let g:BASH_Ctrl_l='off' " avoid 'C-l' being overridden to newline set updatetime=300 set timeoutlen=500 set lazyredraw set shell=/usr/bin/bash let $SHELL = "/usr/bin/bash" set conceallevel=2 " fold config set foldmethod=indent set foldlevelstart=20 " zm/M zr/R increase/increase foldlevel (max) " zo/O zc/C open / close fold (max) " za zA switch fold (small/full) " zi toggle folds " zi zj move to next / prev fold " indentation set ai " auto indent set si " smart indent " Automatically deletes all trailing whitespace on save. autocmd BufWritePre * %s/\s\+$//e " default new file is markdown autocmd BufEnter * if &filetype == "" | setlocal ft=markdown | endif set tabstop=4 set softtabstop=4 set shiftwidth=4 set fileformat=unix au Filetype python set \ tabstop=4 \ softtabstop=4 \ shiftwidth=4 au Filetype markdown,yaml set \ tabstop=2 \ softtabstop=2 \ shiftwidth=2 set expandtab " " Disables automatic commenting on newline: "autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o " ----------------------------------------------------------------------------- " keybinds " ----------------------------------------------------------------------------- " general let mapleader="\" let maplocalleader="," "nmap :WhichKey '' tmap nmap :noh if has('nvim') nmap R :so ~/.config/nvim/init.vim nmap E :tabe ~/.config/nvim/init.vim else nmap R :so ~/.vimrc nmap E :tabe ~/.vimrc endif map q: nmap Q map p (miniyank-autoput) map P (miniyank-autoPut) " search for selected text in visual mode vnoremap // y/" " exit terminal :tnoremap " keep selection after indenting nmap >>_ nmap <<_ vmap >gv vmap :TmuxNavigateLeft nmap :TmuxNavigateDown nmap :TmuxNavigateUp nmap :TmuxNavigateRight " make splits and tabs nmap :vsplit nmap - :split nmap o :tabnew % " resize windows with hjkl nmap < nmap - nmap + nmap > " other C-w commands to remember " BAR maximise " = equalize sizes " T move buffer to new tab " move windows with +HJKL " H " J " K " L " remove buffer nmap d :bpspbnbd " nmap q :bd " fullscreen mode and reset map :Goyo map = map map _ " tab management nmap h :tabprevious nmap l :tabnext nmap :call MoveToNextTab() nmap :call MoveToPrevTab() nmap :execute 'silent! tabmove ' . (tabpagenr()-2) nmap :execute 'silent! tabmove ' . (tabpagenr()+1) " fzf "nmap g :GitFiles "nmap f :Files "nmap l :Ag "nmap L :Lines "nmap r :Rg "nmap b :Buffers "nmap c :Commands "nmap t :Colors "nmap m :Marks "nmap w :Windows "nmap :Maps nmap :CocCommand fzf-preview.ProjectGrep xmap "sy:CocCommand fzf-preview.ProjectGrep-F"=substitute(substitute(@s, '\n', '', 'g'), '/', '\\/', 'g')" nmap :CocCommand fzf-preview.ProjectGrep nmap :CocCommand fzf-preview.Lines --add-fzf-arg=--no-sort --add-fzf-arg=--query="'" nmap :CocCommand fzf-preview.Lines --add-fzf-arg=--no-sort --add-fzf-arg=--query="'=expand('')" nmap :CocCommand fzf-preview.MruFiles nmap :CocCommand fzf-preview.ProjectMruFiles nmap :CocCommand fzf-preview.DirectoryFiles nmap :CocCommand fzf-preview.ProjectFiles nmap :CocCommand fzf-preview.GitStatus nmap :CocCommand fzf-preview.GitActions nmap :CocCommand fzf-preview.Buffers nmap :CocCommand fzf-preview.AllBuffers " Close preview window when completion is done autocmd! CompleteDone * if pumvisible() == 0 | pclose | endif " coc menus imap \ pumvisible() ? "\" : \ check_back_space() ? "\" : \ coc#refresh() imap pumvisible() ? "\" : "\" imap coc#refresh() " coc helpers nmap gP (coc-diagnostic-prev) nmap gp (coc-diagnostic-next) nmap gd (coc-definition) nmap gy (coc-type-definition) nmap gi (coc-implementation) nmap gr (coc-references) nmap gR (coc-refactor) " coc git nmap gn (coc-git-nextchunk) nmap gp (coc-git-prevchunk) nmap g (coc-git-chunkinfo) nmap gs :CocCommand git.chunkStage vmap gs :CocCommand git.chunkStage nmap gX :CocCommand git.chunkUndo vmap gX :CocCommand git.chunkUndo " vim-fugitive " g? for fugitive help. :Gdiff, :Gblame, :Gstats '=' expand, '-' add/reset changes, :Gcommit % to commit current file with messag nmap gg :vertical Gstatus:vertical resize 60 " nerdtree map :NERDTreeToggle " nerdcommenter " 'c ', 'cl' aligned and 'cu>' remove " vim-surround " Visual: 'SA' to wrap in A. Surround: 'csAB' to change from A to B, 'dsA' to remove A. Word: 'ysiwA' to wrap with A " tabular " line up selected text by :Tabularize /[identifier] " vim markdown " vim asterisk map * (asterisk-*) map # (asterisk-#) map g* (asterisk-g*) map g# (asterisk-g#) map z* (asterisk-z*) map gz* (asterisk-gz*) map z# (asterisk-z#) map gz# (asterisk-gz#) " buffergator map :BuffergatorToggle map :BuffergatorTabsToggle nmap j :BuffergatorMruCyclePrev nmap k :BuffergatorMruCycleNext " ----------------------------------------------------------------------------- " plugin config " ----------------------------------------------------------------------------- " tmux navigator let g:tmux_navigator_no_mappings=1 " undotree defaults set undodir=~/.vim/undo/ " Goyo plugin makes text more readable when writing prose: let g:goyo_width=120 let g:goyo_height=85 let g:goyo_linenr=1 function! s:goyo_enter() Limelight endfunction function! s:goyo_leave() highlight Normal guibg=NONE ctermbg=NONE highlight LineNr guibg=NONE ctermbg=NONE Limelight! endfunction autocmd! User GoyoEnter nested call goyo_enter() autocmd! User GoyoLeave nested call goyo_leave() " Limelight let g:limelight_conceal_ctermfg='gray' " Color name (:help cterm-colors) or ANSI code let g:limelight_conceal_guifg='DarkGray' " Color name (:help gui-colors) or RGB color let g:limelight_default_coefficient=0.7 let g:limelight_paragraph_span=0 " Number of preceding/following paragraphs to include (default: 0) let g:limelight_priority=-1 " Highlighting priority (default: 10). Set it to -1 not to overrule hlsearch let g:limelight_bop='^\n^' let g:limelight_eop='\ze\n\n' " NerdTree " Nerd tree autostart if empty " autocmd vimenter * NERDTree "autocmd StdinReadPre * let s:std_in=1 "autocmd VimEnter * if argc() == 1 && isdirectory(argv()[0]) && !exists("s:std_in") | exe 'NERDTree' argv()[0] | wincmd p | ene | exe 'cd '.argv()[0] | endif "autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif " Nerd tree binding "autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif " Airline let g:airline#extensions#tabline#enabled=1 let g:airline#extensions#tabline#show_splits=0 "let g:airline#extensions#tabline#show_tabs=0 let g:airline#extensions#tabline#show_buffers = 0 let g:airline#extensions#tabline#switch_buffers_and_tabs=0 let g:airline_powerline_fonts=1 " vim-markdown let g:vim_markdown_new_list_item_indent=0 let g:vim_markdown_conceal=0 let g:vim_markdown_conceal_code_blocks=0 let g:vim_markdown_math=1 let g:vim_markdown_folding_disabled=0 let g:vim_markdown_math=0 " markdown preview let g:mkdp_auto_start=0 " auto start on moving into let g:mkdp_auto_close=0 " auto close on moving away let g:mkdp_open_to_the_world=0 " available to others let g:mkdp_open_ip='' " use custom IP to open preview page let g:mkdp_preview_options={ \ 'disable_sync_scroll': 0, \ 'sync_scroll_type': 'middle', \ 'hide_yaml_meta': 1 \ } " disable_sync_scroll: if disable sync scroll, default 0 " sync_scroll_type: 'middle', 'top' or 'relative' " hide_yaml_meta: if hide yaml metadata, default is 1 " md-img-paste autocmd FileType markdown nmap p :call mdip#MarkdownClipboardImage() " peekaboo let g:peekaboo_window='vert bo 80new' let g:peekaboo_delay=1000 let g:peekaboo_compact=0 " coc function! s:check_back_space() abort let col=col('.') - 1 return !col || getline('.')[col - 1] =~# '\s' endfunction nmap K :call show_documentation() let g:coc_node_path = '/usr/bin/node' let g:fzf_preview_command = 'bat --color=always --plain {-1}' " Installed bat let g:fzf_preview_grep_cmd = 'rg --smart-case --line-number --no-heading --color=never' " vim asterisk let g:asterisk#keeppos = 1 " buffgator let g:buffergator_mru_cycle_loop = 0 let g:buffergator_suppress_keymaps = 1 let g:buffergator_autoupdate = 1 let g:buffergator_sort_regime = 'mru' let g:buffergator_display_regime = 'basename' let g:buffergator_autodismiss_on_select = 0 " ----------------------------------------------------------------------------- " functions " ----------------------------------------------------------------------------- " coc " show documentation in preview window function! s:show_documentation() if (index(['vim','help'], &filetype) >= 0) execute 'h '.expand('') else call CocAction('doHover') endif endfunction " for moving of tabs if !exists("*MoveToPrevTab") function MoveToPrevTab() "there is only one window if tabpagenr('$') == 1 && winnr('$') == 1 return endif "preparing new window let l:tab_nr=tabpagenr('$') let l:cur_buf=bufnr('%') if tabpagenr() != 1 close! if l:tab_nr == tabpagenr('$') tabprev endif sp else close! exe "0tabnew" endif "opening current buffer in new window exe "b".l:cur_buf endfunc endif if !exists("*MoveToNextTab()") function MoveToNextTab() "there is only one window if tabpagenr('$') == 1 && winnr('$') == 1 return endif "preparing new window let l:tab_nr=tabpagenr('$') let l:cur_buf=bufnr('%') if tabpagenr() < tab_nr close! if l:tab_nr == tabpagenr('$') tabnext endif sp else close! tabnew endif "opening current buffer in new window exe "b".l:cur_buf endfunc endif " ----------------------------------------------------------------------------- " default settings config " ----------------------------------------------------------------------------- " default.vim - Better vim than the default " Maintainer: Liu-Cheng Xu " Version: 1.0 " vim: et ts=2 sts=2 sw=2 set shortmess=atOI " No help Uganda information, and overwrite read messages to avoid PRESS ENTER prompts set ignorecase " Case insensitive search set wildignorecase set smartcase " ... but case sensitive when uc present set scrolljump=5 " Line to scroll when cursor leaves screen set scrolloff=3 " Minumum lines to keep above and below cursor set nowrap " Do not wrap long lines set splitright " Puts new vsplit windows to the right of the current set splitbelow " Puts new split windows to the bottom of the current set mousehide " Hide the mouse cursor while typing set hidden " Allow buffer switching without saving set ruler " Show the ruler set showcmd " Show partial commands in status line and Selected characters/lines in visual mode set showmode " Show current mode in command-line set showmatch " Show matching brackets/parentthesis set matchtime=5 " Show matching time set report=0 " Always report changed lines set linespace=0 " No extra spaces between rows set winminheight=0 set listchars=tab:→\ ,eol:↵,trail:·,extends:↷,precedes:↶ set whichwrap+=<,>,h,l " Allow backspace and cursor keys to cross line boundaries set termencoding=utf-8 set fileencoding=utf-8 set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936 set wildignore+=*swp,*.class,*.pyc,*.png,*.jpg,*.gif,*.zip set wildignore+=*/tmp/*,*.o,*.obj,*.so " Unix set wildignore+=*\\tmp\\*,*.exe " Windows " Visual shifting (does not exit Visual mode) vnoremap < >gv " Treat long lines as break lines (useful when moving around in them) nmap j gj nmap k gk vmap j gj vmap k gk set nobackup set noswapfile set nowritebackup set cursorline " Highlight current line set fileformats=unix,dos,mac " Use Unix as the standard file type set number " Line numbers on set fillchars=vert:│,stl:\ ,stlnc:\ " Annoying temporary files set directory=/tmp//,. set backupdir=/tmp//,. highlight clear SignColumn " SignColumn should match background if has('unnamedplus') set clipboard+=unnamedplus else set clipboard+=unnamed endif set undofile " Persistent undo set undolevels=500 " Maximum number of changes that can be undone set undoreload=5000 " Maximum number lines to save for undo on a buffer reload " Insert mode shortcut inoremap inoremap inoremap inoremap inoremap " Bash like inoremap inoremap inoremap " Command mode shortcut cnoremap cnoremap cnoremap cnoremap cnoremap cnoremap cnoremap cnoremap " Quit visual mode vnoremap v " Move to the start of line nmap H ^ " Move to the end of line nmap L $ " Quick command mode nmap : " In the quickfix window, is used to jump to the error under the " cursor, so undefine the mapping there. autocmd BufReadPost quickfix nmap " Open shell in vim map ' :terminal