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 <igor@milhit.ch>
parent
327fbe7256
commit
279d078208
12
init.lua
12
init.lua
|
@ -547,9 +547,7 @@ mason_lspconfig.setup_handlers {
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
-- [[ Configure nvim-cmp ]]
|
-- [[ Configure LuaSnip ]]
|
||||||
-- See `:help cmp`
|
|
||||||
local cmp = require 'cmp'
|
|
||||||
local luasnip = require 'luasnip'
|
local luasnip = require 'luasnip'
|
||||||
require('luasnip.loaders.from_vscode').lazy_load()
|
require('luasnip.loaders.from_vscode').lazy_load()
|
||||||
luasnip.config.setup {
|
luasnip.config.setup {
|
||||||
|
@ -564,6 +562,14 @@ luasnip.config.setup {
|
||||||
-- Load snippets from ~/.config/nvim/LuaSnip/
|
-- Load snippets from ~/.config/nvim/LuaSnip/
|
||||||
require("luasnip.loaders.from_lua").load({paths = "~/.config/nvim/my_snippets/"})
|
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', '<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)
|
||||||
|
|
|
@ -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(
|
||||||
|
[[
|
||||||
|
<article class="mc-{1}-main">
|
||||||
|
{2}
|
||||||
|
<style>
|
||||||
|
.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. Dorland’s 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")
|
||||||
|
}
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
|
@ -10,3 +10,4 @@ biodiversité
|
||||||
hyperindustrialisés
|
hyperindustrialisés
|
||||||
lacto-fermentation
|
lacto-fermentation
|
||||||
d'engrain
|
d'engrain
|
||||||
|
écorcheuse
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue