From 3f8233407d3db32ccdfe03f1cdedc1ad5642d2e5 Mon Sep 17 00:00:00 2001 From: Jesse Morgan Date: Wed, 13 Apr 2022 21:14:35 -0700 Subject: Add neovim config --- base/config/nvim/init.vim | 49 ++++++++++++++++++++++ base/config/nvim/rust.vim | 102 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 151 insertions(+) create mode 100644 base/config/nvim/init.vim create mode 100644 base/config/nvim/rust.vim diff --git a/base/config/nvim/init.vim b/base/config/nvim/init.vim new file mode 100644 index 0000000..18324af --- /dev/null +++ b/base/config/nvim/init.vim @@ -0,0 +1,49 @@ +set runtimepath^=~/.vim runtimepath+=~/.vim/after +let &packpath = &runtimepath +source ~/.vimrc + +call plug#begin('~/.vim/plugged') + +" Collection of common configurations for the Nvim LSP client +Plug 'neovim/nvim-lspconfig' + +" Completion framework +Plug 'hrsh7th/nvim-cmp' + +" LSP completion source for nvim-cmp +Plug 'hrsh7th/cmp-nvim-lsp' + +" Snippet completion source for nvim-cmp +Plug 'hrsh7th/cmp-vsnip' + +" Other usefull completion sources +Plug 'hrsh7th/cmp-path' +Plug 'hrsh7th/cmp-buffer' + +" See hrsh7th's other plugins for more completion sources! + +" To enable more of the features of rust-analyzer, such as inlay hints and more! +Plug 'simrat39/rust-tools.nvim' + +" Snippet engine +Plug 'hrsh7th/vim-vsnip' + +" Fuzzy finder +" Optional +Plug 'nvim-lua/popup.nvim' +Plug 'nvim-lua/plenary.nvim' +Plug 'nvim-telescope/telescope.nvim' + +" Color Scheme +Plug 'arcticicestudio/nord-vim' + +Plug 'vim-airline/vim-airline' +Plug 'airblade/vim-gitgutter' +Plug 'tpope/vim-fugitive' + +call plug#end() + +colorscheme nord + +source ~/.config/nvim/rust.vim + diff --git a/base/config/nvim/rust.vim b/base/config/nvim/rust.vim new file mode 100644 index 0000000..81ce516 --- /dev/null +++ b/base/config/nvim/rust.vim @@ -0,0 +1,102 @@ +" Set completeopt to have a better completion experience +" :help completeopt +" menuone: popup even when there's only one match +" noinsert: Do not insert text until a selection is made +" noselect: Do not select, force user to select one from the menu +set completeopt=menuone,noinsert,noselect + +" Avoid showing extra messages when using completion +set shortmess+=c + +" Configure LSP through rust-tools.nvim plugin. +" rust-tools will configure and enable certain LSP features for us. +" See https://github.com/simrat39/rust-tools.nvim#configuration +lua <'] = cmp.mapping.select_prev_item(), + [''] = cmp.mapping.select_next_item(), + -- Add tab support + [''] = cmp.mapping.select_prev_item(), + [''] = cmp.mapping.select_next_item(), + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.close(), + [''] = cmp.mapping.confirm({ + behavior = cmp.ConfirmBehavior.Insert, + select = true, + }) + }, + + -- Installed sources + sources = { + { name = 'nvim_lsp' }, + { name = 'vsnip' }, + { name = 'path' }, + { name = 'buffer' }, + }, +}) +EOF + +" Code navigation shortcuts +nnoremap lua vim.lsp.buf.definition() +nnoremap K lua vim.lsp.buf.hover() +nnoremap gD lua vim.lsp.buf.implementation() +nnoremap lua vim.lsp.buf.signature_help() +nnoremap 1gD lua vim.lsp.buf.type_definition() +nnoremap gr lua vim.lsp.buf.references() +nnoremap g0 lua vim.lsp.buf.document_symbol() +nnoremap gW lua vim.lsp.buf.workspace_symbol() +nnoremap gd lua vim.lsp.buf.definition() + +nnoremap ga lua vim.lsp.buf.code_action() + +" Goto previous/next diagnostic warning/error +nnoremap g[ lua vim.diagnostic.goto_prev() +nnoremap g] lua vim.diagnostic.goto_next() -- cgit v1.2.3