mirror of
https://github.com/kmein/niveum
synced 2026-03-16 18:21:07 +01:00
feat(neovim): luasnip and supertab
This commit is contained in:
@@ -1,18 +1,46 @@
|
||||
local cmp = require'cmp'
|
||||
local cmp = require("cmp")
|
||||
local luasnip = require("luasnip")
|
||||
|
||||
print(vim.g.snippet_directory)
|
||||
if vim.g.snippet_directory then
|
||||
require("luasnip.loaders.from_vscode").lazy_load({
|
||||
paths = { vim.g.snippet_directory }
|
||||
})
|
||||
end
|
||||
|
||||
luasnip.config.set_config({
|
||||
history = true,
|
||||
updateevents = "TextChanged,TextChangedI",
|
||||
enable_autosnippets = true
|
||||
})
|
||||
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
require("luasnip").lsp_expand(args.body)
|
||||
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.
|
||||
}),
|
||||
mapping = {
|
||||
-- https://github.com/hrsh7th/nvim-cmp/wiki/Example-mappings#super-tab-like-mapping
|
||||
['<Tab>'] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif luasnip.expand_or_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, {"i", "s"}),
|
||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip.jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { "i", "s" }),
|
||||
},
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'luasnip' },
|
||||
@@ -21,21 +49,6 @@ cmp.setup({
|
||||
})
|
||||
})
|
||||
|
||||
-- -- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
|
||||
-- cmp.setup.cmdline({ '/', '?' }, {
|
||||
-- mapping = cmp.mapping.preset.cmdline(),
|
||||
-- sources = {
|
||||
-- { name = 'buffer' }
|
||||
-- }
|
||||
-- })
|
||||
|
||||
-- -- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
|
||||
-- cmp.setup.cmdline(':', {
|
||||
-- mapping = cmp.mapping.preset.cmdline(),
|
||||
-- sources = cmp.config.sources({
|
||||
-- { name = 'path' }
|
||||
-- })
|
||||
-- })
|
||||
local capabilities = require('cmp_nvim_lsp').default_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||
|
||||
local opts = { noremap=true, silent=true }
|
||||
|
||||
Reference in New Issue
Block a user