mirror of
https://github.com/LazyVim/starter.git
synced 2026-07-22 04:21:03 +00:00
Set up basic lua snippets
This commit is contained in:
parent
72908fe37b
commit
2aebeeb5a8
4 changed files with 61 additions and 0 deletions
|
|
@ -4,6 +4,14 @@ return {
|
|||
vim.g.user_emmet_settings = {
|
||||
eruby = {
|
||||
extends = "html",
|
||||
snippets = {
|
||||
["r"] = "<%= $0 %>",
|
||||
["rc"] = "<%= render $0 %>",
|
||||
["rp"] = '<%= render partial: "$0" %>',
|
||||
["jw"] = '<a href="https://www.jw.org/">JW.ORG</a>',
|
||||
["turbo-frame"] = '<turbo-frame id="$1">\n\t$0\n</turbo-frame>',
|
||||
["turbo-stream"] = '<turbo-stream action="$1" target="$2">\n\t<template>\n\t\t$0\n\t</template>\n</turbo-stream>',
|
||||
},
|
||||
},
|
||||
}
|
||||
end,
|
||||
|
|
|
|||
25
lua/plugins/luasnip.lua
Normal file
25
lua/plugins/luasnip.lua
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
return {
|
||||
"L3MON4D3/LuaSnip",
|
||||
keys = function()
|
||||
return {
|
||||
{
|
||||
"<Tab>",
|
||||
function()
|
||||
return require("luasnip").expand_or_jumpable() and "<Plug>luasnip-expand-or-jump" or "<Tab>"
|
||||
end,
|
||||
expr = true,
|
||||
mode = "i",
|
||||
},
|
||||
{
|
||||
"<S-Tab>",
|
||||
function()
|
||||
require("luasnip").jump(-1)
|
||||
end,
|
||||
mode = "i",
|
||||
},
|
||||
}
|
||||
end,
|
||||
init = function()
|
||||
require("luasnip.loaders.from_lua").load({ paths = "~/.config/nvim/lua/snippets" })
|
||||
end,
|
||||
}
|
||||
14
lua/snippets/eruby.lua
Normal file
14
lua/snippets/eruby.lua
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
local ls = require("luasnip")
|
||||
local s = ls.snippet
|
||||
local i = ls.insert_node
|
||||
local fmt = require("luasnip.extras.fmt").fmt
|
||||
|
||||
return {
|
||||
s(
|
||||
"tf",
|
||||
fmt('<turbo-frame id="{}">\n\t{}\n</turbo-frame>', {
|
||||
i(1, "frame_idx"),
|
||||
i(0),
|
||||
})
|
||||
),
|
||||
}
|
||||
14
lua/snippets/ruby.lua
Normal file
14
lua/snippets/ruby.lua
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
local ls = require("luasnip")
|
||||
local s = ls.snippet
|
||||
local i = ls.insert_node
|
||||
local fmt = require("luasnip.extras.fmt").fmt
|
||||
|
||||
return {
|
||||
s(
|
||||
"def",
|
||||
fmt("def {}\n\t{}\nend", {
|
||||
i(1, "frame_idx"),
|
||||
i(0),
|
||||
})
|
||||
),
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue