diff options
Diffstat (limited to 'init.vim')
-rwxr-xr-x | init.vim | 149 |
1 files changed, 113 insertions, 36 deletions
@@ -23,56 +23,133 @@ set ttyfast " Speed up scrolling in Vim " vim-plug -> call plug#begin('~/.config/nvim/plugged') +" Nvim LSP client +Plug 'neovim/nvim-lspconfig' + " Easy alignment Plug 'junegunn/vim-easy-align' xmap ga <Plug>(EasyAlign) nmap ga <Plug>(EasyAlign) " For Rust development -Plug 'dense-analysis/ale' -Plug 'rust-lang/rust.vim' +Plug 'hrsh7th/nvim-cmp' " Completion framework +Plug 'hrsh7th/cmp-nvim-lsp' " LSP completion source for nvim-cmp +Plug 'hrsh7th/cmp-vsnip' " Snippet completion source for nvim-cmp +Plug 'hrsh7th/cmp-path' +Plug 'hrsh7th/cmp-buffer' +Plug 'simrat39/rust-tools.nvim' +Plug 'hrsh7th/vim-vsnip' -" Collection of common configurations for the Nvim LSP client -" Plug 'neovim/nvim-lspconfig' +" For C++ development +Plug 'jackguo380/vim-lsp-cxx-highlight' -" Completion framework -" Plug 'hrsh7th/nvim-cmp' +" Fuzzy Finder +Plug 'nvim-lua/popup.nvim' +Plug 'nvim-lua/plenary.nvim' +Plug 'nvim-telescope/telescope.nvim' -" LSP completion source for nvim-cmp -" Plug 'hrsh7th/cmp-nvim-lsp' +" Unused +" Plug 'rust-lang/rust.vim' +" Plug 'dense-analysis/ale' -" Snippet completion source for nvim-cmp -" Plug 'hrsh7th/cmp-vsnip' +call plug#end() +" <- vim-plug -" Other usefull completion sources -" Plug 'hrsh7th/cmp-path' -" Plug 'hrsh7th/cmp-buffer' +" :help completeopt +set completeopt=menu,menuone,longest,noselect -" See hrsh7th's other plugins for more completion sources! +set shortmess+=c +set signcolumn=yes -" To enable more of the features of rust-analyzer, such as inlay hints and more! -" Plug 'simrat39/rust-tools.nvim' +" 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 <<EOF +local nvim_lsp = require'lspconfig' -" Snippet engine -" Plug 'hrsh7th/vim-vsnip' +local lspconfig = require'lspconfig' +lspconfig.ccls.setup { + init_options = { + compilationDatabaseDirectory = "build"; + index = { + threads = 0; + }; + highlight = { + lsRanges = true; + }; + clang = { + excludeArgs = { "-frounding-math"} ; + }; + } +} +require'lspconfig'.ccls.setup{} -" Fuzzy finder -" Optional -" Plug 'nvim-lua/popup.nvim' -" Plug 'nvim-lua/plenary.nvim' -" Plug 'nvim-telescope/telescope.nvim' +local opts = { + tools = { -- rust-tools options + autoSetHints = true, + hover_with_actions = true, + inlay_hints = { + show_parameter_hints = true, + parameter_hints_prefix = "", + other_hints_prefix = "", + }, + }, -call plug#end() + -- all the opts to send to nvim-lspconfig + -- these override the defaults set by rust-tools.nvim + -- see https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#rust_analyzer + server = { + -- on_attach is a callback called when the language server attachs to the buffer + -- on_attach = on_attach, + settings = { + -- to enable rust-analyzer settings visit: + -- https://github.com/rust-analyzer/rust-analyzer/blob/master/docs/user/generated_config.adoc + ["rust-analyzer"] = { + -- enable clippy on save + checkOnSave = { + command = "clippy" + }, + } + } + }, +} -" 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 -let g:ale_linters = { 'rust': ['analyzer'] } -let g:ale_fixers = { 'rust': ['rustfmt', 'trim_whitespace', 'remove_trailing_lines'] } -set completeopt=menu,menuone,preview,noselect,noinsert -let g:ale_completion_enabled = 1 - -" Avoid showing extra messages when using completion -" set shortmess+=c +require('rust-tools').setup(opts) +EOF + +" Setup Completion +" See https://github.com/hrsh7th/nvim-cmp#basic-configuration +lua <<EOF +local cmp = require'cmp' +cmp.setup({ + -- Enable LSP snippets + snippet = { + expand = function(args) + vim.fn["vsnip#anonymous"](args.body) + end, + }, + mapping = { + ['<C-p>'] = cmp.mapping.select_prev_item(), + ['<C-n>'] = cmp.mapping.select_next_item(), + -- Add tab support + ['<S-Tab>'] = cmp.mapping.select_prev_item(), + ['<Tab>'] = cmp.mapping.select_next_item(), + ['<C-d>'] = cmp.mapping.scroll_docs(-4), + ['<C-f>'] = cmp.mapping.scroll_docs(4), + ['<C-Space>'] = cmp.mapping.complete(), + ['<C-e>'] = cmp.mapping.close(), + ['<CR>'] = cmp.mapping.confirm({ + behavior = cmp.ConfirmBehavior.Insert, + select = true, + }) + }, + + -- Installed sources + sources = { + { name = 'nvim_lsp' }, + { name = 'vsnip' }, + { name = 'path' }, + { name = 'buffer' }, + }, +}) +EOF |