Ændrede diverse ting, især tilføjede jeg en masse lua-snippets
This commit is contained in:
parent
3e9363b016
commit
b1b7a050da
14 changed files with 428 additions and 19 deletions
|
|
@ -25,6 +25,10 @@ return {
|
|||
},
|
||||
config = function()
|
||||
require("luasnip.loaders.from_snipmate").lazy_load()
|
||||
require("luasnip.loaders.from_lua").lazy_load({
|
||||
-- If you set path manually, luasnip has to scan less
|
||||
-- paths = "~/.config/nvim/snippets/",
|
||||
})
|
||||
end,
|
||||
},
|
||||
"saadparwaiz1/cmp_luasnip",
|
||||
|
|
@ -36,7 +40,17 @@ return {
|
|||
config = function()
|
||||
local cmp = require("cmp")
|
||||
local luasnip = require("luasnip")
|
||||
luasnip.config.setup({ enable_autosnippets = true })
|
||||
|
||||
vim.keymap.set(
|
||||
"n",
|
||||
"<Leader>L",
|
||||
"<Cmd>lua require('luasnip.loaders.from_lua').load({paths = '~/.config/nvim/luasnippets/'})<CR>"
|
||||
)
|
||||
luasnip.config.setup({
|
||||
enable_autosnippets = true,
|
||||
store_selection_keys = "<Tab>",
|
||||
update_events = "TextChanged,TextChangedI",
|
||||
})
|
||||
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
|
|
@ -51,22 +65,60 @@ return {
|
|||
["<C-p>"] = cmp.mapping.select_prev_item(),
|
||||
["<C-u>"] = cmp.mapping.scroll_docs(-4),
|
||||
["<C-d>"] = cmp.mapping.scroll_docs(4),
|
||||
["<C-b>"] = cmp.mapping.scroll_docs(-8),
|
||||
["<C-f>"] = cmp.mapping.scroll_docs(8),
|
||||
-- ["<C-b>"] = cmp.mapping.scroll_docs(-8),
|
||||
-- ["<C-f>"] = cmp.mapping.scroll_docs(8),
|
||||
-- Accept ([y]es) the completion
|
||||
["<C-y>"] = cmp.mapping.confirm({ select = true }),
|
||||
["<CR>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
if luasnip.expandable() then
|
||||
luasnip.expand()
|
||||
else
|
||||
cmp.confirm({ select = true })
|
||||
end
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end),
|
||||
-- Manually trigger a completion from nvim-cmp (normally not needed)
|
||||
["<C-Space>"] = cmp.mapping.complete({}),
|
||||
["<C-l>"] = cmp.mapping(function()
|
||||
if luasnip.expand_or_locally_jumpable() then
|
||||
if luasnip.expand_or_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
["<C-j>"] = cmp.mapping(function()
|
||||
if luasnip.expand_or_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
end
|
||||
end, { "n", "i", "s" }),
|
||||
["<C-k>"] = cmp.mapping(function()
|
||||
if luasnip.locally_jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
end
|
||||
end, { "n", "i", "s" }),
|
||||
["<C-h>"] = cmp.mapping(function()
|
||||
if luasnip.locally_jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
-- Better completions, especially for latex
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if luasnip.expand_or_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
elseif luasnip.locally_jumpable(1) then
|
||||
luasnip.jump(1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||
if luasnip.locally_jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
}),
|
||||
sources = {
|
||||
{ name = "nvim_lsp" },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue