mirror of
https://github.com/marianozunino/nvim.git
synced 2025-06-28 10:33:49 -03:00
chore: add hugo+knap
This commit is contained in:
parent
d75777ef85
commit
a0591215a8
9 changed files with 222 additions and 31 deletions
|
@ -1,6 +1,6 @@
|
|||
local M = {
|
||||
"saghen/blink.cmp",
|
||||
dependencies = "rafamadriz/friendly-snippets",
|
||||
dependencies = { "L3MON4D3/LuaSnip", version = "v2.*" },
|
||||
version = "v0.*",
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,8 @@ M.config = function()
|
|||
nerd_font_variant = "mono",
|
||||
},
|
||||
|
||||
snippets = { preset = "luasnip" },
|
||||
|
||||
sources = {
|
||||
default = { "lsp", "path", "snippets", "buffer", "dadbod" },
|
||||
providers = {
|
||||
|
|
|
@ -24,6 +24,9 @@ return {
|
|||
c = { "clang-format" },
|
||||
cpp = { "clang-format" },
|
||||
hcl = { "hcl" },
|
||||
toml = { "taplo" },
|
||||
htmlhugo = { "prettier" },
|
||||
markdown = { "prettier" },
|
||||
},
|
||||
formatters = {
|
||||
csharpier = {
|
||||
|
@ -38,5 +41,11 @@ return {
|
|||
},
|
||||
notify_on_error = false,
|
||||
})
|
||||
vim.api.nvim_set_keymap(
|
||||
"n",
|
||||
"<leader>cf",
|
||||
'<cmd>lua require("conform").format()<CR>',
|
||||
{ noremap = true, silent = true }
|
||||
)
|
||||
end,
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@ M.config = function()
|
|||
"dist",
|
||||
"build",
|
||||
"coverage",
|
||||
"public",
|
||||
}
|
||||
|
||||
local exclude_opts = ""
|
||||
|
|
103
lua/plugins/hugo.lua
Normal file
103
lua/plugins/hugo.lua
Normal file
|
@ -0,0 +1,103 @@
|
|||
local M = {
|
||||
"phelipetls/vim-hugo",
|
||||
}
|
||||
|
||||
M.config = function()
|
||||
local function is_hugo_project()
|
||||
local config_files = { "hugo.toml", "hugo.yaml", "hugo.json" }
|
||||
for _, file in ipairs(config_files) do
|
||||
if vim.fn.glob(file) ~= "" then
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function get_archetypes()
|
||||
local kinds = {}
|
||||
local archetype_paths = {
|
||||
"archetypes/",
|
||||
"themes/*/archetypes/",
|
||||
}
|
||||
|
||||
for _, path in ipairs(archetype_paths) do
|
||||
local files = vim.fn.glob(path .. "*.md", false, true)
|
||||
for _, file in ipairs(files) do
|
||||
local kind = vim.fn.fnamemodify(file, ":t:r")
|
||||
table.insert(kinds, kind)
|
||||
end
|
||||
end
|
||||
return kinds
|
||||
end
|
||||
|
||||
local function get_content_completions(lead)
|
||||
local search_path = lead:match("^content/") and lead or "content/" .. lead
|
||||
local matches = vim.fn.glob("content/**/*", false, true)
|
||||
|
||||
local completions = {}
|
||||
for _, match in ipairs(matches) do
|
||||
local display = match:gsub("^content/", "")
|
||||
if match:match("^" .. vim.pesc(search_path)) then
|
||||
if vim.fn.isdirectory(match) == 2 then
|
||||
display = display .. "/"
|
||||
end
|
||||
table.insert(completions, display)
|
||||
end
|
||||
end
|
||||
|
||||
return completions
|
||||
end
|
||||
|
||||
local function run_hugo_command(args)
|
||||
local cmd = "hugo " .. table.concat(args, " ")
|
||||
vim.cmd("!" .. cmd)
|
||||
end
|
||||
|
||||
local function hugo_complete_arglead(lead, cmd_line, _)
|
||||
cmd_line = cmd_line:gsub("%s+", " ")
|
||||
|
||||
local parts = vim.split(cmd_line, " ")
|
||||
|
||||
local basic_subcommands = {
|
||||
"server",
|
||||
"new",
|
||||
"help",
|
||||
"version",
|
||||
"config",
|
||||
}
|
||||
|
||||
if #parts <= 2 then
|
||||
return vim.tbl_filter(function(sub)
|
||||
return sub:match("^" .. vim.pesc(lead or ""))
|
||||
end, basic_subcommands)
|
||||
end
|
||||
|
||||
if parts[2] == "new" then
|
||||
if #parts == 3 then
|
||||
return { "content" }
|
||||
end
|
||||
|
||||
if parts[3] == "content" then
|
||||
-- If the previous part is -k or --kind
|
||||
if parts[#parts - 1] == "-k" or parts[#parts - 1] == "--kind" then
|
||||
return get_archetypes()
|
||||
end
|
||||
|
||||
return get_content_completions(lead)
|
||||
end
|
||||
end
|
||||
|
||||
return {}
|
||||
end
|
||||
|
||||
if is_hugo_project() then
|
||||
vim.api.nvim_create_user_command("Hugo", function(opts)
|
||||
run_hugo_command(opts.fargs)
|
||||
end, {
|
||||
nargs = "*",
|
||||
complete = hugo_complete_arglead,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
26
lua/plugins/knap.lua
Normal file
26
lua/plugins/knap.lua
Normal file
|
@ -0,0 +1,26 @@
|
|||
return {
|
||||
{
|
||||
"frabjous/knap",
|
||||
lazy = false,
|
||||
config = function()
|
||||
-- Configure KNAP settings
|
||||
vim.g.knap_settings = {
|
||||
mdoutputext = "pdf",
|
||||
mdtopdf = "pandoc -o %outputfile% --pdf-engine=xelatex",
|
||||
mdtopdfviewerlaunch = "zathura %outputfile%",
|
||||
mdtopdfviewerrefresh = "none",
|
||||
mdtopdfbufferasstdin = true,
|
||||
}
|
||||
|
||||
-- Set up keymappings for all markdown files
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = { "markdown", "pandoc", "md" },
|
||||
callback = function()
|
||||
vim.keymap.set("n", "<leader>kt", function()
|
||||
require("knap").toggle_autopreviewing()
|
||||
end, { buffer = true, desc = "KNAP toggle auto-preview" })
|
||||
end,
|
||||
})
|
||||
end,
|
||||
},
|
||||
}
|
|
@ -10,7 +10,7 @@ local M = {
|
|||
},
|
||||
{
|
||||
"MeanderingProgrammer/render-markdown.nvim",
|
||||
dependencies = { "nvim-treesitter/nvim-treesitter", "echasnovski/mini.nvim" }, -- if you use the mini.nvim suite
|
||||
dependencies = { "nvim-treesitter/nvim-treesitter", "echasnovski/mini.icons" }, -- if you use the mini.nvim suite
|
||||
opts = {},
|
||||
},
|
||||
}
|
||||
|
|
|
@ -1,20 +1,59 @@
|
|||
local M = {
|
||||
|
||||
"L3MON4D3/LuaSnip",
|
||||
version = "v2.*",
|
||||
build = "make install_jsregexp",
|
||||
dependencies = {
|
||||
"rafamadriz/friendly-snippets",
|
||||
-- "saadparwaiz1/cmp_luasnip",
|
||||
},
|
||||
build = "make install_jsregexp",
|
||||
}
|
||||
|
||||
M.config = function()
|
||||
local ls = require("luasnip")
|
||||
local s = ls.snippet
|
||||
local t = ls.text_node
|
||||
local i = ls.insert_node
|
||||
|
||||
ls.setup({
|
||||
history = true, -- Allow jumping back into snippets
|
||||
update_events = "TextChanged,TextChangedI", -- Update snippets as you type
|
||||
|
||||
-- Make sure LuaSnip works well with blink.cmp
|
||||
region_check_events = "CursorMoved,CursorHold,InsertEnter",
|
||||
delete_check_events = "TextChanged,InsertLeave",
|
||||
})
|
||||
|
||||
-- Markdown code block snippets with multiple language support
|
||||
local code_block_langs = {
|
||||
bash = "bash",
|
||||
go = "go",
|
||||
python = "python",
|
||||
javascript = "javascript",
|
||||
typescript = "typescript",
|
||||
rust = "rust",
|
||||
lua = "lua",
|
||||
cpp = "cpp",
|
||||
json = "json",
|
||||
html = "html",
|
||||
css = "css",
|
||||
}
|
||||
|
||||
local code_block_snippets = {}
|
||||
for trigger, lang in pairs(code_block_langs) do
|
||||
table.insert(
|
||||
code_block_snippets,
|
||||
s({ trig = "`" .. trigger, regTrig = false, snippetType = "autosnippet" }, {
|
||||
t({ "", "```" .. lang }),
|
||||
t({ "", "" }),
|
||||
i(1, "# your " .. lang .. " code here"),
|
||||
t({ "", "```" }),
|
||||
})
|
||||
)
|
||||
end
|
||||
|
||||
ls.add_snippets("markdown", code_block_snippets)
|
||||
|
||||
require("luasnip.loaders.from_vscode").lazy_load()
|
||||
require("luasnip.loaders.from_vscode").lazy_load({ paths = vim.fn.stdpath("config") .. "/lua/plugins/snippets/" })
|
||||
require("luasnip").config.set_config({
|
||||
history = true,
|
||||
updateevents = "TextChanged,TextChangedI",
|
||||
})
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
|
@ -3,7 +3,18 @@ return {
|
|||
build = ":TSUpdate",
|
||||
config = function()
|
||||
require("nvim-treesitter.configs").setup({
|
||||
ensure_installed = { "c", "lua", "typescript", "go", "vim", "vimdoc", "query", "markdown", "markdown_inline" },
|
||||
ensure_installed = {
|
||||
"c",
|
||||
"lua",
|
||||
"typescript",
|
||||
"go",
|
||||
"vim",
|
||||
"vimdoc",
|
||||
"query",
|
||||
"markdown",
|
||||
"markdown_inline",
|
||||
"templ",
|
||||
},
|
||||
ignore_install = {},
|
||||
modules = {},
|
||||
sync_install = false,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue