Compare commits

..

No commits in common. "1d28982b43a6f965e3d3ec190b0625ef19251102" and "44959a0c8af7ee0dea46dded0e560a657a8400a8" have entirely different histories.

9 changed files with 426 additions and 139 deletions

View file

@ -103,7 +103,6 @@
- `mini.visits` - `mini.visits`
- Add [fzf-lua](https://github.com/ibhagwan/fzf-lua) in `vim.fzf-lua` - Add [fzf-lua](https://github.com/ibhagwan/fzf-lua) in `vim.fzf-lua`
- Add [rainbow-delimiters](https://github.com/HiPhish/rainbow-delimiters.nvim) in `vim.visuals.rainbow-delimiters` - Add [rainbow-delimiters](https://github.com/HiPhish/rainbow-delimiters.nvim) in `vim.visuals.rainbow-delimiters`
- Add options to define highlights under [](#opt-vim.highlight)
[kaktu5](https://github.com/kaktu5): [kaktu5](https://github.com/kaktu5):

6
flake.lock generated
View file

@ -77,11 +77,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1737370608, "lastModified": 1735523292,
"narHash": "sha256-hFA6SmioeqvGW/XvZa9bxniAeulksCOcj3kokdNT/YE=", "narHash": "sha256-opBsbR/nrGxiiF6XzlVluiHYb6yN/hEwv+lBWTy9xoM=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "300081d0cc72df578b02d914df941b8ec62240e6", "rev": "6d97d419e5a9b36e6293887a89a078cf85f5a61b",
"type": "github" "type": "github"
}, },
"original": { "original": {

View file

@ -2,7 +2,6 @@
imports = [ imports = [
./basic.nix ./basic.nix
./debug.nix ./debug.nix
./highlight.nix
./spellcheck.nix ./spellcheck.nix
]; ];
} }

View file

@ -1,119 +0,0 @@
{
config,
lib,
...
}: let
inherit (lib.options) mkOption;
inherit (lib.types) nullOr attrsOf listOf submodule bool ints str enum;
inherit (lib.strings) hasPrefix concatLines;
inherit (lib.attrsets) mapAttrsToList;
inherit (lib.nvim.dag) entryBetween;
inherit (lib.nvim.lua) toLuaObject;
inherit (lib.nvim.types) hexColor;
mkColorOption = target:
mkOption {
type = nullOr hexColor;
default = null;
example = "#ebdbb2";
description = ''
The ${target} color to use. Written as color name or hex "#RRGGBB".
'';
};
mkBoolOption = name:
mkOption {
type = nullOr bool;
default = null;
example = false;
description = "Whether to enable ${name}";
};
cfg = config.vim.highlight;
in {
options.vim.highlight = mkOption {
type = attrsOf (submodule {
# See :h nvim_set_hl
options = {
bg = mkColorOption "background";
fg = mkColorOption "foreground";
sp = mkColorOption "special";
blend = mkOption {
type = nullOr (ints.between 0 100);
default = null;
description = "Blend as an integer between 0 and 100";
};
bold = mkBoolOption "bold";
standout = mkBoolOption "standout";
underline = mkBoolOption "underline";
undercurl = mkBoolOption "undercurl";
underdouble = mkBoolOption "underdouble";
underdotted = mkBoolOption "underdotted";
underdashed = mkBoolOption "underdashed";
strikethrough = mkBoolOption "strikethrough";
italic = mkBoolOption "italic";
reverse = mkBoolOption "reverse";
nocombine = mkBoolOption "nocombine";
link = mkOption {
type = nullOr str;
default = null;
description = "The name of another highlight group to link to";
};
default = mkOption {
type = nullOr bool;
default = null;
description = "Don't override existing definition";
};
ctermfg = mkOption {
type = nullOr str;
default = null;
description = "The cterm foreground color to use";
};
ctermbg = mkOption {
type = nullOr str;
default = null;
description = "The cterm background color to use";
};
cterm = mkOption {
type = nullOr (listOf (enum [
"bold"
"underline"
"undercurl"
"underdouble"
"underdotted"
"underdashed"
"strikethrough"
"reverse"
"inverse"
"italic"
"standout"
"altfont"
"nocombine"
"NONE"
]));
default = null;
description = "The cterm arguments to use. See ':h highlight-args'";
};
force = mkBoolOption "force update";
};
});
default = {};
example = {
SignColumn = {
bg = "#282828";
};
};
description = "Custom highlights to apply";
};
config = {
vim.luaConfigRC.highlight = let
highlights =
mapAttrsToList (
name: value: ''vim.api.nvim_set_hl(0, ${toLuaObject name}, ${toLuaObject value})''
)
cfg;
in
entryBetween ["lazyConfigs" "pluginConfigs" "extraPluginConfigs"] ["theme"] (concatLines highlights);
};
}

View file

@ -6,7 +6,30 @@
}: let }: let
inherit (lib.options) mkOption; inherit (lib.options) mkOption;
inherit (lib.modules) mkIf; inherit (lib.modules) mkIf;
inherit (lib.types) bool listOf package str ; inherit
(lib.types)
bool
enum
ints
listOf
package
str
;
inherit
(builtins)
attrNames
concatLists
concatStringsSep
elem
elemAt
filter
hasAttr
isAttrs
length
map
throw
toString
;
cfg = config.vim.languages.tex; cfg = config.vim.languages.tex;
@ -58,8 +81,6 @@ in {
vim.languages.tex.build.builder = { vim.languages.tex.build.builder = {
name = "custom"; name = "custom";
args = collateArgs cfg.build; args = collateArgs cfg.build;
package = cfg.build.builders.custom.package;
executable = cfg.build.builders.custom.executable;
}; };
}; };
} }

