Files
nix-config/__devshells.nix
2026-06-07 17:10:46 +02:00

160 lines
3.5 KiB
Nix

{pkgs}: let
nvimCfg = import ./modules/common/nvim-cfg.nix {inherit pkgs;};
texlive = pkgs.texliveBasic.withPackages (
ps: [
ps.beamer
ps.preprint
ps.tikz-ext
ps.latexmk
ps.microtype
ps.mathtools
ps.thmtools
ps.enumitem
ps.csquotes
ps.cleveref
ps.algorithm2e
ps.ifoddpage
ps.relsize
ps.amsfonts
ps.amsmath
ps.geometry
ps.hyperref
ps.lm
ps.xcolor
ps.datetime2
]
);
latexCustomRC = ''
${nvimCfg.baseVimConfig}
lua << EOF
${nvimCfg.baseLuaConfig}
vim.g.vimtex_compiler_method = "latexmk"
vim.g.vimtex_compiler_latexmk = {
build_dir = "",
callback = 1,
continuous = 1,
executable = "latexmk",
options = {
"-pdf",
"-interaction=nonstopmode",
"-synctex=1",
"-file-line-error",
},
}
vim.g.vimtex_view_method = "zathura"
vim.g.vimtex_quickfix_mode = 0
vim.g.plantuml_executable_script = "${pkgs.plantuml}/bin/plantuml"
local capabilities = vim.lsp.protocol.make_client_capabilities()
local ok_cmp_lsp, cmp_lsp = pcall(require, "cmp_nvim_lsp")
if ok_cmp_lsp then
capabilities = cmp_lsp.default_capabilities(capabilities)
end
if vim.lsp and vim.lsp.config then
vim.lsp.config("texlab", {
cmd = { "${pkgs.texlab}/bin/texlab" },
capabilities = capabilities,
settings = {
texlab = {
build = {
executable = "latexmk",
args = {
"-pdf",
"-interaction=nonstopmode",
"-synctex=1",
"-file-line-error",
"%f",
},
onSave = false,
forwardSearchAfter = false,
},
forwardSearch = {
executable = "${pkgs.zathura}/bin/zathura",
args = {
"--synctex-forward",
"%l:1:%f",
"%p",
},
},
},
},
})
vim.lsp.enable("texlab")
end
vim.api.nvim_create_autocmd("FileType", {
pattern = { "tex", "plaintex", "bib" },
callback = function()
local opts = { buffer = true }
vim.keymap.set("n", "<localleader>ll", "<cmd>VimtexCompile<CR>", vim.tbl_extend("force", opts, {
desc = "LaTeX compile",
}))
vim.keymap.set("n", "<localleader>lv", "<cmd>VimtexView<CR>", vim.tbl_extend("force", opts, {
desc = "LaTeX view PDF",
}))
vim.keymap.set("n", "<localleader>lc", "<cmd>VimtexClean<CR>", vim.tbl_extend("force", opts, {
desc = "LaTeX clean",
}))
vim.keymap.set("n", "<localleader>lt", "<cmd>VimtexTocToggle<CR>", vim.tbl_extend("force", opts, {
desc = "LaTeX TOC",
}))
end,
})
EOF
'';
neovimTex = pkgs.wrapNeovim pkgs.neovim-unwrapped {
configure = {
customRC = latexCustomRC;
packages.myNeovimPackages = {
start =
nvimCfg.basePlugins
++ (with pkgs.vimPlugins; [
vimtex
nvim-lspconfig
cmp-nvim-lsp
plantuml-syntax
]);
};
};
};
nvimTex = pkgs.writeShellScriptBin "nvim-tex" ''
set -euo pipefail
exec ${neovimTex}/bin/nvim "$@"
'';
in {
default = pkgs.mkShell {
packages = [
nvimTex
texlive
pkgs.texlab
pkgs.zathura
pkgs.plantuml
pkgs.graphviz
pkgs.jre
pkgs.git
pkgs.ripgrep
pkgs.fd
];
};
}