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. Co-Authored-by: iGor milhit <igor@milhit.ch>
parent
544891631a
commit
4bbb17461d
12
init.lua
12
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', '<Leader>L', '<Cmd>lua require("luasnip.loaders.from_lua").load({paths = "~/.config/nvim/LuaSnip/"})<CR>', { desc = 'Reload [L]uaSnippets' })
|
||||
|
||||
-- [[ Configure nvim-cmp ]]
|
||||
-- See `:help cmp`
|
||||
local cmp = require 'cmp'
|
||||
|
||||
cmp.setup {
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
|
|
|
@ -0,0 +1,109 @@
|
|||
-- 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. <em>Dorland’s illustrated medical dictionary</em>. 33rd ed.</li>
|
||||
<li>Philadelphia: Elsevier, 2020.</li>
|
||||
<li>Cote : REF 1 W 13 9 ed 33</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 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")
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
Loading…
Reference in New Issue