View file

@ -1,12 +1,35 @@
{ {
config, config,
pkgs,
lib, lib,
... ...
}: }:
let let
inherit (lib.options) mkOption; inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types) enum listOf package str; inherit
inherit (builtins) attrNames; (lib.types)
bool
enum
ints
listOf
package
str
;
inherit
(builtins)
attrNames
concatLists
concatStringsSep
elem
elemAt
filter
hasAttr
isAttrs
length
map
throw
toString
;
cfg = config.vim.languages.tex; cfg = config.vim.languages.tex;
in in

View file

@ -15,7 +15,21 @@
package package
str str
; ;
inherit (builtins) concatLists elem map toString; inherit
(builtins)
attrNames
concatLists
concatStringsSep
elem
elemAt
filter
hasAttr
isAttrs
length
map
throw
toString
;
cfg = config.vim.languages.tex; cfg = config.vim.languages.tex;
@ -26,6 +40,7 @@
example = !default; example = !default;
description = description; description = description;
}); });
mkEnableLspOption = mkEnableDefaultOption config.vim.languages.enableLSP;
# --- Arg Collation Functions -- # --- Arg Collation Functions --
collateArgs = buildConfig: let collateArgs = buildConfig: let
@ -211,7 +226,6 @@ in {
name = "tectonic"; name = "tectonic";
args = collateArgs cfg.build; args = collateArgs cfg.build;
package = cfg.build.builders.tectonic.package; package = cfg.build.builders.tectonic.package;
executable = cfg.build.builders.tectonic.executable;
}; };
}; };
} }

View file

