From 68c5878afacdccde517d3ccdcdb594553bc27237 Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Mon, 17 Aug 2020 22:12:49 -0500 Subject: [PATCH] Update nvim config --- .config/nvim/init.vim | 117 ++++++++++++++++++++++++++++-------------- 1 file changed, 78 insertions(+), 39 deletions(-) diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim index 4dbbbef..fed36bf 100644 --- a/.config/nvim/init.vim +++ b/.config/nvim/init.vim @@ -1,31 +1,89 @@ " Shortcuts map :NERDTreeToggle -map :TagbarToggle +nnoremap s :TagbarToggle + +" Remove Highlight +nnoremap :let @/="" + " Required for operations modifying multiple buffers like rename. +" Used by coc.nvim set hidden -let g:LanguageClient_serverCommands = { -\ 'rust': ['rust-analyzer'] -\ } +" Set more space for displaying messages +" Used by coc.nvim +set cmdheight=2 + +" Highlight the symbol and its references when holding the cursor. +autocmd CursorHold * silent call CocActionAsync('highlight') + +" C-Space triggers autocompletion +inoremap coc#refresh() + +" Use tab for trigger completion with characters ahead and navigate. +" Used by coc.nvim +inoremap + \ pumvisible() ? "\" : + \ check_back_space() ? "\" : + \ coc#refresh() +inoremap pumvisible() ? "\" : "\" + +function! s:check_back_space() abort + let col = col('.') - 1 + return !col || getline('.')[col - 1] =~# '\s' +endfunction + +" Use to confirm completion, `u` means break undo chain at current +" position. +" Used by coc.nvim +if exists('*complete_info') + inoremap complete_info()["selected"] != "-1" ? "\" : "\u\" +else + inoremap pumvisible() ? "\" : "\u\" +endif + +" Use K to show documentation in preview window. +" Used by coc.nvim +nnoremap K :call show_documentation() +function! s:show_documentation() + if (index(['vim','help'], &filetype) >= 0) + execute 'h '.expand('') + else + call CocAction('doHover') + endif +endfunction + +" CoC Status in LightLine +" Used by coc.nvim lightline.nvim +let g:lightline = { + \ 'colorscheme': 'molokai', + \ 'active': { + \ 'left': [ [ 'mode', 'paste' ], + \ [ 'cocstatus', 'readonly', 'filename', 'modified' ] ] + \ }, + \ 'component_function': { + \ 'cocstatus': 'coc#status' + \ }, + \ } + +" Use auocmd to force lightline update. +" Used by coc.nvim lightline.nvim +autocmd User CocStatusChange,CocDiagnosticChange call lightline#update() -" Navigate Completion List -inoremap pumvisible() ? "\" : "\" -inoremap pumvisible() ? "\" : "\" +" Add `:Format` command to format current buffer. +" Used by coc.nvim +command! -nargs=0 Format :call CocAction('format') -" Confirm Selection -inoremap pumvisible() ? "\" : "\u\" +" TODO: Pick and Chose the ones I want +" Mappings for CoCList +nnoremap a :CocList diagnostics +nnoremap e :CocList extensions +nnoremap c :CocList commands -" LanguageClient Options -nnoremap :call LanguageClient_contextMenu() " Plugged Plugins call plug#begin(stdpath('data') . '/plugged') - -" Delimiter Autocompletion -Plug 'raimondi/delimitmate' - " One Dark Theme Plug 'joshdick/onedark.vim' @@ -35,26 +93,20 @@ Plug 'tomasr/molokai' " Tender Theme Plug 'jacoborus/tender.vim' -" Not too sure if this extension is necessary tbh -Plug 'sheerun/vim-polyglot' - " Powerline Bar at bottom of screen Plug 'itchyny/lightline.vim' +" Autocomplete +Plug 'neoclide/coc.nvim', {'branch': 'release'} + " Scope Tags Plug 'majutsushi/tagbar' -" Syntax -Plug 'vim-syntastic/syntastic' - " Rust Support Plug 'rust-lang/rust.vim' -" Language Server Protocol Support -Plug 'autozimu/LanguageClient-neovim', { 'branch': 'next', 'do': 'bash install.sh', } - -" Autocomplete -Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' } +" TOML Support +Plug 'toml-lang/toml' " Fuzzy Search Plug 'junegunn/fzf' @@ -76,19 +128,6 @@ call plug#end() " Autosave with rust-fmt (Rust Only) let g:rustfmt_autosave = 1 -" Enable Autocomplete -let g:deoplete#enable_at_startup = 1 - -" Install Tender for Lightline -let g:lightline = { 'colorscheme': 'molokai' } - -" Let The LSP Client know which Language servers to use -let g:LanguageClient_serverCommands = { -\ 'rust': ['rust-analyzer'] -\ } - " Configuration set noshowmode " Not Needed because we have Lightline colorscheme molokai - -