Unconventional commit (check notes)
This commit fixes up completion, making it easier to see what snippet node is currently active, and adding/modifying bindings to work better
This commit is contained in:
parent
88cec5db46
commit
a3ede4bfa4
|
|
@ -1,17 +1,31 @@
|
|||
require("lazy.types")
|
||||
---@type LazySpec[]
|
||||
---@module "lazy"
|
||||
---@type LazySpec
|
||||
return {
|
||||
{
|
||||
"L3MON4D3/LuaSnip",
|
||||
{ "L3MON4D3/LuaSnip",
|
||||
dependencies = {
|
||||
"rafamadriz/friendly-snippets",
|
||||
},
|
||||
config = function()
|
||||
local lua_snippets = vim.fn.stdpath("config") .. "/luasnip"
|
||||
local vscode_snippets = vim.fn.stdpath("config") .. "/snippets"
|
||||
local types = require("luasnip.util.types")
|
||||
require("luasnip.loaders.from_vscode").lazy_load()
|
||||
require("luasnip.loaders.from_vscode").lazy_load({ paths = { vscode_snippets } })
|
||||
require("luasnip.loaders.from_lua").lazy_load({ paths = { lua_snippets } })
|
||||
require("luasnip").config.setup({
|
||||
ext_opts = {
|
||||
[types.choiceNode] = {
|
||||
active = {
|
||||
virt_text = {{"", "GruvboxOrange"}}
|
||||
}
|
||||
},
|
||||
[types.insertNode] = {
|
||||
active = {
|
||||
virt_text = {{"", "GruvboxBlue"}}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
end,
|
||||
lazy = true,
|
||||
},
|
||||
|
|
@ -32,9 +46,16 @@ return {
|
|||
"chrisgrieser/cmp-nerdfont",
|
||||
},
|
||||
opts = function()
|
||||
vim.lsp.config("*", {capabilities = require("cmp_nvim_lsp").default_capabilities()})
|
||||
|
||||
local cmp = require("cmp")
|
||||
local luasnip = require("luasnip")
|
||||
local lspkind = require("lspkind")
|
||||
local cmp_autopairs = require("nvim-autopairs.completion.cmp")
|
||||
cmp.event:on(
|
||||
'confirm_done',
|
||||
cmp_autopairs.on_confirm_done()
|
||||
)
|
||||
---@type cmp.ConfigSchema
|
||||
return {
|
||||
enabled = function()
|
||||
|
|
@ -66,6 +87,20 @@ return {
|
|||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
["x"] = cmp.mapping(function (fallback)
|
||||
if luasnip.choice_active() then
|
||||
luasnip.change_choice(1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end),
|
||||
["z"] = cmp.mapping(function (fallback)
|
||||
if luasnip.choice_active() then
|
||||
luasnip.change_choice(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end),
|
||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
|
|
@ -92,9 +127,16 @@ return {
|
|||
select = false,
|
||||
}),
|
||||
}),
|
||||
["<C-F>"] = cmp.mapping(function(fallback)
|
||||
["<C-F>"] = cmp.mapping(function(_)
|
||||
cmp.complete()
|
||||
end),
|
||||
["<C-A>"] = cmp.mapping(function (fallback)
|
||||
if cmp.visible() then
|
||||
cmp.close()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end)
|
||||
},
|
||||
sources = cmp.config.sources({
|
||||
{ name = "lazydev" },
|
||||
|
|
@ -122,3 +164,4 @@ return {
|
|||
end,
|
||||
},
|
||||
}
|
||||
-- vim: fdl=2
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user