-- -- This file adds local changes to the corresponding file and plugins in LazyVim -- -- Pattern for plugin "echasnovski/mini.pairs": -- -- . all characters -- %a letters -- %c control characters -- %d digits -- %l lower case letters -- %p punctuation characters -- %s space characters -- %u upper case letters -- %w alphanumeric characters -- %x hexadecimal digits -- %z the character with representation 0 -- -- So below we try to say: -- NOT after alphanumeric, ), ], }, and not before alphanumeric, (, [, { local pattern = "[^%w\\%)%}%]][^%w\\%(%{%[]" -- An alternative can be: -- local pattern = "[%s\r][%s\n]" -- Which should say "only before or after whitespace" return { -- auto completion { -- https://github.com/hrsh7th/nvim-cmp "hrsh7th/nvim-cmp", import = "lazyvim.plugins.extras.coding.nvim-cmp", opts = function(_, opts) local cmp = require("cmp") opts.completion = { completeopt = "menu,menuone,noselect", } opts.experimental = { ghost_text = false, } 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 opts.mapping = vim.tbl_extend("force", opts.mapping, { --[""] = cmp.mapping.select_prev_item(), [""] = cmp.mapping.scroll_docs(-4), --[""] = cmp.mapping.select_next_item(), [""] = cmp.mapping.scroll_docs(4), --[""] = cmp.mapping.scroll_docs(-4), [""] = cmp.mapping.select_next_item(), --[""] = cmp.mapping.scroll_docs(4), [""] = cmp.mapping.select_prev_item(), [""] = cmp.mapping({ i = function(fallback) if cmp.visible() then cmp.close() end fallback() end, }), [""] = cmp.mapping({ i = function(fallback) if cmp.visible() then cmp.close() end fallback() end, }), --[""] = cmp.mapping.complete(), --[""] = cmp.mapping.close(), --[""] = cmp.mapping.confirm { -- behavior = cmp.ConfirmBehavior.Insert, -- select = true, --}, [""] = cmp.mapping({ i = function(fallback) if cmp.visible() and cmp.get_active_entry() then cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = false }) else fallback() end end, s = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }), c = cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }), }), [""] = cmp.mapping(function() if cmp.visible() then cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace, select = true }) else cmp.complete() end end), [""] = cmp.mapping(function(fallback) if cmp.visible() and has_words_before() then cmp.select_next_item() elseif require("luasnip").expand_or_jumpable() then vim.fn.feedkeys(vim.api.nvim_replace_termcodes("luasnip-expand-or-jump", true, true, true), "") else fallback() end end, { "i", "s", }), [""] = cmp.mapping(function(fallback) if cmp.visible() then cmp.select_prev_item() elseif require("luasnip").jumpable(-1) then vim.fn.feedkeys(vim.api.nvim_replace_termcodes("luasnip-jump-prev", true, true, true), "") else fallback() end end, { "i", "s", }), }) end, }, -- auto pairs { -- https://github.com/echasnovski/mini.pairs "echasnovski/mini.pairs", event = "VeryLazy", opts = { mappings = { ["("] = { neigh_pattern = pattern }, ["["] = { neigh_pattern = pattern }, ["{"] = { neigh_pattern = pattern }, [")"] = { neigh_pattern = pattern }, ["]"] = { neigh_pattern = pattern }, ["}"] = { neigh_pattern = pattern }, ['"'] = { neigh_pattern = pattern }, ["'"] = { neigh_pattern = pattern }, ["`"] = { neigh_pattern = pattern }, }, }, }, -- comments { -- https://github.com/folke/ts-comments.nvim "folke/ts-comments.nvim", enabled = false, }, -- Better text-objects { -- https://github.com/echasnovski/mini.ai "echasnovski/mini.ai", enabled = false, }, -- properly configures LuaLS for editing your Neovim config by lazily updating your workspace libraries --{ -- https://github.com/folke/lazydev.nvim -- "folke/lazydev.nvim", --}, }