X-Git-Url: https://git.rmz.io/dotfiles.git/blobdiff_plain/c46a02525d29b338c3d911933d7d306c532ce24f..2f1cd5e44d3d1d6eeabc60e26d5a340803da7c9f:/nvim/lua/plugins/coding.lua diff --git a/nvim/lua/plugins/coding.lua b/nvim/lua/plugins/coding.lua index c1b1c39..985ccf0 100644 --- a/nvim/lua/plugins/coding.lua +++ b/nvim/lua/plugins/coding.lua @@ -9,55 +9,16 @@ 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, - }, - - -- auto completion - { - "hrsh7th/nvim-cmp", - ---@param opts cmp.ConfigSchema - opts = function(_, opts) - local has_words_before = function() - unpack = unpack or table.unpack - 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 cmp = require("cmp") - local luasnip = require("luasnip") - - 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, { - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif luasnip.expand_or_jumpable() then - luasnip.expand_or_jump() - elseif has_words_before() then - cmp.complete() - 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" }), - }) - end, + opts = { + store_selection_keys = "", + }, }, -- auto pairs @@ -68,10 +29,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 +52,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 {