feat: add latex compile command

feat: add latex compile command
This commit is contained in:
2025-11-01 12:28:27 +01:00
parent 7a329aaa36
commit 652e2fd450
4 changed files with 66 additions and 23 deletions

View File

@@ -49,6 +49,7 @@ require 'browsher'.setup({
})
require 'naxdy.format'.setup()
require 'naxdy.latexcompile'.setup()
-- autosave
local group = vim.api.nvim_create_augroup('autosave', {})

View File

@@ -1,24 +1,27 @@
if client.workspace_folders then
local path = client.workspace_folders[1].name
if vim.uv.fs_stat(path .. '/.luarc.json') or vim.uv.fs_stat(path .. '/.luarc.jsonc') then
return
function(client)
if client.workspace_folders then
local path = client.workspace_folders[1].name
if vim.uv.fs_stat(path .. '/.luarc.json') or vim.uv.fs_stat(path .. '/.luarc.jsonc') then
return
end
end
end
client.config.settings.Lua = vim.tbl_deep_extend('force', client.config.settings.Lua or {}, {
runtime = {
-- Tell the language server which version of Lua you're using
-- (most likely LuaJIT in the case of Neovim)
version = 'LuaJIT'
},
-- Make the server aware of Neovim runtime files
workspace = {
checkThirdParty = false,
library = {
vim.env.VIMRUNTIME
-- Depending on the usage, you might want to add additional paths here.
-- "${3rd}/luv/library"
-- "${3rd}/busted/library",
client.config.settings.Lua = vim.tbl_deep_extend("force", client.config.settings.Lua or {}, {
runtime = {
-- Tell the language server which version of Lua you're using
-- (most likely LuaJIT in the case of Neovim)
version = 'LuaJIT'
},
-- Make the server aware of Neovim runtime files
workspace = {
checkThirdParty = false,
library = {
vim.env.VIMRUNTIME,
vim.api.nvim_get_runtime_file('', true),
-- Depending on the usage, you might want to add additional paths here.
-- "${3rd}/luv/library"
-- "${3rd}/busted/library",
}
}
}
})
})
end

32
naxdy/latexcompile.lua Normal file
View File

@@ -0,0 +1,32 @@
local M = {
compiling_buffers = {}
}
M.setup = function()
local group = vim.api.nvim_create_augroup("LatexCompile", {})
vim.api.nvim_create_autocmd("BufWritePost", {
group = group,
desc = "Compile LaTeX on save",
callback = M.compile
})
end
M.compile = function(options)
local bufnr = options.buf
if M.compiling_buffers[bufnr] then
return
end
local filename = vim.fn.bufname(bufnr)
if filename:sub(- #".tex") == ".tex" then
M.compiling_buffers[bufnr] = true
vim.system({ "pdflatex", filename }, {}, function()
M.compiling_buffers[bufnr] = nil
end)
end
end
return M

View File

@@ -10,10 +10,12 @@
luau-lsp,
nixfmt-rfc-style,
nixvim,
nodejs,
pkgs,
shellcheck,
sscli,
tofu-ls,
tree-sitter,
vimPlugins,
vimUtils,
vscode-js-debug,
@@ -677,8 +679,10 @@ nixvim.makeNixvim {
jq # js-i18n needs this
lazygit
luau-lsp
nodejs
shellcheck
sscli
tree-sitter
];
# extraFiles = {
@@ -1430,8 +1434,11 @@ nixvim.makeNixvim {
filetypes = [
"lua"
];
onAttach = {
function = builtins.readFile ./lspconfig.lua;
extraOptions = {
on_init.__raw = builtins.readFile ./lspconfig.lua;
};
settings = {
Lua.__raw = "{}";
};
};
pyright.enable = true;