remove snippet option for cmp | fix telescope first time delay

This commit is contained in:
siduck 2022-02-12 07:31:23 +05:30
parent ca481b1385
commit a21e884983
3 changed files with 17 additions and 30 deletions

View file

@ -69,7 +69,6 @@ M.plugins = {
lspsignature = true, -- lsp enhancements
vim_matchup = true, -- improved matchit
cmp = true,
snippets = true,
nvimtree = true,
autopairs = true,
},

View file

@ -4,21 +4,13 @@ if not present then
return
end
local snippets_status = require("core.utils").load_config().plugins.status.snippets
vim.opt.completeopt = "menuone,noselect"
local default = {
completion = {
completeopt = "menuone,noselect",
},
documentation = {
border = "single",
},
snippet = (snippets_status and {
snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body)
end,
}) or {
expand = function(_) end,
},
formatting = {
format = function(entry, vim_item)
@ -26,10 +18,9 @@ local default = {
vim_item.kind = string.format("%s %s", icons[vim_item.kind], vim_item.kind)
vim_item.menu = ({
buffer = "[BUF]",
nvim_lsp = "[LSP]",
nvim_lua = "[Lua]",
path = "[Path]",
buffer = "[BUF]",
})[entry.source.name]
return vim_item
@ -46,24 +37,24 @@ local default = {
behavior = cmp.ConfirmBehavior.Replace,
select = true,
},
["<Tab>"] = cmp.mapping(function(fallback)
["<Tab>"] = function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif snippets_status and require("luasnip").expand_or_jumpable() then
require("luasnip").expand_or_jump()
elseif require("luasnip").expand_or_jumpable() then
vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<Plug>luasnip-expand-or-jump", true, true, true), "")
else
fallback()
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback)
end,
["<S-Tab>"] = function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif require("luasnip").jumpable(-1) then
require("luasnip").jump(-1)
vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<Plug>luasnip-jump-prev", true, true, true), "")
else
fallback()
end
end, { "i", "s" }),
end,
},
sources = {
{ name = "nvim_lsp" },

View file

@ -115,7 +115,7 @@ local plugins = {
{
"max397574/better-escape.nvim",
disable = not plugin_settings.status.better_escape,
event = "InsertEnter",
event = "InsertCharPre",
config = override_req("better_escape", "plugins.configs.others", "better_escape"),
},
@ -124,23 +124,20 @@ local plugins = {
{
"rafamadriz/friendly-snippets",
module = "cmp_nvim_lsp",
disable = not (plugin_settings.status.cmp and plugin_settings.status.snippets),
event = "InsertEnter",
disable = not plugin_settings.status.cmp,
event = "InsertCharPre",
},
-- cmp by default loads after friendly snippets
-- if snippets are disabled -> cmp loads on insertEnter!
{
"hrsh7th/nvim-cmp",
disable = not plugin_settings.status.cmp,
event = not plugin_settings.status.snippets and "InsertEnter",
after = plugin_settings.status.snippets and "friendly-snippets",
after = "friendly-snippets",
config = override_req("nvim_cmp", "plugins.configs.cmp", "setup"),
},
{
"L3MON4D3/LuaSnip",
disable = not (plugin_settings.status.cmp and plugin_settings.status.snippets),
disable = not plugin_settings.status.cmp,
wants = "friendly-snippets",
after = "nvim-cmp",
config = override_req("luasnip", "plugins.configs.others", "luasnip"),
@ -148,14 +145,14 @@ local plugins = {
{
"saadparwaiz1/cmp_luasnip",
disable = not (plugin_settings.status.cmp and plugin_settings.status.snippets),
disable = not plugin_settings.status.cmp,
after = plugin_settings.options.cmp.lazy_load and "LuaSnip",
},
{
"hrsh7th/cmp-nvim-lua",
disable = not plugin_settings.status.cmp,
after = (plugin_settings.status.snippets and "cmp_luasnip") or "nvim-cmp",
after = "cmp_luasnip",
},
{