From 100334a2878cac934314542cfad71496814d706b Mon Sep 17 00:00:00 2001 From: thek4n Date: Wed, 26 Jun 2024 14:51:47 +0300 Subject: [PATCH] nvim(lsp): migrate to coq_nvim --- .../.config/nvim/lua/plugins/coq_nvim.lua | 43 +++++++ .../.config/nvim/lua/plugins/nvim_cmp.lua | 116 ------------------ 2 files changed, 43 insertions(+), 116 deletions(-) create mode 100644 home/user/.config/nvim/lua/plugins/coq_nvim.lua delete mode 100644 home/user/.config/nvim/lua/plugins/nvim_cmp.lua diff --git a/home/user/.config/nvim/lua/plugins/coq_nvim.lua b/home/user/.config/nvim/lua/plugins/coq_nvim.lua new file mode 100644 index 0000000..8f9342b --- /dev/null +++ b/home/user/.config/nvim/lua/plugins/coq_nvim.lua @@ -0,0 +1,43 @@ +return { + "neovim/nvim-lspconfig", -- REQUIRED: for native Neovim LSP integration + lazy = false, -- REQUIRED: tell lazy.nvim to start this plugin at startup + dependencies = { + { + "ms-jpq/coq_nvim", + branch = "coq", + build = ":COQdeps", + }, + + -- 9000+ Snippets + { "ms-jpq/coq.artifacts", branch = "artifacts" }, + + { 'ms-jpq/coq.thirdparty', branch = "3p" } + }, + init = function() + vim.g.coq_settings = { + auto_start = true, + } + + vim.g.coq_settings = { + keymap = { + recommended = true, + }, + } + + -- Keybindings + vim.api.nvim_set_keymap('i', '', [[pumvisible() ? "\" : "\"]], { expr = true, silent = true }) + vim.api.nvim_set_keymap('i', '', [[pumvisible() ? "\" : "\"]], { expr = true, silent = true }) + vim.api.nvim_set_keymap('i', '', [[pumvisible() ? "\" : "\"]], { expr = true, silent = true }) + vim.api.nvim_set_keymap( + "i", + "", + [[pumvisible() ? (complete_info().selected == -1 ? "\" : "\") : "\"]], + { expr = true, silent = true } + ) + vim.api.nvim_set_keymap('i', '', [[pumvisible() ? "\" : "\"]], { expr = true, silent = true }) + vim.api.nvim_set_keymap('i', '', [[pumvisible() ? "\" : "\"]], { expr = true, silent = true }) + end, + config = function() + vim.cmd('COQnow -s') + end, +} \ No newline at end of file diff --git a/home/user/.config/nvim/lua/plugins/nvim_cmp.lua b/home/user/.config/nvim/lua/plugins/nvim_cmp.lua deleted file mode 100644 index c0455cd..0000000 --- a/home/user/.config/nvim/lua/plugins/nvim_cmp.lua +++ /dev/null @@ -1,116 +0,0 @@ -local border_opts = { - border = "single", - winhighlight = "Normal:Normal,FloatBorder:FloatBorder,CursorLine:Visual,Search:None", -} - -local function has_words_before() - local line, col = unpack(vim.api.nvim_win_get_cursor(0)) - return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil -end - -local function setup_cmp() - local cmp = require("cmp") - - cmp.setup({ - completion = { - autocomplete = {'TextChanged'} - }, - snippet = { - expand = function(args) - require('luasnip').lsp_expand(args.body) - end, - }, - mapping = { - [''] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif has_words_before() then - cmp.complete() - else - fallback() - end - end, { "i", "s" }), - [''] = cmp.mapping.select_prev_item(), - [''] = cmp.mapping.scroll_docs(-4), - [''] = cmp.mapping.scroll_docs(4), - [''] = cmp.mapping.abort(), - [''] = cmp.mapping.confirm { - behavior = cmp.ConfirmBehavior.Replace, - select = false, - }, - }, - window = { - completion = cmp.config.window.bordered(border_opts), - documentation = cmp.config.window.bordered(border_opts), - }, - sorting = { - priority_weight = 1.0, - comparators = { - cmp.config.compare.locality, - cmp.config.compare.recently_used, - cmp.config.compare.score, - cmp.config.compare.offset, - cmp.config.compare.order, - }, - }, - sources = cmp.config.sources({ - { name = 'nvim_lsp', priority = 1250 }, - { name = 'luasnip', priority = 1000 }, - { name = 'buffer', priority = 750 }, - { name = "dotenv", priority = 500 }, - { name = 'path', priority = 250 }, - }), - }) -end - -return { - { - 'L3MON4D3/LuaSnip', - event = "InsertEnter", - build = "make install_jsregexp", - dependencies = { - 'hrsh7th/nvim-cmp', - 'honza/vim-snippets', - }, - config = function() - local ls = require("luasnip") - - vim.g.snips_author = 'thek4n' - vim.g.snips_email = 'thek4n@yandex.com' - vim.g.snips_github = 'https://github.com/thek4n' - - local function jump(val) - return function() - ls.jump(val) - end - end - - local map = vim.keymap.set - map({'i', 's'}, '', jump(1)) - map({'i', 's'}, '', jump(-1)) - - - local luasnip_loaders = require("luasnip.loaders.from_snipmate") - - luasnip_loaders.lazy_load() - end - }, - { - 'hrsh7th/nvim-cmp', - event = "InsertEnter", - dependencies = { - "hrsh7th/cmp-buffer", - "hrsh7th/cmp-path", - "hrsh7th/cmp-cmdline", - 'saadparwaiz1/cmp_luasnip', - 'hrsh7th/cmp-nvim-lsp', - 'lukas-reineke/cmp-under-comparator', - 'SergioRibera/cmp-dotenv' - }, - config = setup_cmp, - }, - { - 'neovim/nvim-lspconfig', - event = "InsertEnter", - }, -} \ No newline at end of file