@ -1,12 +1,46 @@
{ {
config, config,
pkgs,
lib, lib,
... ...
}: let }: let
inherit (lib.options) mkOption; inherit (lib.options) mkOption;
inherit (lib.types) bool str; inherit (lib.modules) mkIf;
inherit
(lib.types)
bool
enum
ints
listOf
package
str
;
inherit
(builtins)
attrNames
concatLists
concatStringsSep
elem
elemAt
filter
hasAttr
isAttrs
length
map
throw
toString
;
cfg = config.vim.languages.tex; cfg = config.vim.languages.tex;
# --- Enable Options ---
mkEnableDefaultOption = default: description: (mkOption {
type = bool;
default = default;
example = !default;
description = description;
});
mkEnableLspOption = mkEnableDefaultOption config.vim.languages.enableLSP;
in { in {
imports = [ imports = [
./builders ./builders

View file

@ -22,6 +22,8 @@
inherit inherit
(lib.types) (lib.types)
bool bool
enum
ints
listOf listOf
package package
str str
@ -29,7 +31,9 @@
inherit inherit
(builtins) (builtins)
attrNames attrNames
concatLists
concatStringsSep concatStringsSep
elem
elemAt elemAt
filter filter
hasAttr hasAttr
@ -50,6 +54,87 @@
description = description; description = description;
}); });
mkEnableLspOption = mkEnableDefaultOption config.vim.languages.enableLSP; mkEnableLspOption = mkEnableDefaultOption config.vim.languages.enableLSP;
# --- Arg Collation Functions --
# collateArgs.lsp.texlab.build = {
# tectonic = buildConfig: let
# selfConfig = buildConfig.tectonic;
# in (
# # Base args
# [
# "-X"
# "compile"
# "%f"
# ]
# # Flags
# ++ (
# if selfConfig.keepIntermediates
# then ["--keep-intermediates"]
# else []
# )
# ++ (
# if selfConfig.keepLogs
# then ["--keep-logs"]
# else []
# )
# ++ (
# if selfConfig.onlyCached
# then ["--only-cached"]
# else []
# )
# ++ (
# if selfConfig.synctex
# then ["--synctex"]
# else []
# )
# ++ (
# if selfConfig.untrustedInput
# then ["--untrusted"]
# else []
# )
# # Options
# ++ (
# if selfConfig.reruns > 0
# then ["--reruns" "${toString selfConfig.reruns}"]
# else []
# )
# ++ (
# if selfConfig.bundle != ""
# then ["--bundle" "${toString selfConfig.bundle}"]
# else []
# )
# ++ (
# if selfConfig.webBundle != ""
# then ["--web-bundle" "${toString selfConfig.webBundle}"]
# else []
# )
# ++ (
# if selfConfig.outfmt != ""
# then ["--outfmt" "${toString selfConfig.outfmt}"]
# else []
# )
# ++ (concatLists (map (x: ["--hide" x]) selfConfig.hidePaths))
# ++ (
# if selfConfig.format != ""
# then ["--format" "${toString selfConfig.format}"]
# else []
# )
# ++ (
# if selfConfig.color != ""
# then ["--color" "${toString selfConfig.color}"]
# else []
# )
# # Still options but these are not defined by builder specific options but
# # instead synchronize options between the global build options and builder
# # specific options
# ++ (
# if !(elem buildConfig.pdfDirectory ["." ""])
# then ["--outdir" "${buildConfig.pdfDirectory}"]
# else []
# )
# );
# custom = buildConfig: buildConfig.custom.args; # Moved
# };
in { in {
options.vim.languages.tex.lsp.texlab = { options.vim.languages.tex.lsp.texlab = {
enable = mkEnableLspOption "Whether to enable Tex LSP support (texlab)"; enable = mkEnableLspOption "Whether to enable Tex LSP support (texlab)";
@ -60,6 +145,201 @@ in {
description = "texlab package"; description = "texlab package";
}; };
# build = {
# tectonic = {
# enable = mkEnableDefaultOption true "Whether to enable Tex Compilation Via Tectonic";
#
# package = mkOption {
# type = package;
# default = pkgs.tectonic;
# description = "tectonic package";
# };
#
# executable = mkOption {
# type = str;
# default = "tectonic";
# description = "The executable name from the build package that will be used to build/compile the tex.";
# };
#
# # -- Flags --
# keepIntermediates = mkEnableDefaultOption false ''
# Keep the intermediate files generated during processing.
#
# If texlab is reporting build errors when there shouldn't be, disable this option.
# '';
# keepLogs = mkEnableDefaultOption true ''
# Keep the log files generated during processing.
#
# Without the keepLogs flag, texlab won't be able to report compilation warnings.
# '';
# onlyCached = mkEnableDefaultOption false "Use only resource files cached locally";
# synctex = mkEnableDefaultOption true "Generate SyncTeX data";
# untrustedInput = mkEnableDefaultOption false "Input is untrusted -- disable all known-insecure features";
#
# # -- Options --
# reruns = mkOption {
# type = ints.unsigned;
# default = 0;
# example = 2;
# description = "Rerun the TeX engine exactly this many times after the first";
# };
#
# bundle = mkOption {
# type = str;
# default = "";
# description = "Use this directory or Zip-format bundle file to find resource files instead of the default";
# };
#
# webBundle = mkOption {
# type = str;
# default = "";
# description = "Use this URL to find resource files instead of the default";
# };
#
# outfmt = mkOption {
# type = enum [
# "pdf"
# "html"
# "xdv"
# "aux"
# "fmt"
# ""
# ];
# default = "";
# description = "The kind of output to generate";
# };
#
# hidePaths = mkOption {
# type = listOf str;
# default = [];
# example = [
# "./secrets.tex"
# "./passwords.tex"
# ];
# description = "Tell the engine that no file at <hide_path> exists, if it tries to read it.";
# };
#
# format = mkOption {
# type = str;
# default = "";
# description = "The name of the \"format\" file used to initialize the TeX engine";
# };
#
# color = mkOption {
# type = enum [
# "always"
# "auto"
# "never"
# ""
# ];
# default = "";
# example = "always";
# description = "Enable/disable colorful log output";
# };
#
# extraOptions = {
# type = listOf str;
# default = [];
# description = ''
# Add extra command line options to include in the tectonic build command.
# Extra options added here will not overwrite the options set in as nvf options.
# '';
# };
# };
# # Moved
# custom = {
# enable = mkEnableDefaultOption false "Whether to enable using a custom build package";
# package = mkOption {
# type = package;
# default = pkgs.tectonic;
# description = "build/compiler package";
# };
# executable = mkOption {
# type = str;
# default = "tectonic";
# description = "The executable name from the build package that will be used to build/compile the tex.";
# };
# args = mkOption {
# type = listOf str;
# default = [
# "-X"
# "compile"
# "%f"
# "--synctex"
# "--keep-logs"
# "--keep-intermediates"
# ];
# description = ''
# Defines additional arguments that are passed to the configured LaTeX build tool.
# Note that flags and their arguments need to be separate elements in this array.
# To pass the arguments -foo bar to a build tool, args needs to be ["-foo" "bar"].
# The placeholder `%f` will be replaced by the server.
#
# Placeholders:
# - `%f`: The path of the TeX file to compile.
# '';
# };
# };
# forwardSearchAfter = mkOption {
# type = bool;
# default = false;
# description = "Set this property to true if you want to execute a forward search after a build.";
# };
# onSave = mkOption {
# type = bool;
# default = false;
# description = "Set this property to true if you want to compile the project after saving a file.";
# };
# useFileList = mkOption {
# type = bool;
# default = false;
# description = ''
# When set to true, the server will use the .fls files produced by the TeX engine as an additional input for the project detection.
#
# Note that enabling this property might have an impact on performance.
# '';
# };
# auxDirectory = mkOption {
# type = str;
# default = ".";
# description = ''
# When not using latexmk, provides a way to define the directory containing the .aux files.
# Note that you need to set the aux directory in latex.build.args too.
#
# When using a latexmkrc file, texlab will automatically infer the correct setting.
# '';
# };
# logDirectory = mkOption {
# type = str;
# default = ".";
# description = ''
# When not using latexmk, provides a way to define the directory containing the build log files.
# Note that you need to change the output directory in your build arguments too.
#
# When using a latexmkrc file, texlab will automatically infer the correct setting.
# '';
# };
# pdfDirectory = mkOption {
# type = str;
# default = ".";
# description = ''
# When not using latexmk, provides a way to define the directory containing the output files.
# Note that you need to set the output directory in latex.build.args too.
#
# When using a latexmkrc file, texlab will automatically infer the correct setting.
# '';
# };
# filename = mkOption {
# type = str;
# default = "";
# description = ''
# Allows overriding the default file name of the build artifact. This setting is used to find the correct PDF file to open during forward search.
# '';
# };
# };
forwardSearch = { forwardSearch = {
enable = mkOption { enable = mkOption {
type = bool; type = bool;
@ -162,8 +442,42 @@ in {
# -- Build -- # -- Build --
buildConfig = let buildConfig = let
# This function will sort through the builder options and count how many # This function will sort through the builder options of ...texlab.build and count how many
# builders have been enabled. # builders have been enabled and get the attrs of the last enabled builder.
# getBuilder = {
# enabledBuildersCount ? 0,
# enabledBuilderName ? "",
# index ? 0,
# builderNamesList ? (
# filter (
# x: let
# y = cfg.build.builders.${x};
# in (isAttrs y && hasAttr "enable" y)
# ) (attrNames cfg.build.builders)
# ),
# }: let
# currentBuilderName = elemAt builderNamesList index;
# currentBuilder = tl.build.${currentBuilderName};
# nextIndex = index + 1;
# currentState = {
# enabledBuildersCount =
# if currentBuilder.enable
# then enabledBuildersCount + 1
# else enabledBuildersCount;
# enabledBuilderName =
# if currentBuilder.enable
# then currentBuilderName
# else enabledBuilderName;
# };
# in
# if length builderNamesList > nextIndex
# then
# getBuilder ({
# inherit builderNamesList;
# index = nextIndex;
# }
# // currentState)
# else currentState;
getEnabledBuildersCount = { getEnabledBuildersCount = {
enabledBuildersCount ? 0, enabledBuildersCount ? 0,
index ? 0, index ? 0,
@ -193,6 +507,8 @@ in {
else newEnabledBuildersCount; else newEnabledBuildersCount;
enabledBuildersCount = getEnabledBuildersCount {}; enabledBuildersCount = getEnabledBuildersCount {};
# builder = tl.build.${getBuilderResults.enabledBuilderName};
# builderArgs = collateArgs.lsp.texlab.build.${getBuilderResults.enabledBuilderName} tl.build;
in in
if enabledBuildersCount == 0 if enabledBuildersCount == 0
then "" then ""