From 4e5765521ac03c2dc91bc53c774dc6f9bdc06e3b Mon Sep 17 00:00:00 2001 From: iGor milhit Date: Wed, 2 Aug 2023 16:26:13 +0200 Subject: [PATCH] snippets: add HTML snippets for library portal - Creates a new file for custom HTML snippets. - Adds 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. - Improves the LuaSnip configuration and moves it outside the nvim-cmp configuration. - Increments the French personal dictionary. Co-Authored-by: iGor milhit --- init.lua | 12 +++-- my_snippets/html.lua | 111 +++++++++++++++++++++++++++++++++++++++++ spell/en.utf-8.add | 1 + spell/en.utf-8.add.spl | Bin 310 -> 335 bytes 4 files changed, 121 insertions(+), 3 deletions(-) create mode 100644 my_snippets/html.lua diff --git a/init.lua b/init.lua index a05c71d..cd55754 100644 --- a/init.lua +++ b/init.lua @@ -547,9 +547,7 @@ mason_lspconfig.setup_handlers { end, } --- [[ Configure nvim-cmp ]] --- See `:help cmp` -local cmp = require 'cmp' +-- [[ Configure LuaSnip ]] local luasnip = require 'luasnip' require('luasnip.loaders.from_vscode').lazy_load() luasnip.config.setup { @@ -564,6 +562,14 @@ luasnip.config.setup { -- Load snippets from ~/.config/nvim/LuaSnip/ require("luasnip.loaders.from_lua").load({paths = "~/.config/nvim/my_snippets/"}) +-- Keymap to reload 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/html.lua b/my_snippets/html.lua new file mode 100644 index 0000000..072d8bb --- /dev/null +++ b/my_snippets/html.lua @@ -0,0 +1,111 @@ +-- 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/spell/en.utf-8.add b/spell/en.utf-8.add index bb424bf..ed88d02 100644 --- a/spell/en.utf-8.add +++ b/spell/en.utf-8.add @@ -10,3 +10,4 @@ biodiversité hyperindustrialisés lacto-fermentation d'engrain +écorcheuse diff --git a/spell/en.utf-8.add.spl b/spell/en.utf-8.add.spl index 28b361d1f3fa41ea0b3b848b3dbd1bcfcbbcd8b7..cad4fd49b2db0a4da0a35a31811902a69731eb49 100644 GIT binary patch delta 138 zcmdnSbe>5n%+t5HAT=k)=syDk!zb>aqjTyBj`Z|bf6*J~BrZMI- zCNX9LaSo7VWMB}OxI{(NDj&quN@Pq0N|!+-v?kt_*YYZ1Jj}QfD3r=r1XALb3FIXM V6%_%=44`N!V=-83>SR7f4FFl0AC?o&Gr7EJ9 s`HYMV44R3Isf_uIWsI3%-o$(ILY^gzhZ$D_g;E)dK!UEBlhqkD0B}zktpET3