keybind inc

This commit is contained in:
THEON-1
2025-11-27 11:24:45 +01:00
parent 4a1006a062
commit 269c827a7b
2 changed files with 27 additions and 7 deletions

View File

@@ -7,13 +7,21 @@ local function markdown(options)
{ "pandoc" }, { "pandoc" },
options_list options_list
) )
table.insert(cmd, "-s")
table.insert(cmd, vim.fn.expand("%:p")) table.insert(cmd, vim.fn.expand("%:p"))
table.insert(cmd, "-o") table.insert(cmd, "-o")
table.insert(cmd, vim.fn.expand("%:p:r") .. ".pdf") table.insert(cmd, vim.fn.expand("%:p:r") .. ".tex")
local pandoc_process = vim.system(cmd) local pandoc_process = vim.system(cmd)
local pandoc_result = pandoc_process:wait() local pandoc_result = pandoc_process:wait()
vim.notify(pandoc_result.stdout, vim.log.levels.INFO);
vim.notify(pandoc_result.stderr, vim.log.levels.ERROR); local pdflatex_process = vim.system({
"pdflatex",
vim.fn.expand("%:p:r") .. ".tex",
})
local pdflatex_result = pdflatex_process:wait()
--vim.notify((pandoc_result.stdout .. "\n\n" .. pdflatex_result.stdout):gsub("^%s*", ""):gsub("%s*$", ""), vim.log.levels.INFO);
vim.notify((pandoc_result.stderr .. "\n\n" .. pdflatex_result.stderr):gsub("^%s*", ""):gsub("%s*$", ""), vim.log.levels.ERROR);
end end
local function arduino(options) local function arduino(options)
@@ -59,6 +67,17 @@ local function arduino(options)
}) })
end end
local function tex(options)
local pdflatex_process = vim.system({
"pdflatex",
vim.fn.expand("%:p"),
})
local pdflatex_result = pdflatex_process:wait()
vim.notify(pdflatex_result.stdout, vim.log.levels.INFO);
vim.notify(pdflatex_result.stderr, vim.log.levels.ERROR);
end
local function run_ft_action(options) local function run_ft_action(options)
local default = { local default = {
__index = function() __index = function()
@@ -68,6 +87,7 @@ local function run_ft_action(options)
local fttable = { local fttable = {
["markdown"] = markdown, ["markdown"] = markdown,
["arduino"] = arduino, ["arduino"] = arduino,
["tex"] = tex,
} }
setmetatable(fttable, default) setmetatable(fttable, default)

View File

@@ -24,12 +24,12 @@ vim.keymap.set("n", "<leader>x", "<cmd>!chmod +x %<CR>", {silent = true})
vim.keymap.set("n", "<leader>sb", function () vim.keymap.set("n", "<leader>sb", function ()
local filetype = vim.bo.filetype local filetype = vim.bo.filetype
local mapping = { local mapping = {
jl = "julia", jl = "/usr/bin/env julia",
julia = "julia", julia = "/usr/bin/env julia",
sh = "bash", sh = "bash",
zsh = "zsh", zsh = "zsh",
py = "/usr/bin/env python3", py = "/usr/bin/env python",
python = "/usr/bin/env python3", python = "/usr/bin/env python",
} }
local command = mapping[filetype] local command = mapping[filetype]
if (command == nil) then return end if (command == nil) then return end