Add config.plugins.status.snippets to enable/disable snippets
This commit is contained in:
parent
ee5b79d3d4
commit
2a02054a39
3 changed files with 11 additions and 7 deletions
|
@ -68,6 +68,7 @@ M.plugins = {
|
||||||
lspsignature = true, -- lsp enhancements
|
lspsignature = true, -- lsp enhancements
|
||||||
vim_matchup = true, -- improved matchit
|
vim_matchup = true, -- improved matchit
|
||||||
cmp = true,
|
cmp = true,
|
||||||
|
snippets = true,
|
||||||
nvimtree = true,
|
nvimtree = true,
|
||||||
autopairs = true,
|
autopairs = true,
|
||||||
},
|
},
|
||||||
|
|
|
@ -4,10 +4,12 @@ if not present then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local snippets_status = require("core.utils").load_config().plugins.status.snippets
|
||||||
|
|
||||||
vim.opt.completeopt = "menuone,noselect"
|
vim.opt.completeopt = "menuone,noselect"
|
||||||
|
|
||||||
local default = {
|
local default = {
|
||||||
snippet = {
|
snippet = snippets_status and {
|
||||||
expand = function(args)
|
expand = function(args)
|
||||||
require("luasnip").lsp_expand(args.body)
|
require("luasnip").lsp_expand(args.body)
|
||||||
end,
|
end,
|
||||||
|
@ -40,7 +42,7 @@ local default = {
|
||||||
["<Tab>"] = function(fallback)
|
["<Tab>"] = function(fallback)
|
||||||
if cmp.visible() then
|
if cmp.visible() then
|
||||||
cmp.select_next_item()
|
cmp.select_next_item()
|
||||||
elseif require("luasnip").expand_or_jumpable() then
|
elseif snippents_status and require("luasnip").expand_or_jumpable() then
|
||||||
vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<Plug>luasnip-expand-or-jump", true, true, true), "")
|
vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<Plug>luasnip-expand-or-jump", true, true, true), "")
|
||||||
else
|
else
|
||||||
fallback()
|
fallback()
|
||||||
|
@ -49,7 +51,7 @@ local default = {
|
||||||
["<S-Tab>"] = function(fallback)
|
["<S-Tab>"] = function(fallback)
|
||||||
if cmp.visible() then
|
if cmp.visible() then
|
||||||
cmp.select_prev_item()
|
cmp.select_prev_item()
|
||||||
elseif require("luasnip").jumpable(-1) then
|
elseif snippets_status and require("luasnip").jumpable(-1) then
|
||||||
vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<Plug>luasnip-jump-prev", true, true, true), "")
|
vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<Plug>luasnip-jump-prev", true, true, true), "")
|
||||||
else
|
else
|
||||||
fallback()
|
fallback()
|
||||||
|
|
|
@ -128,19 +128,20 @@ return packer.startup(function()
|
||||||
"rafamadriz/friendly-snippets",
|
"rafamadriz/friendly-snippets",
|
||||||
module = 'cmp_nvim_lsp',
|
module = 'cmp_nvim_lsp',
|
||||||
disable = not plugin_settings.status.cmp,
|
disable = not plugin_settings.status.cmp,
|
||||||
|
disable = not (plugin_settings.status.cmp and plugin_settings.status.snippets),
|
||||||
event = "InsertEnter",
|
event = "InsertEnter",
|
||||||
}
|
}
|
||||||
|
|
||||||
use {
|
use {
|
||||||
"hrsh7th/nvim-cmp",
|
"hrsh7th/nvim-cmp",
|
||||||
disable = not plugin_settings.status.cmp,
|
disable = not plugin_settings.status.cmp,
|
||||||
after ="friendly-snippets",
|
after = plugin_settings.status.snippets and "friendly-snippets",
|
||||||
config = override_req("nvim_cmp", "plugins.configs.cmp", "setup"),
|
config = override_req("nvim_cmp", "plugins.configs.cmp", "setup"),
|
||||||
}
|
}
|
||||||
|
|
||||||
use {
|
use {
|
||||||
"L3MON4D3/LuaSnip",
|
"L3MON4D3/LuaSnip",
|
||||||
disable = not plugin_settings.status.cmp,
|
disable = not (plugin_settings.status.cmp and plugin_settings.status.snippets),
|
||||||
wants = "friendly-snippets",
|
wants = "friendly-snippets",
|
||||||
after = "nvim-cmp",
|
after = "nvim-cmp",
|
||||||
config = override_req("luasnip", "plugins.configs.others", "luasnip"),
|
config = override_req("luasnip", "plugins.configs.others", "luasnip"),
|
||||||
|
@ -148,14 +149,14 @@ return packer.startup(function()
|
||||||
|
|
||||||
use {
|
use {
|
||||||
"saadparwaiz1/cmp_luasnip",
|
"saadparwaiz1/cmp_luasnip",
|
||||||
disable = not plugin_settings.status.cmp,
|
disable = not (plugin_settings.status.cmp and plugin_settings.status.snippets),
|
||||||
after = plugin_settings.options.cmp.lazy_load and "LuaSnip",
|
after = plugin_settings.options.cmp.lazy_load and "LuaSnip",
|
||||||
}
|
}
|
||||||
|
|
||||||
use {
|
use {
|
||||||
"hrsh7th/cmp-nvim-lua",
|
"hrsh7th/cmp-nvim-lua",
|
||||||
disable = not plugin_settings.status.cmp,
|
disable = not plugin_settings.status.cmp,
|
||||||
after = "cmp_luasnip",
|
after = (plugin_settings.status.snippets and "cmp_luasnip") or "nvim-cmp",
|
||||||
}
|
}
|
||||||
|
|
||||||
use {
|
use {
|
||||||
|
|
Loading…
Reference in a new issue