More Tab key fixes

This commit is contained in:
Andy Teijelo 2023-12-18 09:33:02 -05:00
parent d2a3415639
commit d4f71ddb0f
3 changed files with 26 additions and 1 deletions

View file

@ -1,3 +1,16 @@
-- Autocmds are automatically loaded on the VeryLazy event -- Autocmds are automatically loaded on the VeryLazy event
-- Default autocmds that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/autocmds.lua -- Default autocmds that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/autocmds.lua
-- Add any additional autocmds here -- Add any additional autocmds here
-- stop snippets when you leave to normal mode
vim.api.nvim_create_autocmd({ "ModeChanged" }, {
callback = function()
if
((vim.v.event.old_mode == "s" and vim.v.event.new_mode == "n") or vim.v.event.old_mode == "i")
and require("luasnip").session.current_nodes[vim.api.nvim_get_current_buf()]
and not require("luasnip").session.jump_active
then
require("luasnip").unlink_current()
end
end,
})

View file

@ -10,3 +10,4 @@ vim.opt.pumblend = 0
vim.opt.tabstop = 4 vim.opt.tabstop = 4
vim.opt.shiftwidth = 4 vim.opt.shiftwidth = 4
vim.g.autoformat = false vim.g.autoformat = false
vim.opt.completeopt = "menuone,noselect,preview"

View file

@ -62,6 +62,16 @@ return {
completion = cmp.config.window.bordered(), completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(), documentation = cmp.config.window.bordered(),
} }
opts.formatting = {
format = function(entry, vim_item)
vim_item.abbr = string.sub(vim_item.abbr, 1, 40)
return vim_item
end,
}
opts.preselect = cmp.PreselectMode.None
opts.completion = {
completeopt = "menuone,noselect,preview",
}
opts.mapping = cmp.mapping.preset.insert({ opts.mapping = cmp.mapping.preset.insert({
["<C-n>"] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }), ["<C-n>"] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }),
["<C-p>"] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }), ["<C-p>"] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }),
@ -69,7 +79,8 @@ return {
["<C-f>"] = cmp.mapping.scroll_docs(4), ["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete(), ["<C-Space>"] = cmp.mapping.complete(),
["<C-e>"] = cmp.mapping.abort(), ["<C-e>"] = cmp.mapping.abort(),
["<CR>"] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. ["<CR>"] = cmp.mapping.confirm({ select = false }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
-- ["<CR>"] = cmp.config.disable,
["<S-CR>"] = cmp.mapping.confirm({ ["<S-CR>"] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Replace, behavior = cmp.ConfirmBehavior.Replace,
select = true, select = true,