add luasnip config

This commit is contained in:
Charlotte 🦝 Delenk 2022-08-15 15:02:51 +01:00
parent f0e62fe12c
commit 621ba2a368
Signed by: darkkirb
GPG key ID: AB2BD8DAF2E37122
4 changed files with 67 additions and 1 deletions

View file

@ -0,0 +1,10 @@
{pkgs, ...}: {
output.plugins = with pkgs.vimPlugins; [
luasnip
];
output.extraConfig = ''
lua require('luasnip-config')
require("luasnip.loaders.from_vscode").lazy_load()
require("luasnip.loaders.from_vscode").lazy_load({ paths = '${./snippets}' })
'';
}

View file

@ -3,14 +3,19 @@
nvim-cmp
# Various sources
cmp-path
cmp_luasnip
cmp-buffer
cmp-calc
cmp-spell
cmp-path
cmp-nvim-lua
cmp-nvim-lsp
cmp-latex-symbols
];
outputs.extraConfig = "lua require('cmp-config')";
plugin.setup.cmp = {
# TODO: maybe do non-default keybindings?
# See :help cmp-mapping

View file

@ -0,0 +1,26 @@
local cmp = require("cmp")
cmp.setup({
snippet = {
expand = function(args)
require('luasnip').lsp_expand(args.body)
end,
},
mapping = cmp.mapping.preset.insert({
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<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.
}),
sources = cmp.config.sources({
{ name = "nvim_lsp" },
{ name = "luasnip" },
{ name = "buffer" },
{ name = "calc" },
{ name = "spell" },
{ name = "path" },
{ name = "nvim_lua" },
{ name = "latex-symbols" }
})
})

View file

@ -0,0 +1,25 @@
local ls = require('luasnip')
local s = ls.snippet
local i = ls.insert_node
local t = ls.text_node
local c = ls.choice_node
local sn = ls.snippet_node
local isn = ls.indent_snippet_node
local fmt = require('luasnip.extras.fmt').fmt
local types = require("luasnip.util.types")
ls.config.setup({
ext_opts = {
[types.choiceNode] = {
active = {
virt_text = {{"", "GruvboxOrange"}}
}
},
[types.insertNode] = {
active = {
virt_text = {{"", "GruvboxBlue"}}
}
}
},
})