mirror of
https://github.com/NotAShelf/nvf.git
synced 2026-04-06 10:59:32 +00:00
Merge pull request #1465 from snoweuph/feat/latex
Some checks are pending
Set up binary cache / cachix (default) (push) Waiting to run
Set up binary cache / cachix (maximal) (push) Waiting to run
Set up binary cache / cachix (nix) (push) Waiting to run
Treewide Checks / Validate flake (push) Waiting to run
Treewide Checks / Check formatting (push) Waiting to run
Treewide Checks / Check source tree for typos (push) Waiting to run
Treewide Checks / Validate documentation builds (push) Waiting to run
Treewide Checks / Validate documentation builds-1 (push) Waiting to run
Treewide Checks / Validate documentation builds-2 (push) Waiting to run
Treewide Checks / Validate documentation builds-3 (push) Waiting to run
Treewide Checks / Validate hyperlinks in documentation sources (push) Waiting to run
Treewide Checks / Validate Editorconfig conformance (push) Waiting to run
Build and deploy documentation / Check latest commit (push) Waiting to run
Build and deploy documentation / publish (push) Blocked by required conditions
Some checks are pending
Set up binary cache / cachix (default) (push) Waiting to run
Set up binary cache / cachix (maximal) (push) Waiting to run
Set up binary cache / cachix (nix) (push) Waiting to run
Treewide Checks / Validate flake (push) Waiting to run
Treewide Checks / Check formatting (push) Waiting to run
Treewide Checks / Check source tree for typos (push) Waiting to run
Treewide Checks / Validate documentation builds (push) Waiting to run
Treewide Checks / Validate documentation builds-1 (push) Waiting to run
Treewide Checks / Validate documentation builds-2 (push) Waiting to run
Treewide Checks / Validate documentation builds-3 (push) Waiting to run
Treewide Checks / Validate hyperlinks in documentation sources (push) Waiting to run
Treewide Checks / Validate Editorconfig conformance (push) Waiting to run
Build and deploy documentation / Check latest commit (push) Waiting to run
Build and deploy documentation / publish (push) Blocked by required conditions
languages/latex: add latex support wiht lsp, formatter and highlighting
This commit is contained in:
commit
a3ea20fceb
4 changed files with 120 additions and 0 deletions
|
|
@ -74,6 +74,7 @@ isMaximal: {
|
||||||
};
|
};
|
||||||
toml.enable = isMaximal;
|
toml.enable = isMaximal;
|
||||||
xml.enable = isMaximal;
|
xml.enable = isMaximal;
|
||||||
|
tex.enable = isMaximal;
|
||||||
|
|
||||||
# Language modules that are not as common.
|
# Language modules that are not as common.
|
||||||
arduino.enable = false;
|
arduino.enable = false;
|
||||||
|
|
|
||||||
|
|
@ -269,6 +269,9 @@
|
||||||
[twig-cs-fixer](https://github.com/VincentLanglet/Twig-CS-Fixer) aren't
|
[twig-cs-fixer](https://github.com/VincentLanglet/Twig-CS-Fixer) aren't
|
||||||
packaged for nix.
|
packaged for nix.
|
||||||
|
|
||||||
|
- Added `languages.tex`. Currently only highlighting, formatting and lsp. No
|
||||||
|
previewing yet.
|
||||||
|
|
||||||
- Didn't Add
|
- Didn't Add
|
||||||
[`syntax-gaslighting`](https://github.com/NotAShelf/syntax-gaslighting.nvim),
|
[`syntax-gaslighting`](https://github.com/NotAShelf/syntax-gaslighting.nvim),
|
||||||
you're crazy.
|
you're crazy.
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ in {
|
||||||
./json.nix
|
./json.nix
|
||||||
./lua.nix
|
./lua.nix
|
||||||
./markdown.nix
|
./markdown.nix
|
||||||
|
./tex.nix
|
||||||
./nim.nix
|
./nim.nix
|
||||||
./vala.nix
|
./vala.nix
|
||||||
./nix.nix
|
./nix.nix
|
||||||
|
|
|
||||||
115
modules/plugins/languages/tex.nix
Normal file
115
modules/plugins/languages/tex.nix
Normal file
|
|
@ -0,0 +1,115 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
pkgs,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
inherit (builtins) attrNames;
|
||||||
|
inherit (lib.meta) getExe;
|
||||||
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
|
inherit (lib.options) literalExpression mkEnableOption mkOption;
|
||||||
|
inherit (lib.types) bool enum listOf;
|
||||||
|
inherit (lib.nvim.types) mkGrammarOption;
|
||||||
|
inherit (lib.nvim.attrsets) mapListToAttrs;
|
||||||
|
|
||||||
|
cfg = config.vim.languages.tex;
|
||||||
|
defaultServers = ["texlab"];
|
||||||
|
servers = {
|
||||||
|
texlab = {
|
||||||
|
enable = true;
|
||||||
|
cmd = [(getExe pkgs.texlab) "run"];
|
||||||
|
filetypes = ["plaintex" "tex" "bib"];
|
||||||
|
root_markers = [".git" ".latexmkrc" "latexmkrc" ".texlabroot" "texlabroot" ".texstudio" "Tectonic.toml"];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
defaultFormat = ["tex-fmt"];
|
||||||
|
formats = {
|
||||||
|
tex-fmt = {
|
||||||
|
command = getExe pkgs.tex-fmt;
|
||||||
|
};
|
||||||
|
latexindent = {
|
||||||
|
command = "${pkgs.texlive.withPackages (ps: [ps.latexindent])}/bin/latexindent";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
in {
|
||||||
|
options.vim.languages.tex = {
|
||||||
|
enable = mkEnableOption "TeX language support";
|
||||||
|
|
||||||
|
treesitter = {
|
||||||
|
enable = mkOption {
|
||||||
|
type = bool;
|
||||||
|
default = config.vim.languages.enableTreesitter;
|
||||||
|
defaultText = literalExpression "config.vim.languages.enableTreesitter";
|
||||||
|
description = "Enable TeX treesitter";
|
||||||
|
};
|
||||||
|
latexPackage = mkGrammarOption pkgs "latex";
|
||||||
|
bibtexPackage = mkGrammarOption pkgs "bibtex";
|
||||||
|
};
|
||||||
|
|
||||||
|
lsp = {
|
||||||
|
enable =
|
||||||
|
mkEnableOption "TeX LSP support"
|
||||||
|
// {
|
||||||
|
default = config.vim.lsp.enable;
|
||||||
|
defaultText = literalExpression "config.vim.lsp.enable";
|
||||||
|
};
|
||||||
|
|
||||||
|
servers = mkOption {
|
||||||
|
description = "TeX LSP server to use";
|
||||||
|
type = listOf (enum (attrNames servers));
|
||||||
|
default = defaultServers;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
format = {
|
||||||
|
enable =
|
||||||
|
mkEnableOption "TeX formatting"
|
||||||
|
// {
|
||||||
|
default = config.vim.languages.enableFormat;
|
||||||
|
defaultText = literalExpression "config.vim.languages.enableFormat";
|
||||||
|
};
|
||||||
|
|
||||||
|
type = mkOption {
|
||||||
|
type = listOf (enum (attrNames formats));
|
||||||
|
default = defaultFormat;
|
||||||
|
description = "TeX formatter to use";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf cfg.enable (mkMerge [
|
||||||
|
(mkIf cfg.treesitter.enable {
|
||||||
|
vim.treesitter.enable = true;
|
||||||
|
vim.treesitter.grammars = [
|
||||||
|
cfg.treesitter.latexPackage
|
||||||
|
cfg.treesitter.bibtexPackage
|
||||||
|
];
|
||||||
|
})
|
||||||
|
|
||||||
|
(mkIf cfg.lsp.enable {
|
||||||
|
vim.lsp.servers =
|
||||||
|
mapListToAttrs (n: {
|
||||||
|
name = n;
|
||||||
|
value = servers.${n};
|
||||||
|
})
|
||||||
|
cfg.lsp.servers;
|
||||||
|
})
|
||||||
|
|
||||||
|
(mkIf cfg.format.enable {
|
||||||
|
vim.formatter.conform-nvim = {
|
||||||
|
enable = true;
|
||||||
|
setupOpts = {
|
||||||
|
formatters_by_ft.tex = cfg.format.type;
|
||||||
|
formatters_by_ft.plaintex = cfg.format.type;
|
||||||
|
formatters =
|
||||||
|
mapListToAttrs (name: {
|
||||||
|
inherit name;
|
||||||
|
value = formats.${name};
|
||||||
|
})
|
||||||
|
cfg.format.type;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
})
|
||||||
|
]);
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue