" Required: call plug#begin(expand('~/.config/nvim/plugged')) Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' } Plug 'neoclide/coc.nvim', {'do': 'yarn install --frozen-lockfile'} Plug 'Shougo/vimproc.vim', {'do' : 'make'} Plug 'scrooloose/nerdtree' Plug 'jistr/vim-nerdtree-tabs' Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } Plug 'itchyny/lightline.vim' Plug 'tpope/vim-commentary' Plug 'sheerun/vim-polyglot' Plug 'tpope/vim-fugitive' Plug 'tpope/vim-rhubarb' Plug 'Raimondi/delimitMate' Plug 'voldikss/vim-floaterm' Plug 't9md/vim-choosewin' Plug 'tomasr/molokai' Plug 'xolox/vim-misc' Plug 'xolox/vim-session' Plug 'Yggdroot/LeaderF', { 'do': ':LeaderfInstallCExtension' } call plug#end() set clipboard=unnamedplus set clipboard+=unnamedplus command! -nargs=0 Prettier :CocCommand prettier.formatFile syntax on set ruler set relativenumber set scrolloff=12 set number " session management let g:session_directory = "~/.config/nvim/session" let g:session_autoload = "yes" let g:session_autosave = "yes" let g:session_command_aliases = 1 let g:session_autosave_periodic = 1 "" Lightline set tabline=%!lightline#tabline() set laststatus=2 let g:lightline = { \ 'active': { \ 'left': [ [ 'mode', 'paste' ], \ [ 'cocstatus','currentfunction','gitbranch', 'readonly', 'filename', 'modified' ] ] \ }, \ 'component_function': { \ 'cocstatus': 'coc#status', \ 'currentfunction': 'CocCurrentFunction', \ 'gitbranch': 'FugitiveHead' \ }} "" Color set termguicolors colorscheme molokai let no_buffers_menu=1 set mousemodel=popup set t_Co=256 set guioptions=egmrti set gfn=Monospace\ 10 highlight Cursor guifg=white guibg=red highlight iCursor guifg=white guibg=red set guicursor=n-v-c:block-Cursor set guicursor+=i:ver100-iCursor set guicursor+=n-v-c:blinkon0 set guicursor+=i:blinkwait10 " esearch hi ESearchMatch ctermfg=black ctermbg=white guifg=#000000 guibg=yellow "" Map leader to , let mapleader=',' "" Tabs. May be overridden by autocmd rules set tabstop=4 set softtabstop=0 set shiftwidth=4 set expandtab "" Split noremap h :split noremap v :vsplit "" Git set diffopt+=horizontal noremap ga :Gwrite noremap gc :Git commit noremap gsh :Git push noremap gll :Git pull noremap gst :Git noremap gb :Git blame noremap gd :Git diff noremap gr :Git remove" noremap zz :!cargo run noremap zx :!cargo build " vim choosewin nmap (choosewin) "" MyCustom set noswapfile set autoread set autowrite au CursorHold,CursorHoldI * checktime noremap :nohl noremap w :w \| :SaveSession noremap rp :%s///g noremap qq :qa! noremap noremap :tabnext noremap :tabnew imap :tabnext imap :tabnew vmap :tabnext vmap :tabnew noremap sps :SpSearch """ Floatterm let g:floaterm_keymap_new = '' let g:floaterm_keymap_prev = '' let g:floaterm_keymap_next = '' let g:floaterm_keymap_toggle = '0' let g:floaterm_width = 0.8 let g:floaterm_height = 0.8 " hi Floaterm guibg= "" NERDTree configuration let g:NERDTreeChDirMode=2 let g:NERDTreeIgnore=['\.rbc$', '\~$', '\.pyc$', '\.db$', '\.sqlite$', '__pycache__','node_modules','target'] let g:NERDTreeSortOrder=['^__\.py$', '\/$', '*', '\.swp$', '\.bak$', '\~$'] let g:NERDTreeShowBookmarks=1 let g:nerdtree_tabs_focus_on_files=1 let g:NERDTreeMapOpenInTabSilent = '' let g:NERDTreeWinSize = 30 set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.pyc,*.db,*.sqlite,target/* nnoremap :NERDTreeFind nnoremap :NERDTreeToggle "" fzf.vim set wildmode=list:longest,list:full set wildignore+=*.o,*.obj,.git,*.rbc,*.pyc,__pycache__,node_modules/*,dist/*,target/* " " ripgrep if executable('rg') let $FZF_DEFAULT_COMMAND = 'rg --files --hidden --follow --glob "!{.git/*,target/*}"' set grepprg=rg\ --vimgrep command! -bang -nargs=* Find call fzf#vim#grep('rg --column --line-number --no-heading --fixed-strings --ignore-case --hidden --follow --glob "!{.git/*,node_modules/*,target/*}" --color "always" '.shellescape().'| tr -d "\017"', 1, 0) endif cnoremap =expand("%:p:h") . "/" nnoremap b :Buffers nnoremap e :FZF -m " ------------------------------------------------------------------------------------------------- " coc.nvim default settings " ------------------------------------------------------------------------------------------------- " if hidden is not set, TextEdit might fail. set hidden " Better display for messages set cmdheight=2 " Smaller updatetime for CursorHold & CursorHoldI set updatetime=300 set ttimeoutlen=50 " don't give |ins-completion-menu| messages. set shortmess+=c " always show signcolumns set signcolumn=yes " Use tab for trigger completion with characters ahead and navigate. " Use command ':verbose imap ' to make sure tab is not mapped by other plugin. inoremap \ pumvisible() ? "\" : \ check_back_space() ? "\" : \ coc#refresh() inoremap pumvisible() ? "\" : "\" function! CocCurrentFunction() return get(b:, 'coc_current_function', '') endfunction function! s:check_back_space() abort let col = col('.') - 1 return !col || getline('.')[col - 1] =~# '\s' endfunction " Use to trigger completion. inoremap coc#refresh() " Use `[c` and `]c` to navigate diagnostics nmap [c (coc-diagnostic-prev) nmap ]c (coc-diagnostic-next) " Remap keys for gotos " nmap gd (coc-definition) nmap gd :call CocActionAsync('jumpDefinition') nmap gy (coc-type-definition) nmap gi (coc-implementation) nmap gr (coc-references) " Use U to show documentation in preview window nnoremap U :call show_documentation() " Remap for rename current word nmap rn (coc-rename) nnoremap prw :CocSearch =expand("") " Remap for format selected region vmap f (coc-format-selected) nmap f (coc-format-selected) " Show all diagnostics nnoremap a :CocList diagnostics " Manage extensions nnoremap e :CocList extensions " Show commands nnoremap c :CocList commands " Find symbol of current document nnoremap o :CocList outline " Search workspace symbols nnoremap s :CocList -I symbols " Do default action for next item. nnoremap j :CocNext " Do default action for previous item. nnoremap k :CocPrev " Resume latest coc list nnoremap p :CocListResume " disable vim-go :GoDef short cut (gd) " this is handled by LanguageClient [LC] let g:go_def_mapping_enabled = 0 " go " vim-go " run :GoBuild or :GoTestCompile based on the go file function! s:build_go_files() let l:file = expand('%') if l:file =~# '^\f\+_test\.go$' call go#test#Test(0, 1) elseif l:file =~# '^\f\+\.go$' call go#cmd#Build(0) endif endfunction let g:go_list_type = "quickfix" let g:go_fmt_command = "goimports" let g:go_fmt_fail_silently = 1 let g:go_highlight_types = 1 let g:go_highlight_fields = 1 let g:go_highlight_functions = 1 let g:go_highlight_methods = 1 let g:go_highlight_operators = 1 let g:go_highlight_build_constraints = 1 let g:go_highlight_structs = 1 let g:go_highlight_generate_tags = 1 let g:go_highlight_space_tab_error = 0 let g:go_highlight_array_whitespace_error = 0 let g:go_highlight_trailing_whitespace_error = 0 let g:go_highlight_extra_types = 1 autocmd BufNewFile,BufRead *.go setlocal noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 augroup completion_preview_close autocmd! if v:version > 703 || v:version == 703 && has('patch598') autocmd CompleteDone * if !&previewwindow && &completeopt =~ 'preview' | silent! pclose | endif endif augroup END augroup go au! au Filetype go command! -bang A call go#alternate#Switch(0, 'edit') au Filetype go command! -bang AV call go#alternate#Switch(0, 'vsplit') au Filetype go command! -bang AS call go#alternate#Switch(0, 'split') au Filetype go command! -bang AT call go#alternate#Switch(0, 'tabe') au FileType go nmap dd (go-def-vertical) au FileType go nmap dv (go-doc-vertical) au FileType go nmap db (go-doc-browser) au FileType go nmap r (go-run) au FileType go nmap t (go-test) au FileType go nmap gt (go-coverage-toggle) au FileType go nmap i (go-info) au FileType go nmap l (go-metalinter) au FileType go nmap :GoDecls au FileType go nmap dr :GoDeclsDir au FileType go imap :GoDecls au FileType go imap dr :GoDeclsDir au FileType go nmap rb :call build_go_files() augroup END " don't show the help in normal mode let g:Lf_HideHelp = 1 let g:Lf_UseCache = 0 let g:Lf_UseVersionControlTool = 0 let g:Lf_IgnoreCurrentBufferName = 1 " popup mode let g:Lf_WindowPosition = 'popup' let g:Lf_PreviewInPopup = 1 let g:Lf_StlSeparator = { 'left': "\ue0b0", 'right': "\ue0b2", 'font': "UbuntuMono Nerd Font" } let g:Lf_PreviewResult = {'Function': 0, 'BufTag': 0 } let g:Lf_ShortcutF = "ff" noremap fb :=printf("Leaderf buffer %s", "") noremap fm :=printf("Leaderf mru %s", "") noremap ft :=printf("Leaderf bufTag %s", "") noremap fl :=printf("Leaderf line %s", "") noremap :=printf("Leaderf! rg --current-buffer -e %s ", expand("")) noremap :=printf("Leaderf! rg -e %s ", expand("")) " search visually selected text literally xnoremap gf :=printf("Leaderf! rg -F -e %s ", leaderf#Rg#visual()) noremap go :Leaderf! rg --recall " should use `Leaderf gtags --update` first let g:Lf_GtagsAutoGenerate = 0 let g:Lf_Gtagslabel = 'native-pygments' noremap fr :=printf("Leaderf! gtags -r %s --auto-jump", expand("")) noremap fd :=printf("Leaderf! gtags -d %s --auto-jump", expand("")) noremap fo :=printf("Leaderf! gtags --recall %s", "") noremap fn :=printf("Leaderf gtags --next %s", "") noremap fp :=printf("Leaderf gtags --previous %s", "")