mirror of
https://codeberg.org/leana8959/.files.git
synced 2025-12-06 06:39:14 +00:00
ref(nvim): stylua
This commit is contained in:
parent
f115a84799
commit
531862a6c4
20 changed files with 369 additions and 369 deletions
|
|
@ -1,5 +1,5 @@
|
|||
local cmp = require "cmp"
|
||||
local ls = require "luasnip"
|
||||
local cmp = require("cmp")
|
||||
local ls = require("luasnip")
|
||||
|
||||
local s = ls.snippet
|
||||
local sn = ls.snippet_node
|
||||
|
|
@ -10,28 +10,28 @@ local f = ls.function_node
|
|||
local c = ls.choice_node
|
||||
local d = ls.dynamic_node
|
||||
local r = ls.restore_node
|
||||
local l = require "luasnip.extras".lambda
|
||||
local rep = require "luasnip.extras".rep
|
||||
local p = require "luasnip.extras".partial
|
||||
local m = require "luasnip.extras".match
|
||||
local n = require "luasnip.extras".nonempty
|
||||
local dl = require "luasnip.extras".dynamic_lambda
|
||||
local fmt = require "luasnip.extras.fmt".fmt
|
||||
local fmta = require "luasnip.extras.fmt".fmta
|
||||
local types = require "luasnip.util.types"
|
||||
local conds = require "luasnip.extras.conditions"
|
||||
local conds_expand = require "luasnip.extras.conditions.expand"
|
||||
local l = require("luasnip.extras").lambda
|
||||
local rep = require("luasnip.extras").rep
|
||||
local p = require("luasnip.extras").partial
|
||||
local m = require("luasnip.extras").match
|
||||
local n = require("luasnip.extras").nonempty
|
||||
local dl = require("luasnip.extras").dynamic_lambda
|
||||
local fmt = require("luasnip.extras.fmt").fmt
|
||||
local fmta = require("luasnip.extras.fmt").fmta
|
||||
local types = require("luasnip.util.types")
|
||||
local conds = require("luasnip.extras.conditions")
|
||||
local conds_expand = require("luasnip.extras.conditions.expand")
|
||||
|
||||
local has_words_before = function()
|
||||
unpack = unpack or table.unpack
|
||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match "%s" == nil
|
||||
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
|
||||
end
|
||||
|
||||
-----------------
|
||||
-- Lazy loader --
|
||||
-----------------
|
||||
require "luasnip.loaders.from_vscode".lazy_load { paths = { "./snippets" } }
|
||||
require("luasnip.loaders.from_vscode").lazy_load { paths = { "./snippets" } }
|
||||
|
||||
----------
|
||||
-- Init --
|
||||
|
|
@ -42,11 +42,11 @@ ls.setup { update_events = { "TextChanged", "TextChangedI" } }
|
|||
-- Typst --
|
||||
-----------
|
||||
local function show_date_typst_entry()
|
||||
return os.date "(year: %Y, month: %m, day: %d, hour: %H, minute: %M, second: %S)"
|
||||
return os.date("(year: %Y, month: %m, day: %d, hour: %H, minute: %M, second: %S)")
|
||||
end
|
||||
ls.add_snippets("typst", {
|
||||
s("entry", {
|
||||
t "#entry(",
|
||||
t("#entry("),
|
||||
f(show_date_typst_entry),
|
||||
t { ")[", "" },
|
||||
i(0),
|
||||
|
|
@ -56,7 +56,7 @@ ls.add_snippets("typst", {
|
|||
|
||||
local function get_cms()
|
||||
assert(vim.bo.commentstring ~= "", "comment string is not set")
|
||||
local left = vim.bo.commentstring:gsub("%s*%%s.*", "")
|
||||
local left = vim.bo.commentstring:gsub("%s*%%s.*", "")
|
||||
local right = vim.bo.commentstring:gsub(".*%%s%s*", "")
|
||||
if right == "" then right = left end
|
||||
return { left = left, right = right }
|
||||
|
|
@ -86,7 +86,9 @@ ls.add_snippets("all", {
|
|||
s("banner", {
|
||||
f(horizon, { 1 }),
|
||||
t { "", "" },
|
||||
f(left), i(1), f(right),
|
||||
f(left),
|
||||
i(1),
|
||||
f(right),
|
||||
t { "", "" },
|
||||
f(horizon, { 1 }),
|
||||
}),
|
||||
|
|
@ -95,20 +97,28 @@ ls.add_snippets("all", {
|
|||
------------
|
||||
-- Ledger --
|
||||
------------
|
||||
local function show_date_ledger_entry()
|
||||
return os.date "%Y-%m-%d"
|
||||
end
|
||||
local function show_date_ledger_entry() return os.date("%Y-%m-%d") end
|
||||
-- shortcuts
|
||||
ls.add_snippets("ledger", {
|
||||
s("lessive", {
|
||||
f(show_date_ledger_entry), t " ", t "Lave linge (CROUS)", cr(),
|
||||
t "\texpenses 3,00 EUR", cr(),
|
||||
t "\tassets:compte_courant -3,00 EUR", cr(),
|
||||
f(show_date_ledger_entry),
|
||||
t(" "),
|
||||
t("Lave linge (CROUS)"),
|
||||
cr(),
|
||||
t("\texpenses 3,00 EUR"),
|
||||
cr(),
|
||||
t("\tassets:compte_courant -3,00 EUR"),
|
||||
cr(),
|
||||
}),
|
||||
s("sechoir", {
|
||||
f(show_date_ledger_entry), t " ", t "Sèche linge (CROUS)", cr(),
|
||||
t "\texpenses 1,50 EUR", cr(),
|
||||
t "\tassets:compte_courant -1,50 EUR", cr(),
|
||||
f(show_date_ledger_entry),
|
||||
t(" "),
|
||||
t("Sèche linge (CROUS)"),
|
||||
cr(),
|
||||
t("\texpenses 1,50 EUR"),
|
||||
cr(),
|
||||
t("\tassets:compte_courant -1,50 EUR"),
|
||||
cr(),
|
||||
}),
|
||||
})
|
||||
|
||||
|
|
@ -116,21 +126,43 @@ ls.add_snippets("ledger", {
|
|||
local id = function(args) return args[1][1] end
|
||||
ls.add_snippets("ledger", {
|
||||
s("entry", {
|
||||
f(show_date_ledger_entry), t " ", i(1), cr(),
|
||||
t "\texpenses:", i(2), t " ", i(3), t " EUR", cr(),
|
||||
t "\tassets:compte_courant -", f(id, { 3 }), t " EUR", cr(),
|
||||
f(show_date_ledger_entry),
|
||||
t(" "),
|
||||
i(1),
|
||||
cr(),
|
||||
t("\texpenses:"),
|
||||
i(2),
|
||||
t(" "),
|
||||
i(3),
|
||||
t(" EUR"),
|
||||
cr(),
|
||||
t("\tassets:compte_courant -"),
|
||||
f(id, { 3 }),
|
||||
t(" EUR"),
|
||||
cr(),
|
||||
}),
|
||||
s("date-entry", {
|
||||
i(1), t " ", i(2), cr(),
|
||||
t "\texpenses:", i(3), t " ", i(4), t " EUR", cr(),
|
||||
t "\tassets:compte_courant -", f(id, { 4 }), t " EUR", cr(),
|
||||
i(1),
|
||||
t(" "),
|
||||
i(2),
|
||||
cr(),
|
||||
t("\texpenses:"),
|
||||
i(3),
|
||||
t(" "),
|
||||
i(4),
|
||||
t(" EUR"),
|
||||
cr(),
|
||||
t("\tassets:compte_courant -"),
|
||||
f(id, { 4 }),
|
||||
t(" EUR"),
|
||||
cr(),
|
||||
}),
|
||||
})
|
||||
|
||||
-------------
|
||||
-- Haskell --
|
||||
-------------
|
||||
local haskell_snippets = require "haskell-snippets".all
|
||||
local haskell_snippets = require("haskell-snippets").all
|
||||
ls.add_snippets("haskell", haskell_snippets, { key = "haskell" })
|
||||
|
||||
---------------
|
||||
|
|
@ -146,9 +178,7 @@ end
|
|||
|
||||
cmp.setup {
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
ls.lsp_expand(args.body)
|
||||
end,
|
||||
expand = function(args) ls.lsp_expand(args.body) end,
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert {
|
||||
["<Tab>"] = cmp.mapping(function(fallback) -- Next or jump
|
||||
|
|
@ -183,7 +213,7 @@ cmp.setup {
|
|||
cmp.mapping.confirm {
|
||||
behavior = cmp.ConfirmBehavior.Insert,
|
||||
select = true,
|
||||
} ()
|
||||
}()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
|
|
@ -193,7 +223,7 @@ cmp.setup {
|
|||
cmp.mapping.confirm {
|
||||
behavior = cmp.ConfirmBehavior.Replace,
|
||||
select = true,
|
||||
} ()
|
||||
}()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
|
|
@ -203,20 +233,18 @@ cmp.setup {
|
|||
{ name = "luasnip" },
|
||||
{ name = "nvim_lsp" },
|
||||
{
|
||||
name = "buffer", keyword_length = 10,
|
||||
name = "buffer",
|
||||
keyword_length = 10,
|
||||
option = {
|
||||
enable_in_context = function()
|
||||
return of_filetype { "tex", "markdown", "typst" }
|
||||
end,
|
||||
enable_in_context = function() return of_filetype { "tex", "markdown", "typst" } end,
|
||||
},
|
||||
},
|
||||
{
|
||||
name = "spell", keyword_length = 10,
|
||||
name = "spell",
|
||||
keyword_length = 10,
|
||||
option = {
|
||||
keep_all_entries = true,
|
||||
enable_in_context = function()
|
||||
return of_filetype { "tex", "markdown", "typst" }
|
||||
end,
|
||||
keep_all_entries = true,
|
||||
enable_in_context = function() return of_filetype { "tex", "markdown", "typst" } end,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue