From 0aac4d5de31a5c64f6f10c8e192e83054fac5267 Mon Sep 17 00:00:00 2001 From: Minijackson Date: Tue, 12 Apr 2022 12:48:25 +0200 Subject: vim: switch deprecated nvim-compe -> nvim-cmp --- common/vim.nix | 14 +++++++++++--- dotfiles/vim-dev.lua | 1 + dotfiles/vim.lua | 52 ++++++++++++++++++++++++++++++++++++---------------- 3 files changed, 48 insertions(+), 19 deletions(-) diff --git a/common/vim.nix b/common/vim.nix index 09dd9f5..17d18ac 100644 --- a/common/vim.nix +++ b/common/vim.nix @@ -72,9 +72,17 @@ let gitsigns-nvim diffview-nvim - nvim-compe - compe-latex-symbols - compe-zsh + nvim-cmp + cmp-buffer + cmp-calc + cmp-cmdline + cmp-latex-symbols + cmp-nvim-lsp + cmp-path + cmp-spell + cmp-tmux + cmp-treesitter + cmp-vsnip vim-vsnip vim-vsnip-integ diff --git a/dotfiles/vim-dev.lua b/dotfiles/vim-dev.lua index 55ac142..ab04bf8 100644 --- a/dotfiles/vim-dev.lua +++ b/dotfiles/vim-dev.lua @@ -64,6 +64,7 @@ capabilities.textDocument.completion.completionItem.resolveSupport = { 'additionalTextEdits', } } +capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities) require("rust-tools").setup { server = { diff --git a/dotfiles/vim.lua b/dotfiles/vim.lua index 9317453..0e89ba6 100644 --- a/dotfiles/vim.lua +++ b/dotfiles/vim.lua @@ -166,26 +166,46 @@ require('nvim-treesitter.configs').setup { vim.o.foldmethod = 'expr' vim.o.foldexpr = 'nvim_treesitter#foldexpr()' --- nvim-compe +-- nvim-cmp -require("compe").setup { - source = { - buffer = true, - calc = true, - latex_symbols = true, - nvim_lsp = true, - nvim_lua = true, - nvim_treesitter = true, - omni = false, - path = true, - spell = true, - vsnip = true, - zsh = true, +local cmp = require("cmp") + +cmp.setup { + snippet = { + expand = function(args) + vim.fn["vsnip#anonymous"](args.body) + end, + }, + mapping = { + [''] = cmp.mapping.confirm({ select = false }), }, + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "vsnip" }, + { name = "latex_symbols" }, + { name = "calc" }, + }, { + { name = "path" }, + { name = "treesitter" }, + }, { + { name = "tmux" }, + { name = "spell" }, + -- Use \k for iskeyword because of UTF-8 + { name = "buffer", option = { keyword_pattern = [[\k\+]], } }, + }), } -map("i", "", "compe#confirm('')", { noremap = true, silent = true, expr = true }) -map("i", "", "compe#close('')", { noremap = true, silent = true, expr = true }) +cmp.setup.cmdline("/", { + sources = { + { name = "buffer", option = { keyword_pattern = [[\k\+]], } }, + } +}) + +cmp.setup.cmdline(":", { + sources = cmp.config.sources({ + { name = "cmdline" }, + }) +}) -- Telescope -- cgit v1.2.3