add luasnip config
This commit is contained in:
parent
f0e62fe12c
commit
621ba2a368
4 changed files with 67 additions and 1 deletions
10
config/programs/vim/modules/languages/luasnip.nix
Normal file
10
config/programs/vim/modules/languages/luasnip.nix
Normal 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}' })
|
||||
'';
|
||||
}
|
|
@ -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
|
||||
|
|
26
config/programs/vim/modules/lua/cmp-config.lua
Normal file
26
config/programs/vim/modules/lua/cmp-config.lua
Normal 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" }
|
||||
})
|
||||
})
|
25
config/programs/vim/modules/lua/luasnip-config.lua
Normal file
25
config/programs/vim/modules/lua/luasnip-config.lua
Normal 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"}}
|
||||
}
|
||||
}
|
||||
},
|
||||
})
|
||||
|
Loading…
Reference in a new issue