diff --git a/init.lua b/init.lua index e78ac7a..b10acad 100644 --- a/init.lua +++ b/init.lua @@ -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 vim.keymap.set('n', 'L', 'lua require("luasnip.loaders.from_lua").load({paths = "~/.config/nvim/my_snippets/"})', { desc = 'Reload [L]uaSnippets' }) +-- [[ Configure nvim-cmp ]] +-- See `:help cmp` +local cmp = require 'cmp' + cmp.setup { snippet = { expand = function(args) diff --git a/my_snippets/gitcommit.lua b/my_snippets/gitcommit.lua new file mode 100644 index 0000000..d0e71d2 --- /dev/null +++ b/my_snippets/gitcommit.lua @@ -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") + } + ) +} diff --git a/my_snippets/html.lua b/my_snippets/html.lua new file mode 100644 index 0000000..f20133c --- /dev/null +++ b/my_snippets/html.lua @@ -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( + [[ +
+ {2} + +
+ ]], + { + 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( + [[ + {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( + [[ +
  • + + Livre électronique en ligne + . +
  • + ]], + { + i(1, "Ebook URL"), + i(2, "Language code (2 chars)"), + i(3, "Language name") + } + ) + ) +} diff --git a/my_snippets/markdown.lua b/my_snippets/markdown.lua index 052cf26..7883817 100644 --- a/my_snippets/markdown.lua +++ b/my_snippets/markdown.lua @@ -40,7 +40,7 @@ end return { s( { - trig = "datetime", + trig = "dt", name = "Datetime", dscr = "Insert the current datetime with locale daylight saving." }, @@ -48,16 +48,6 @@ return { f(get_datetime, {}) } ), - s( - { - trig = "date", - name = "Date", - dscr = "Insert the current date." - }, - { - f(get_date, {}) - } - ), s( { trig = "id", @@ -78,6 +68,23 @@ return { f(get_day, {}) } ), + s( + { + trig = "ie", + Name = "Inc entry", + dscr = "Insert an Inc entry for today (heading level 2)." + }, + fmt( + [[ + ## {} + + + ]], + { + f(get_day, {}) + } + ) + ), s( { trig = "fm", @@ -112,9 +119,8 @@ return { [[ --- title: {1} - creation_date: {2} - author: iGor milhit - categories: [inc] + date: {2} + id: {4} tags: [notes, quotidien, {3}] --- @@ -122,7 +128,8 @@ return { { f(get_month_year, {}), f(get_datetime, {}), - f(get_month, {}) + f(get_month, {}), + f(get_id, {}) } ) ), @@ -137,13 +144,12 @@ return { [[ [{1}][{2}] - [{2}]: {3} "{4}" + [{2}]: {3} ]], { i(1, "Link text"), i(2, "Reference"), - i(3, "Link target"), - i(4, "Title") + i(3, "Link target") }, { repeat_duplicates = true } ) diff --git a/spell/en.utf-8.add b/spell/en.utf-8.add index be24260..ed88d02 100644 --- a/spell/en.utf-8.add +++ b/spell/en.utf-8.add @@ -9,3 +9,5 @@ Réaménagement biodiversité hyperindustrialisés lacto-fermentation +d'engrain +écorcheuse