X-Git-Url: https://git.rmz.io/dotfiles.git/blobdiff_plain/c46a02525d29b338c3d911933d7d306c532ce24f..ce988f1bedf1b5c1ea824a57fc69d190f9e533d8:/nvim/lua/plugins/coding.lua?ds=sidebyside diff --git a/nvim/lua/plugins/coding.lua b/nvim/lua/plugins/coding.lua index c1b1c39..131fc4a 100644 --- a/nvim/lua/plugins/coding.lua +++ b/nvim/lua/plugins/coding.lua @@ -9,17 +9,29 @@ return { "honza/vim-snippets", config = function() require("luasnip.loaders.from_snipmate").lazy_load() + require("luasnip.loaders.from_lua").load({ paths = vim.fn.stdpath("config") .. "/lua/snippets" }) end, }, }, keys = function() return {} end, + opts = { + store_selection_keys = "", + }, }, -- auto completion { "hrsh7th/nvim-cmp", + version = false, -- last release is way too old + event = "InsertEnter", + dependencies = { + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + "saadparwaiz1/cmp_luasnip", + }, ---@param opts cmp.ConfigSchema opts = function(_, opts) local has_words_before = function() @@ -31,11 +43,32 @@ return { local cmp = require("cmp") local luasnip = require("luasnip") + local upstream_format = opts.formatting.format + opts.formatting.format = function(entry, vim_item) + vim_item = upstream_format(entry, vim_item) + local menu = { + nvim_lsp = "[lsp]", + luasnip = "[snip]", + buffer = "[buf]", + path = "[path]", + } + vim_item.menu = menu[entry.source.name] + return vim_item + end + opts.completion = vim.tbl_extend("force", opts.completion, { completeopt = "menu,menuone,noselect", }) - --TODO: review if I want to keep any of LazyVim's mappings - opts.mapping = vim.tbl_extend("force", opts.mapping, { + -- TODO: review if I want to keep any of LazyVim's mappings + opts.mapping = { + -- lazyvims + [""] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }), + [""] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }), + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.abort(), + [""] = cmp.mapping.complete(), + -- mine [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_next_item() @@ -56,7 +89,7 @@ return { fallback() end end, { "i", "s" }), - }) + } end, }, @@ -68,10 +101,16 @@ return { -- surround { "echasnovski/mini.surround", - keys = { - { "S", "lua MiniSurround.add('visual')", "x" }, - { "yss", "ys_", remap = true }, - }, + keys = function() + -- HACK: use function to disable merging with LazyVim's keys definition + return { + { "ys", desc = "Add surrounding", "n" }, + { "S", desc = "Add surrounding", "x" }, + { "ds", desc = "Delete surrounding" }, + { "cs", desc = "Change surrounding" }, + { "yss", "ys_", remap = true }, + } + end, opts = { mappings = { -- TODO: this is tpope/surround like, but should consider using vim-sandwich mappings @@ -85,6 +124,12 @@ return { update_n_lines = "", }, }, + config = function(_, opts) + require("mini.surround").setup(opts) + -- remap visual + vim.keymap.del("x", "ys", { silent = true }) + vim.keymap.set("x", "S", [[:lua MiniSurround.add('visual')]], { silent = true }) + end, }, -- comments {