Ændrede diverse ting, især tilføjede jeg en masse lua-snippets
This commit is contained in:
parent
3e9363b016
commit
b1b7a050da
14 changed files with 428 additions and 19 deletions
62
lua/luasnip-helpers.lua
Normal file
62
lua/luasnip-helpers.lua
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
local M = {}
|
||||
|
||||
local ls = require("luasnip")
|
||||
local s = ls.snippet
|
||||
|
||||
local in_mathzone = function()
|
||||
return vim.fn["vimtex#syntax#in_mathzone"]() == 1
|
||||
end
|
||||
|
||||
local in_text = function()
|
||||
return vim.fn["vimtex#syntax#in_mathzone"]() == 0
|
||||
end
|
||||
|
||||
M.in_mathzone = in_mathzone
|
||||
M.in_text = in_text
|
||||
|
||||
-- "as" for "Auto snippet"
|
||||
local function as(trigger, nodes, opts)
|
||||
opts = opts or {}
|
||||
-- Add snippetType = "autosnippet" to the first parameter
|
||||
if type(trigger) == "table" then
|
||||
trigger.snippetType = "autosnippet"
|
||||
else
|
||||
trigger = { trig = trigger, snippetType = "autosnippet" }
|
||||
end
|
||||
return s(trigger, nodes, opts)
|
||||
end
|
||||
|
||||
M.as = as
|
||||
|
||||
-- "asm" for "Auto snippet math"
|
||||
function M.asm(trigger, nodes, opts)
|
||||
-- Only trigger commands in mathzones
|
||||
opts = opts or {}
|
||||
opts.condition = in_mathzone
|
||||
return as(trigger, nodes, opts)
|
||||
end
|
||||
-- Add snippetType = "autosnippet" to the first parameter
|
||||
-- if type(trigger) == "table" then
|
||||
-- trigger.snippetType = "autosnippet"
|
||||
-- else
|
||||
-- trigger = { trig = trigger, snippetType = "autosnippet" }
|
||||
-- end
|
||||
-- return s(trigger, nodes, opts)
|
||||
-- end
|
||||
|
||||
-- "ast" for "Auto snippet text"
|
||||
function M.ast(trigger, nodes, opts)
|
||||
-- Only trigger commands in mathzones
|
||||
opts = opts or {}
|
||||
opts.condition = in_text
|
||||
return as(trigger, nodes, opts)
|
||||
-- -- Add snippetType = "autosnippet" to the first parameter
|
||||
-- if type(trigger) == "table" then
|
||||
-- trigger.snippetType = "autosnippet"
|
||||
-- else
|
||||
-- trigger = { trig = trigger, snippetType = "autosnippet" }
|
||||
-- end
|
||||
-- return s(trigger, nodes, opts)
|
||||
end
|
||||
--
|
||||
return M
|
||||
Loading…
Add table
Add a link
Reference in a new issue