[wip] nvim: begin migrating to luasnip

This commit is contained in:
dogeystamp 2024-04-02 22:37:58 -04:00
parent fe67879a1f
commit e327fb4f3e
Signed by: dogeystamp
GPG Key ID: 7225FE3592EFFA38
11 changed files with 54 additions and 21 deletions

16
.gitmodules vendored
View File

@ -73,12 +73,6 @@
path = src/.local/share/nvim/site/pack/3pp/start/typst.vim
url = https://github.com/kaarmu/typst.vim.git
# snippet engine
# ultisnips.vim
[submodule "src/.local/share/nvim/site/pack/3pp/opt/ultisnips"]
path = src/.local/share/nvim/site/pack/3pp/opt/ultisnips
url = https://github.com/SirVer/ultisnips.git
# color theme
# init.lua
[submodule "src/.local/share/nvim/site/pack/3pp/start/nvim-noirbuddy"]
@ -99,3 +93,13 @@
[submodule "src/.local/share/nvim/site/pack/3pp/start/nvim-nio"]
path = src/.local/share/nvim/site/pack/3pp/start/nvim-nio
url = https://github.com/nvim-neotest/nvim-nio
# snippet support
# snippets.lua
# (also coding.lua becuase nvim-cmp uses this too)
[submodule "src/.local/share/nvim/site/pack/3pp/start/LuaSnip"]
path = src/.local/share/nvim/site/pack/3pp/start/LuaSnip
url = https://github.com/L3MON4D3/LuaSnip
[submodule "src/.local/share/nvim/site/pack/3pp/start/cmp_luasnip"]
path = src/.local/share/nvim/site/pack/3pp/start/cmp_luasnip
url = https://github.com/saadparwaiz1/cmp_luasnip

View File

@ -77,8 +77,6 @@ endif
filetype plugin indent on
source $XDG_CONFIG_HOME/nvim/ultisnips.vim
if $SYSTEM_PROFILE == "DEFAULT"
" plugins for IDE-like nvim
source $XDG_CONFIG_HOME/nvim/coding.vim

View File

@ -176,11 +176,16 @@ cmp.setup({
documentation = cmp.config.window.bordered(),
},
mapping = cmp.mapping.preset.insert({
['<C-e>'] = cmp.mapping.abort(),
['<C-f>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
}),
snippet = {
expand = function(args)
require("luasnip").lsp_expand(args.body)
end
},
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
{ name = 'buffer' },
})
}),
})

View File

@ -24,7 +24,7 @@ function M.keymap(key, cmd, params)
end
})
vim.keymap.set(params.mode, key, cmd, { silent = params.silent, noremap = params.noremap })
vim.keymap.set(params.mode, key, cmd, { silent = params.silent, noremap = params.noremap, expr = params.expr })
end
-- see ~/.config/dot_profile.example for info

View File

@ -37,6 +37,7 @@ keymap("<leader>eb", "<cmd>Telescope keymaps<cr>")
--------------------------------
require("theme")
require("snippets")
if dotprofile >= profile_table.DEFAULT then
require("coding")

View File

@ -0,0 +1,28 @@
-- Snippet engine
-- see coding.lua because it also uses luasnip
-- snippets live in .config/nvim/snippets/
local confutil = require("confutil")
local keymap = confutil.keymap
--------------------------------
-- key bindings
--------------------------------
-- could not manage to replicate this behaviour in lua
-- if you nvim_feedkeys to pass through the <Tab> it infinite-loops
-- and also expr seems broken on my keymap() func
vim.cmd([[
imap <silent><expr> <Tab> luasnip#expand_or_jumpable() ? '<Plug>luasnip-expand-or-jump' : '<Tab>'
]])
keymap("<Tab>", "<Plug>luasnip-jump-next", { mode = { "s" } })
keymap("<S-Tab>", "<Plug>luasnip-jump-prev", { mode = { "s", "i" } })
keymap("<C-e>", "<Plug>luasnip-next-choice", { mode = { "s", "i" } })
--------------------------------
-- snippets
--------------------------------
require("luasnip.loaders.from_lua").load({paths = vim.env.XDG_CONFIG_HOME .. "/nvim/snippets"})

View File

@ -0,0 +1,5 @@
return {
s({ trig = "today", desc = "YYYY-MM-DD date of today" }, f(function ()
return os.date("%Y-%m-%d")
end))
}

View File

@ -1,9 +0,0 @@
" snippet engine (see .config/nvim/ultisnips/)
if has('python3') && ($SYSTEM_PROFILE == "DEFAULT" || $SYSTEM_PROFILE == "SLIM")
packadd ultisnips
let g:UltiSnipsExpandTrigger="<tab>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<s-tab>"
let g:UltiSnipsSnippetDirectories=[$HOME.'/.config/nvim/ultisnips/']
endif

@ -1 +0,0 @@
Subproject commit b393ba65386d47664421e1f8b246a87a6e8b218c

@ -0,0 +1 @@
Subproject commit 825a61bad1d60d917a7962d73cf3c683f4e0407e

@ -0,0 +1 @@
Subproject commit 05a9ab28b53f71d1aece421ef32fee2cb857a843