switch to lua-snipp
This commit is contained in:
parent
42da1305d4
commit
24bec72fe8
4 changed files with 65 additions and 5 deletions
|
@ -6,8 +6,9 @@ require('pluginoptions')
|
||||||
|
|
||||||
-- PLUGIN OPTIONS
|
-- PLUGIN OPTIONS
|
||||||
require('telescopeconfig')
|
require('telescopeconfig')
|
||||||
|
require('statusline')
|
||||||
|
require('snippets')
|
||||||
require('autocompletion')
|
require('autocompletion')
|
||||||
require('treesitterconfig')
|
require('treesitterconfig')
|
||||||
require('filemanager')
|
require('filemanager')
|
||||||
require('statusline')
|
|
||||||
require('notes')
|
require('notes')
|
||||||
|
|
|
@ -1,15 +1,17 @@
|
||||||
-- Setup nvim-cmp.
|
-- Setup nvim-cmp.
|
||||||
local cmp = require'cmp'
|
local cmp = require 'cmp'
|
||||||
|
|
||||||
cmp.setup({
|
cmp.setup({
|
||||||
snippet = {
|
snippet = {
|
||||||
expand = function(args)
|
expand = function(args)
|
||||||
vim.fn['UltiSnips#Anon'](args.body) -- For `ultisnips` users.
|
require('luasnip').lsp_expand(args.body)
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
mapping = {
|
mapping = {
|
||||||
['<C-b>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }),
|
['<C-b>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }),
|
||||||
['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }),
|
['<C-f>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }),
|
||||||
|
['<C-n>'] = cmp.mapping(cmp.mapping.select_next_item(), {'i','c'}),
|
||||||
|
['<C-p>'] = cmp.mapping(cmp.mapping.select_prev_item(), {'i','c'}),
|
||||||
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
|
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
|
||||||
['<C-y>'] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping.
|
['<C-y>'] = cmp.config.disable, -- Specify `cmp.config.disable` if you want to remove the default `<C-y>` mapping.
|
||||||
['<C-e>'] = cmp.mapping({
|
['<C-e>'] = cmp.mapping({
|
||||||
|
@ -22,6 +24,7 @@ cmp.setup({
|
||||||
},
|
},
|
||||||
sources = cmp.config.sources({
|
sources = cmp.config.sources({
|
||||||
{ name = 'nvim_lsp' },
|
{ name = 'nvim_lsp' },
|
||||||
|
{ name = 'luasnip' },
|
||||||
}, {
|
}, {
|
||||||
{ name = 'buffer' },
|
{ name = 'buffer' },
|
||||||
})
|
})
|
||||||
|
|
|
@ -76,8 +76,8 @@ Plug 'hrsh7th/cmp-path'
|
||||||
Plug 'hrsh7th/cmp-cmdline'
|
Plug 'hrsh7th/cmp-cmdline'
|
||||||
Plug 'hrsh7th/nvim-cmp'
|
Plug 'hrsh7th/nvim-cmp'
|
||||||
|
|
||||||
Plug 'SirVer/ultisnips'
|
Plug 'L3MON4D3/LuaSnip'
|
||||||
Plug 'quangnguyen30192/cmp-nvim-ultisnips'
|
Plug 'saadparwaiz1/cmp_luasnip'
|
||||||
|
|
||||||
-- Autoformatter
|
-- Autoformatter
|
||||||
Plug 'sbdchd/neoformat'
|
Plug 'sbdchd/neoformat'
|
||||||
|
|
56
nvim/lua/snippets.lua
Normal file
56
nvim/lua/snippets.lua
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
local ls = require "luasnip"
|
||||||
|
|
||||||
|
local types = require "luasnip.util.types"
|
||||||
|
|
||||||
|
ls.config.set_config {
|
||||||
|
history = true,
|
||||||
|
updateevents = "TextChanged,TextChangedI",
|
||||||
|
|
||||||
|
enable_autosnippets = true,
|
||||||
|
|
||||||
|
ext_opts = {
|
||||||
|
[types.choiceNode] = {
|
||||||
|
active = {
|
||||||
|
virt_text = { { "<-", "Error" } },
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
-- expand snippet / jump to next location
|
||||||
|
vim.keymap.set({"i", "s" }, "<c-k>", function()
|
||||||
|
if ls.expand_or_jumpable() then
|
||||||
|
ls.expand_or_jump()
|
||||||
|
end
|
||||||
|
end, { silent = true })
|
||||||
|
|
||||||
|
-- jump to previous location
|
||||||
|
vim.keymap.set({"i", "s" }, "<c-j>", function()
|
||||||
|
if ls.jumpable(-1) then
|
||||||
|
ls.jump(-1)
|
||||||
|
end
|
||||||
|
end, { silent = true })
|
||||||
|
|
||||||
|
-- jump to previous location
|
||||||
|
vim.keymap.set({"i"}, "<c-l>", function()
|
||||||
|
if ls.choice_active() then
|
||||||
|
ls.change_choice(1)
|
||||||
|
end
|
||||||
|
end, { silent = true })
|
||||||
|
|
||||||
|
-- source luafile again
|
||||||
|
vim.keymap.set("n", "<leader><leader>s", "<cmd>source ~/.config/nvim/lua/snippets.lua<CR>")
|
||||||
|
|
||||||
|
local s = ls.s
|
||||||
|
local i = ls.insert_node
|
||||||
|
local rep = require("luasnip.extras").rep
|
||||||
|
local fmt = require("luasnip.extras.fmt").fmt
|
||||||
|
|
||||||
|
|
||||||
|
ls.add_snippets("tex", {
|
||||||
|
s("beg", fmt([[
|
||||||
|
\begin{<>}
|
||||||
|
<>
|
||||||
|
\end{<>}
|
||||||
|
]], {i(1, "itemize"), i(2, "test"), rep(1)}, {delimiters = "<>"})),
|
||||||
|
})
|
Loading…
Add table
Reference in a new issue