{ lib, helpers, ... }: let inherit (helpers) mkRaw; use_tectonic = false; in { plugins.lsp.servers = { texlab = { enable = true; filetypes = [ "tex" "plaintex" "bib" ]; settings = { texlab = { # -------------------------------- # -- START texlab main config # -- if used with texmagic, disable this # -------------------------------- # https://github.com/latex-lsp/texlab/wiki/Configuration#deprecated-texlabauxdirectory # auxDirectory = "tex_aux_output"; # deprecated rootDirectory = false; build = lib.mkMerge [ (lib.mkIf (!use_tectonic) { executable = "latexmk"; args = [ "-xelatex" "-verbose" # -- "-outdir=%f_output" # -- "-auxdir=%f_aux" "-auxdir=tex_aux_output" "-file-line-error" # https://github.com/latex-lsp/texlab/wiki/Previewing # use for forward serach and inverse search "-synctex=1" "-interaction=nonstopmode" # "-pvc" # preview continuously update instead if -pv (open a new instance) "%f" ]; }) (lib.mkIf use_tectonic { executable = "tectonic"; # https://github.com/latex-lsp/texlab/wiki/Tectonic # V2 args = [ "-X" "compile" "%f" "--synctex" "--keep-logs" "--keep-intermediates" ]; }) { auxDirectory = "tex_aux_output"; logDirectory = "tex_aux_output"; pdfDirectory = "."; # -- forwardSearchAfter = true, isContinuous = true; # -- "onSave = true" failed to work properly with large files like moderncv # -- it would not build properly until you delete all the intermediate files onSave = true; # -------------------------------- # -- END texlab main config # -- if used with texmagic, disable this # -------------------------------- # https://github.com/latex-lsp/texlab/wiki/Previewing#zathura } ]; forwardSearch = { executable = "zathura"; args = [ "--synctex-forward" "%l:1:%f" "%p" ]; }; # Inverse Search for zathura set in ~/.config/zathura/zathurarc # set synctex true # set synctex-editor-command "texlab inverse-search -i %{input} -l %{line}" chktex = { onOpenAndSave = true; onEdit = true; }; # https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/configs/texlab.lua#L179-L183 # https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/configs/texlab.lua#L179-L183 latexindent = { local = ./indentconfig.yaml; }; }; }; }; }; autoCmd = [ { pattern = [ "tex" ]; event = [ "FileType" ]; callback = mkRaw '' function() -- vim.keymap.set( 'n', 'TH', "TexlabBuild", { desc = 'TexlabBuild' }) -- vim.keymap.set( 'n', 'TD', "TexlabCleanAuxiliary", { desc = 'TexlabCleanAuxiliary' }) -- vim.keymap.set( 'n', 'TN', "TexlabForward", { desc = 'TexlabForward' }) vim.keymap.set( 'n', 'TH', function() vim.cmd.TexlabBuild() end, { desc = 'TexlabBuild' }) vim.keymap.set( 'n', 'TD', function() vim.cmd.TexlabCancelBuild(); vim.cmd.TexlabCleanAuxiliary() end, { desc = 'TexlabCancelBuild+CleanAuxiliary' }) vim.keymap.set( 'n', 'Td', function() vim.cmd.TexlabCleanArtifacts() end, { desc = 'TexlabCleanArtifacts' }) vim.keymap.set( 'n', 'TN', function() vim.cmd.TexlabForward() end, { desc = 'TexlabForward' }) end ''; } ]; }