snippets: add a markdown reference link snippet

- Adds a snippet to create a link in markdown reference syntax.
- Improves the description of my markdown snippets.
- Enables the search highlighting.

Co-Authored-by: iGor milhit <igor@milhit.ch>
iGor milhit 2023-06-10 09:37:35 +02:00
parent c9af70e82e
commit ddb16b8a12
Signed by: igor
GPG Key ID: 692D97C3D0228A99
3 changed files with 27 additions and 15 deletions

View File

@ -229,7 +229,7 @@ vim.opt.rtp:append (vim.fn.stdpath ('data') .. '/site')
-- NOTE: You can change these options as you wish!
-- Set highlight on search
vim.o.hlsearch = false
vim.o.hlsearch = true
-- Make line numbers default
vim.wo.number = true

View File

@ -1,14 +0,0 @@
return {
-- A snippet that expands the trigger "hi" into the string "Hello, world!".
require("luasnip").snippet(
{ trig = "hi" },
{ t("Hello, world!") }
),
-- To return multiple snippets, use one `return` statement per snippet file
-- and return a table of Lua snippets.
require("luasnip").snippet(
{ trig = "foo" },
{ t("Another snippet.") }
)
}

View File

@ -3,6 +3,7 @@ local s = ls.snippet
local t = ls.text_node
local i = ls.insert_node
local f = ls.function_node
local fmt = require("luasnip.extras.fmt").fmt
-- Function to get the datetime
-- with daylight saving time
@ -20,6 +21,7 @@ return {
s(
{
trig = "datetime",
name = "Datetime",
dscr = "Insert datetime with locale daylight saving"
},
{
@ -29,6 +31,7 @@ return {
s(
{
trig = "id",
Name = "ID",
dscr = "Insert an id based on the datetime"
},
{
@ -38,6 +41,7 @@ return {
s(
{
trig = "yaml",
name = "YAML frontmatter",
dscr = "Insert a YAML frontmatter for markdown"
},
{
@ -52,5 +56,27 @@ return {
t{ "]", "---", "" },
i(0),
}
),
s(
{
trig="reflink",
name = "Reference link",
dscr="Insert a link with reference syntax",
docstring = "[Link text][Reference]\n\n[Reference]: Link Target \"Title\"\n\nTab to jump to the next field to fill in. \"Reference\" is automatically repeated."
},
fmt(
[[
[{1}][{2}]
[{2}]: {3} "{4}"
]],
{
i(1, "Link text"),
i(2, "Reference"),
i(3, "Link target"),
i(4, "Title")
},
{ repeat_duplicates = true }
)
)
}