[wip] nvim: begin migrating to luasnip
This commit is contained in:
parent
fe67879a1f
commit
e327fb4f3e
16
.gitmodules
vendored
16
.gitmodules
vendored
@ -73,12 +73,6 @@
|
|||||||
path = src/.local/share/nvim/site/pack/3pp/start/typst.vim
|
path = src/.local/share/nvim/site/pack/3pp/start/typst.vim
|
||||||
url = https://github.com/kaarmu/typst.vim.git
|
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
|
# color theme
|
||||||
# init.lua
|
# init.lua
|
||||||
[submodule "src/.local/share/nvim/site/pack/3pp/start/nvim-noirbuddy"]
|
[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"]
|
[submodule "src/.local/share/nvim/site/pack/3pp/start/nvim-nio"]
|
||||||
path = 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
|
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
|
||||||
|
@ -77,8 +77,6 @@ endif
|
|||||||
|
|
||||||
filetype plugin indent on
|
filetype plugin indent on
|
||||||
|
|
||||||
source $XDG_CONFIG_HOME/nvim/ultisnips.vim
|
|
||||||
|
|
||||||
if $SYSTEM_PROFILE == "DEFAULT"
|
if $SYSTEM_PROFILE == "DEFAULT"
|
||||||
" plugins for IDE-like nvim
|
" plugins for IDE-like nvim
|
||||||
source $XDG_CONFIG_HOME/nvim/coding.vim
|
source $XDG_CONFIG_HOME/nvim/coding.vim
|
||||||
|
@ -176,11 +176,16 @@ cmp.setup({
|
|||||||
documentation = cmp.config.window.bordered(),
|
documentation = cmp.config.window.bordered(),
|
||||||
},
|
},
|
||||||
mapping = cmp.mapping.preset.insert({
|
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.
|
['<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({
|
sources = cmp.config.sources({
|
||||||
{ name = 'nvim_lsp' },
|
{ name = 'nvim_lsp' },
|
||||||
|
{ name = 'luasnip' },
|
||||||
{ name = 'buffer' },
|
{ name = 'buffer' },
|
||||||
})
|
}),
|
||||||
})
|
})
|
||||||
|
@ -24,7 +24,7 @@ function M.keymap(key, cmd, params)
|
|||||||
end
|
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
|
end
|
||||||
|
|
||||||
-- see ~/.config/dot_profile.example for info
|
-- see ~/.config/dot_profile.example for info
|
||||||
|
@ -37,6 +37,7 @@ keymap("<leader>eb", "<cmd>Telescope keymaps<cr>")
|
|||||||
--------------------------------
|
--------------------------------
|
||||||
|
|
||||||
require("theme")
|
require("theme")
|
||||||
|
require("snippets")
|
||||||
|
|
||||||
if dotprofile >= profile_table.DEFAULT then
|
if dotprofile >= profile_table.DEFAULT then
|
||||||
require("coding")
|
require("coding")
|
||||||
|
28
src/.config/nvim/lua/snippets.lua
Normal file
28
src/.config/nvim/lua/snippets.lua
Normal 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"})
|
5
src/.config/nvim/snippets/all.lua
Normal file
5
src/.config/nvim/snippets/all.lua
Normal 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))
|
||||||
|
}
|
@ -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
|
Loading…
Reference in New Issue
Block a user