Switched to Alejandra formatting style

This commit is contained in:
isaacST08 2025-01-19 16:05:26 -07:00
commit fb0ddb338e

View file

@ -16,18 +16,19 @@
pkgs, pkgs,
lib, lib,
... ...
}: }: let
let
inherit (lib.options) mkEnableOption mkOption; inherit (lib.options) mkEnableOption mkOption;
inherit (lib.modules) mkIf mkMerge; inherit (lib.modules) mkIf mkMerge;
inherit (lib.types) inherit
(lib.types)
bool bool
listOf listOf
package package
str str
; ;
inherit (lib.nvim.types) mkGrammarOption; inherit (lib.nvim.types) mkGrammarOption;
inherit (builtins) inherit
(builtins)
any any
attrValues attrValues
concatStringsSep concatStringsSep
@ -37,23 +38,18 @@ let
; ;
cfg = config.vim.languages.tex; cfg = config.vim.languages.tex;
in in {
{
options.vim.languages.tex = { options.vim.languages.tex = {
enable = mkEnableOption "Tex support"; enable = mkEnableOption "Tex support";
# Treesitter options for latex and bibtex flavours of tex. # Treesitter options for latex and bibtex flavours of tex.
treesitter = { treesitter = {
latex = { latex = {
enable = mkEnableOption "Latex treesitter" // { enable = mkEnableOption "Latex treesitter" // { default = config.vim.languages.enableTreesitter; };
default = config.vim.languages.enableTreesitter;
};
package = mkGrammarOption pkgs "latex"; package = mkGrammarOption pkgs "latex";
}; };
bibtex = { bibtex = {
enable = mkEnableOption "Bibtex treesitter" // { enable = mkEnableOption "Bibtex treesitter" // { default = config.vim.languages.enableTreesitter; };
default = config.vim.languages.enableTreesitter;
};
package = mkGrammarOption pkgs "bibtex"; package = mkGrammarOption pkgs "bibtex";
}; };
}; };
@ -66,9 +62,7 @@ in
# Each lsp group must have an enable option of its own. # Each lsp group must have an enable option of its own.
lsp = { lsp = {
texlab = { texlab = {
enable = mkEnableOption "Tex LSP support (texlab)" // { enable = mkEnableOption "Tex LSP support (texlab)" // { default = config.vim.languages.enableLSP; };
default = config.vim.languages.enableLSP;
};
package = mkOption { package = mkOption {
type = package; type = package;
@ -286,18 +280,16 @@ in
# Treesitter # Treesitter
(mkIf cfg.treesitter.latex.enable { (mkIf cfg.treesitter.latex.enable {
vim.treesitter.enable = true; vim.treesitter.enable = true;
vim.treesitter.grammars = [ cfg.treesitter.latex.package ]; vim.treesitter.grammars = [cfg.treesitter.latex.package];
}) })
(mkIf cfg.treesitter.bibtex.enable { (mkIf cfg.treesitter.bibtex.enable {
vim.treesitter.enable = true; vim.treesitter.enable = true;
vim.treesitter.grammars = [ cfg.treesitter.bibtex.package ]; vim.treesitter.grammars = [cfg.treesitter.bibtex.package];
}) })
# LSP # LSP
(mkIf (any (x: x.enable) (attrValues cfg.lsp)) ( (mkIf (any (x: x.enable) (attrValues cfg.lsp)) (
{ { vim.lsp.lspconfig.enable = true; } # Enable lspconfig when any of the lsps are enabled
vim.lsp.lspconfig.enable = true; # Enable lspconfig when any of the lsps are enabled
}
// (mkMerge [ // (mkMerge [
# Texlab # Texlab
( (
@ -305,19 +297,28 @@ in
tl = cfg.lsp.texlab; tl = cfg.lsp.texlab;
build = tl.build; build = tl.build;
listToLua = listToLua = list: nullOnEmpty:
list: nullOnEmpty: if length list == 0
if length list == 0 then then
if nullOnEmpty then "null" else "{ }" if nullOnEmpty
else then "null"
"{ ${concatStringsSep ", " (map (x: ''"${toString x}"'') list)} }"; else "{ }"
else "{ ${concatStringsSep ", " (map (x: ''"${toString x}"'') list)} }";
stringToLua = stringToLua = string: nullOnEmpty:
string: nullOnEmpty: if string == "" then if nullOnEmpty then "null" else "" else ''"${string}"''; if string == ""
then
if nullOnEmpty
then "null"
else ""
else ''"${string}"'';
boolToLua = boolean: if boolean then "true" else "false"; boolToLua = boolean:
in if boolean
(mkIf tl.enable { then "true"
else "false";
in (mkIf tl.enable {
vim.lsp.lspconfig.sources.texlab = '' vim.lsp.lspconfig.sources.texlab = ''
lspconfig.texlab.setup { lspconfig.texlab.setup {
cmd = { "${tl.package}/bin/texlab" }, cmd = { "${tl.package}/bin/texlab" },