From dfa93f98dfea42fd2f190cdf4734014fec2d4d09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Moritz=20B=C3=B6hme?= Date: Wed, 6 Sep 2023 09:19:32 +0200 Subject: [PATCH] Revert "feat(nvim): add coq-nvim" This reverts commit e2aff57d7236018257bc0a5ee6c14c2dfe9b3a04. --- modules/programs/nvim/plugins/codeium-vim.lua | 2 - modules/programs/nvim/plugins/coq-nvim.lua | 6 -- .../programs/nvim/plugins/coq-thirdparty.lua | 4 -- modules/programs/nvim/plugins/default.nix | 42 +++++++------ modules/programs/nvim/plugins/nvim-cmp.lua | 63 +++++++++++++++++++ .../programs/nvim/plugins/nvim-lspconfig.lua | 13 ++-- 6 files changed, 93 insertions(+), 37 deletions(-) delete mode 100644 modules/programs/nvim/plugins/codeium-vim.lua delete mode 100644 modules/programs/nvim/plugins/coq-nvim.lua delete mode 100644 modules/programs/nvim/plugins/coq-thirdparty.lua create mode 100644 modules/programs/nvim/plugins/nvim-cmp.lua diff --git a/modules/programs/nvim/plugins/codeium-vim.lua b/modules/programs/nvim/plugins/codeium-vim.lua deleted file mode 100644 index 72cd968..0000000 --- a/modules/programs/nvim/plugins/codeium-vim.lua +++ /dev/null @@ -1,2 +0,0 @@ --- dont show ghost text -vim.g.codeium_render = false diff --git a/modules/programs/nvim/plugins/coq-nvim.lua b/modules/programs/nvim/plugins/coq-nvim.lua deleted file mode 100644 index 63536a8..0000000 --- a/modules/programs/nvim/plugins/coq-nvim.lua +++ /dev/null @@ -1,6 +0,0 @@ -vim.g.coq_settings = { - auto_start = "shut-up", - keymap = { - jump_to_mark = "", - }, -} diff --git a/modules/programs/nvim/plugins/coq-thirdparty.lua b/modules/programs/nvim/plugins/coq-thirdparty.lua deleted file mode 100644 index ec1e05c..0000000 --- a/modules/programs/nvim/plugins/coq-thirdparty.lua +++ /dev/null @@ -1,4 +0,0 @@ -require("coq_3p")({ - { src = "orgmode", short_name = "ORG" }, - { src = "codeium", short_name = "COD" }, -}) diff --git a/modules/programs/nvim/plugins/default.nix b/modules/programs/nvim/plugins/default.nix index 6d22f61..7aa5eb0 100644 --- a/modules/programs/nvim/plugins/default.nix +++ b/modules/programs/nvim/plugins/default.nix @@ -74,6 +74,28 @@ with builtins; { plugin = nvim-web-devicons; } ]; } + { + plugin = nvim-cmp; + conf = readFile ./nvim-cmp.lua; + event = [ "InsertEnter" ]; + dependencies = [ + { plugin = cmp-async-path; } + { plugin = cmp-nvim-lsp; } + { plugin = cmp_luasnip; } + { + plugin = copilot-cmp; + dependencies = [ + { + plugin = copilot-lua; + conf = readFile ./copilot-lua.lua; + dependencies = [{ plugin = which-key-nvim; }]; + } + ]; + } + { plugin = friendly-snippets; } + { plugin = luasnip; } + ]; + } { plugin = todo-comments-nvim; event = [ "BufReadPost" "BufNewFile" ]; @@ -241,26 +263,6 @@ with builtins; plugin = markdown-preview-nvim; ft = [ "md" ]; } - { - plugin = coq_nvim; - event = [ "BufReadPost" "BufNewFile" ]; - init = builtins.readFile ./coq-nvim.lua; - dependencies = [ - { - plugin = coq-thirdparty; - conf = builtins.readFile ./coq-thirdparty.lua; - dependencies = [ - { - plugin = codeium-vim; - init = builtins.readFile ./codeium-vim.lua; - } - ]; - } - { - plugin = coq-artifacts; - } - ]; - } { plugin = nvim-surround; event = [ "BufReadPost" "BufNewFile" ]; diff --git a/modules/programs/nvim/plugins/nvim-cmp.lua b/modules/programs/nvim/plugins/nvim-cmp.lua new file mode 100644 index 0000000..0533cb7 --- /dev/null +++ b/modules/programs/nvim/plugins/nvim-cmp.lua @@ -0,0 +1,63 @@ +local cmp = require("cmp") +local luasnip = require("luasnip") +require("luasnip.loaders.from_vscode").lazy_load() +require("copilot_cmp").setup() + +local default_sources = { + { name = "async_path", priority = 1 }, + { name = "copilot", priority = 2 }, + { name = "luasnip", priority = 2 }, + { name = "nvim_lsp", priority = 3 }, +} + +cmp.setup({ + formatting = { + format = require("lspkind").cmp_format({ + mode = "symbol", -- show only symbol annotations + maxwidth = 50, -- prevent the popup from showing more than provided characters + ellipsis_char = "...", -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead + symbol_map = { + Copilot = "", + }, + }), + }, + snippet = { + -- REQUIRED - you must specify a snippet engine + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + }, + mapping = cmp.mapping.preset.insert({ + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete(), + [""] = cmp.mapping.abort(), + [""] = cmp.mapping.confirm({ select = true }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif luasnip.expand_or_jumpable() then + luasnip.expand_or_jump() + else + fallback() + end + end, { "i", "s" }), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif luasnip.jumpable(-1) then + luasnip.jump(-1) + else + fallback() + end + end, { "i", "s" }), + }), + sources = default_sources, +}) + +cmp.setup.filetype("org", { + sources = vim.tbl_deep_extend("force", default_sources, { + { name = "buffer", priority = 1 }, + { name = "orgmode", priority = 3 }, + }), +}) diff --git a/modules/programs/nvim/plugins/nvim-lspconfig.lua b/modules/programs/nvim/plugins/nvim-lspconfig.lua index afb7ea0..3690f1d 100644 --- a/modules/programs/nvim/plugins/nvim-lspconfig.lua +++ b/modules/programs/nvim/plugins/nvim-lspconfig.lua @@ -5,8 +5,9 @@ vim.diagnostic.config({ virtual_text = false, }) -local capabilities = vim.lsp.protocol.make_client_capabilities() --- NOTE for nvim-ufo +-- The nvim-cmp almost supports LSP's capabilities so You should advertise it to LSP servers.. +local capabilities = require("cmp_nvim_lsp").default_capabilities() + -- Tell the server the capability of foldingRange, -- Neovim hasn't added foldingRange to default capabilities, users must add it manually capabilities.textDocument.foldingRange = { @@ -100,6 +101,9 @@ end local lspconfig_default_options = { on_attach = on_attach_def, capabilities = capabilities, + flags = { + debounce_text_changes = 100, + }, } ---function to add default options to lspconfig @@ -107,9 +111,8 @@ local lspconfig_default_options = { ---@param options table ---@return nil local function lspconfig_setup(lsp, options) - local coq_options = require("coq").lsp_ensure_capabilities({}) - local merged_options = vim.tbl_deep_extend("force", coq_options, lspconfig_default_options, options) - lspconfig[lsp].setup(merged_options) + local final_options = vim.tbl_deep_extend("force", lspconfig_default_options, options) + lspconfig[lsp].setup(final_options) end local servers = {