snippets: add HTML and commit snippets

- Creates a new file for custom HTML snippets.
- Creates three snippets to be used when updating the clinical medicine
  library portal with bibliographic descriptions:
  - A main HTML structure with CSS styling.
  - An item with some bibliographic description examples.
  - A list item with a link to an ebook online.
- Creates a snippet for commit message to save working hours.
- Creates snippet for incremental note commits.
- Creates snippet for AoU stats commits.
- Removes redundant markdown snippets for the date.
- Improves the markdown snippet for incremental note entry.
- Improves the LuaSnip configuration and moves it outside the nvim-cmp
  configuration.
- Increments the French personal dictionary.

Co-Authored-by: iGor milhit <igor@milhit.ch>
main
iGor milhit 2023-07-03 09:36:04 +02:00
parent 8162a01e8e
commit 195075d96c
Signed by: igor
GPG Key ID: 692D97C3D0228A99
5 changed files with 193 additions and 18 deletions

View File

@ -563,6 +563,10 @@ require("luasnip.loaders.from_lua").load({paths = "~/.config/nvim/my_snippets/"}
-- https://www.ejmastnak.com/tutorials/vim-latex/luasnip/#refreshing-snippets-from-a-separate-vim-instance -- https://www.ejmastnak.com/tutorials/vim-latex/luasnip/#refreshing-snippets-from-a-separate-vim-instance
vim.keymap.set('n', '<Leader>L', '<Cmd>lua require("luasnip.loaders.from_lua").load({paths = "~/.config/nvim/my_snippets/"})<CR>', { desc = 'Reload [L]uaSnippets' }) vim.keymap.set('n', '<Leader>L', '<Cmd>lua require("luasnip.loaders.from_lua").load({paths = "~/.config/nvim/my_snippets/"})<CR>', { desc = 'Reload [L]uaSnippets' })
-- [[ Configure nvim-cmp ]]
-- See `:help cmp`
local cmp = require 'cmp'
cmp.setup { cmp.setup {
snippet = { snippet = {
expand = function(args) expand = function(args)

View File

@ -0,0 +1,48 @@
local ls = require("luasnip")
local s = ls.snippet
local t = ls.text_node
local f = ls.function_node
local fmt = require("luasnip.extras.fmt").fmt
-- Function to get the current date
local get_date = function()
return os.date("%Y-%m-%d")
end
return {
s(
{
trig = "hr",
name = "Heures",
dscr = "Insert a commit message for saving the worked hours."
},
{
t("organisation: enregistre les heures")
}
),
s(
{
trig = "ic",
name = "Incremental note commit message",
dscr = "Insert a commit message for my incremental notes commits."
},
fmt(
[[
Incrémente la note du {1}
]],
{
f(get_date, {})
}
)
),
s(
{
trig = "aou",
name = "AoU stats commit message",
dscr = "Commit message for an increment of AoU validation statistics."
},
{
t("r+e: incrémente les stats de validation de l'AoU")
}
)
}

View File

@ -0,0 +1,115 @@
-- My HTML snippets
-- Below, the duplicate of brackets, for instance in the CSS code, is for
-- escaping delimiters.
-- Set the local variables (shortcuts)
local ls = require("luasnip")
local s = ls.snippet
local i = ls.insert_node
local fmt = require("luasnip.extras.fmt").fmt
return {
-- A main snippet setting the outer structure, with the style tag.
-- Should be completed with the nested article item below.
s(
{
trig = "mcim",
name = "Main article structure for MC portal",
dscr = "Insert an HTML structure to add bibliographic description on the clinical medicine portal."
},
fmt(
[[
<article class="mc-{1}-main">
{2}
<style>
.mc-{1}-title {{
color: #cf0063;
font-size: xx-large;
}}
.mc-{1}-item > ul > li {{
padding: 0 !important;
}}
.mc-{1}-item li:not([class])::before,
.mc-{1}-item li::before {{
content: none;
}}
</style>
</article>
]],
{
i(1, "Class identifier"),
i(0)
},
{
repeat_duplicates = true
}
)
),
-- Snippet that inserts an article with bibliographic metatada, to be nested
-- in the upper main structure.
s(
{
trig = "mcii",
name = "Item article structure for MC portal",
dscr = "Insert an HTML structure to add an item bibliographic description on the clinical medicine portal."
},
fmt(
[[
<article class="mc-{1}-item">
<ul>
<li>Dorland W. Dorlands illustrated medical dictionary. 4th ed.</li>
<li>Philadelphia: Elsevier, 2020.</li>
<li>Cote : W 13 ed 4</li>
<li>
<a lang="fr"
dir="ltr"
type="html/text"
href="https://slsp-unige.primo.exlibrisgroup.com/articleermalink/41SLSP_UGE/l0hvjc/alma991008098789705502"
hreflang="français"
rel="nofollow"
target="_blank">
Le document dans le catalogue Swisscovery
</a>.
</li>
</ul>
<span placeholder="coins metadata"></span>
</article>{2}
]],
{
i(1, "Class identifier"),
i(0)
},
{
repeat_duplicates = true
}
)
),
-- Snippet that insert a list item with a link to an ebook online.
s(
{
trig = "eli",
name = "List item for an ebook link",
dscr = "Insert a link for an ebook nested in a list item. Designed for the medicine portal HTML structure."
},
fmt(
[[
<li>
<a dir="ltr"
type="html/text"
href="{1}"
lang="{2}"
hreflang="{3}"
ref="nofollow"
target="_blank">
Livre électronique en ligne
</a>.
</li>
]],
{
i(1, "Ebook URL"),
i(2, "Language code (2 chars)"),
i(3, "Language name")
}
)
)
}

View File

@ -40,7 +40,7 @@ end
return { return {
s( s(
{ {
trig = "datetime", trig = "dt",
name = "Datetime", name = "Datetime",
dscr = "Insert the current datetime with locale daylight saving." dscr = "Insert the current datetime with locale daylight saving."
}, },
@ -48,16 +48,6 @@ return {
f(get_datetime, {}) f(get_datetime, {})
} }
), ),
s(
{
trig = "date",
name = "Date",
dscr = "Insert the current date."
},
{
f(get_date, {})
}
),
s( s(
{ {
trig = "id", trig = "id",
@ -78,6 +68,23 @@ return {
f(get_day, {}) f(get_day, {})
} }
), ),
s(
{
trig = "ie",
Name = "Inc entry",
dscr = "Insert an Inc entry for today (heading level 2)."
},
fmt(
[[
## {}
]],
{
f(get_day, {})
}
)
),
s( s(
{ {
trig = "fm", trig = "fm",
@ -112,9 +119,8 @@ return {
[[ [[
--- ---
title: {1} title: {1}
creation_date: {2} date: {2}
author: iGor milhit id: {4}
categories: [inc]
tags: [notes, quotidien, {3}] tags: [notes, quotidien, {3}]
--- ---
@ -122,7 +128,8 @@ return {
{ {
f(get_month_year, {}), f(get_month_year, {}),
f(get_datetime, {}), f(get_datetime, {}),
f(get_month, {}) f(get_month, {}),
f(get_id, {})
} }
) )
), ),
@ -137,13 +144,12 @@ return {
[[ [[
[{1}][{2}] [{1}][{2}]
[{2}]: {3} "{4}" [{2}]: {3}
]], ]],
{ {
i(1, "Link text"), i(1, "Link text"),
i(2, "Reference"), i(2, "Reference"),
i(3, "Link target"), i(3, "Link target")
i(4, "Title")
}, },
{ repeat_duplicates = true } { repeat_duplicates = true }
) )

View File

@ -9,3 +9,5 @@ Réaménagement
biodiversité biodiversité
hyperindustrialisés hyperindustrialisés
lacto-fermentation lacto-fermentation
d'engrain
écorcheuse