X-Git-Url: https://git.rmz.io/dotfiles.git/blobdiff_plain/807f8fa562480ce8cddce9b41709049dc325b840..559f210dc5648dae36a56c69e04da016d998a79e:/nvim/lua/plugins/coding.lua diff --git a/nvim/lua/plugins/coding.lua b/nvim/lua/plugins/coding.lua index a765a79..7bf442f 100644 --- a/nvim/lua/plugins/coding.lua +++ b/nvim/lua/plugins/coding.lua @@ -4,9 +4,20 @@ return { { "L3MON4D3/LuaSnip", -- disable luasnip bindings for and + dependencies = { + { + "honza/vim-snippets", + config = function() + require("luasnip.loaders.from_snipmate").lazy_load() + end, + }, + }, keys = function() return {} end, + opts = { + store_selection_keys = "", + }, }, -- auto completion @@ -23,11 +34,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 = cmp.mapping.preset.insert({ + -- 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() @@ -51,4 +83,47 @@ return { }) end, }, + + -- auto pairs + { + "echasnovski/mini.pairs", + }, + + -- surround + { + "echasnovski/mini.surround", + keys = { + { "S", "lua MiniSurround.add('visual')", "x" }, + { "yss", "ys_", remap = true }, + }, + opts = { + mappings = { + -- TODO: this is tpope/surround like, but should consider using vim-sandwich mappings + -- see: :h MiniSurround-vim-surround-config + add = "ys", + delete = "ds", + find = "", + find_left = "", + highlight = "", + replace = "cs", + update_n_lines = "", + }, + }, + }, + -- comments + { + "numToStr/Comment.nvim", + opts = { + toggler = { + line = "gcc", + block = "gbb", + }, + mappings = { + basic = true, + extra = true, + }, + }, + }, + { "JoosepAlviste/nvim-ts-context-commentstring", enabled = false }, + { "echasnovski/mini.comment", enabled = false }, }