snippets: add some markdown snippets

- Adds a snippet to create a link in markdown reference syntax.
- Adds a frontmatter snippet for my INC notes.
- Replace the fronmatter snippet for markdown with a formatted one,
  easier to read.
- Improves the description of my markdown snippets.
- Enables the search highlighting.
- Removes unnecessary lualine separator.
- Renames the neo-tree plugin file.
- Lazy loads the zen-mode for markdown files.

Co-Authored-by: iGor milhit <igor@milhit.ch>
iGor milhit 2023-06-10 09:37:35 +02:00
parent c9af70e82e
commit 980b84a0e0
Signed by: igor
GPG Key ID: 692D97C3D0228A99
7 changed files with 88 additions and 30 deletions

View File

@ -160,7 +160,7 @@ require('lazy').setup({
icons_enabled = true, icons_enabled = true,
theme = 'nord', theme = 'nord',
component_separators = '|', component_separators = '|',
section_separators = '/', section_separators = '',
}, },
}, },
}, },
@ -229,7 +229,7 @@ vim.opt.rtp:append (vim.fn.stdpath ('data') .. '/site')
-- NOTE: You can change these options as you wish! -- NOTE: You can change these options as you wish!
-- Set highlight on search -- Set highlight on search
vim.o.hlsearch = false vim.o.hlsearch = true
-- Make line numbers default -- Make line numbers default
vim.wo.number = true vim.wo.number = true

View File

@ -1,4 +1,5 @@
-- Trying to add a custom plugin for file tree -- Plugin for file tree: neo-tree
-- Using the kickstart and the neo-tree documentations
-- Unless you are still migrating, remove the deprecated commands from v1.x -- Unless you are still migrating, remove the deprecated commands from v1.x
vim.cmd([[ let g:neo_tree_remove_legacy_commands = 1 ]]) vim.cmd([[ let g:neo_tree_remove_legacy_commands = 1 ]])

View File

@ -3,6 +3,10 @@
return { return {
"folke/zen-mode.nvim", "folke/zen-mode.nvim",
ft = {
"markdown",
"pandoc"
},
-- Twilight allows to dim text outside of the cursor line. -- Twilight allows to dim text outside of the cursor line.
dependencies = { dependencies = {
"folke/twilight.nvim", "folke/twilight.nvim",

View File

@ -1,14 +0,0 @@
return {
-- A snippet that expands the trigger "hi" into the string "Hello, world!".
require("luasnip").snippet(
{ trig = "hi" },
{ t("Hello, world!") }
),
-- To return multiple snippets, use one `return` statement per snippet file
-- and return a table of Lua snippets.
require("luasnip").snippet(
{ trig = "foo" },
{ t("Another snippet.") }
)
}

View File

@ -3,6 +3,7 @@ local s = ls.snippet
local t = ls.text_node local t = ls.text_node
local i = ls.insert_node local i = ls.insert_node
local f = ls.function_node local f = ls.function_node
local fmt = require("luasnip.extras.fmt").fmt
-- Function to get the datetime -- Function to get the datetime
-- with daylight saving time -- with daylight saving time
@ -11,6 +12,14 @@ local get_date = function()
return os.date("%Y-%m-%dT%H:%M:%S%z") return os.date("%Y-%m-%dT%H:%M:%S%z")
end end
local get_month = function()
return os.date("%B")
end
local get_month_year = function()
return os.date("%B-%Y")
end
-- Function to get an id based on the datetime -- Function to get an id based on the datetime
local get_id = function() local get_id = function()
return os.date("%Y%m%d%H%M%S") return os.date("%Y%m%d%H%M%S")
@ -20,6 +29,7 @@ return {
s( s(
{ {
trig = "datetime", trig = "datetime",
name = "Datetime",
dscr = "Insert datetime with locale daylight saving" dscr = "Insert datetime with locale daylight saving"
}, },
{ {
@ -29,6 +39,7 @@ return {
s( s(
{ {
trig = "id", trig = "id",
Name = "ID",
dscr = "Insert an id based on the datetime" dscr = "Insert an id based on the datetime"
}, },
{ {
@ -37,20 +48,72 @@ return {
), ),
s( s(
{ {
trig = "yaml", trig = "fm",
dscr = "Insert a YAML frontmatter for markdown" name = "YAML frontmatter",
dscr = "Insert a YAML frontmatter for markdown files.\n\nIt has a datetime with the locale daylight saving time, and an ID based on the datetime.\nTab to jump to next text input."
}, },
fmt(
[[
---
title: {1}
date: {3}
id: {4}
tags: [{2}]
---
]],
{
i(1, "title"),
i(2, "tags"),
f(get_date, {}),
f(get_id, {})
}
)
),
s(
{ {
t { "---", "title: " }, trig = "inc",
i(1, "title"), name = "INC YAML frontmatter",
t{ "", "date: " }, dscr = "Insert a YAML frontmatter for INC notes.\n\nIt has a datetime with the locale daylight saving time, prefilled title, author, categories and tags.\nAdjust the title manually."
f(get_date, {}), },
t{ "", "id: " }, fmt(
f(get_id, {}), [[
t{ "","tags: [" }, ---
i(2, "tags"), title: {1}
t{ "]", "---", "" }, creation_date: {2}
i(0), author: iGor milhit
} categories: [inc]
tags: [notes, quotidien, {3}]
---
]],
{
f(get_month_year, {}),
f(get_date, {}),
f(get_month, {})
}
)
),
s(
{
trig="reflink",
name = "Reference link",
dscr="Insert a link with reference syntax",
docstring = "[Link text][Reference]\n\n[Reference]: Link Target \"Title\"\n\nTab to jump to next text input. \"Reference\" is automatically repeated."
},
fmt(
[[
[{1}][{2}]
[{2}]: {3} "{4}"
]],
{
i(1, "Link text"),
i(2, "Reference"),
i(3, "Link target"),
i(4, "Title")
},
{ repeat_duplicates = true }
)
) )
} }

View File

@ -1,2 +1,6 @@
AoU AoU
Floriane Floriane
Séverine
HEG
neovim
lua

Binary file not shown.