mirror of
https://github.com/NotAShelf/nvf.git
synced 2026-01-04 09:47:16 +00:00
Migrated lsp configs to new standard (non-lspconfig)
This commit is contained in:
parent
233490941b
commit
d104e383fc
4 changed files with 108 additions and 596 deletions
107
modules/plugins/languages/tex/lsp.nix
Normal file
107
modules/plugins/languages/tex/lsp.nix
Normal file
|
|
@ -0,0 +1,107 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) getExe;
|
||||
inherit (lib.attrsets) optionalAttrs attrNames hasAttrByPath;
|
||||
inherit (lib.options) mkEnableOption mkOption;
|
||||
inherit (lib.nvim.types) deprecatedSingleOrListOf;
|
||||
inherit (lib.types) enum;
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.nvim.attrsets) mapListToAttrs;
|
||||
|
||||
cfg = config.vim.languages.tex;
|
||||
builderCfg = cfg.build.builder;
|
||||
|
||||
pdfViewer = cfg.pdfViewer.viewers.${cfg.pdfViewer.name};
|
||||
|
||||
# **===========================================**
|
||||
# || <<<<< LSP SERVERS >>>>> ||
|
||||
# **===========================================**
|
||||
|
||||
defaultServers = ["texlab"];
|
||||
|
||||
servers = {
|
||||
texlab = {
|
||||
cmd = [(getExe pkgs.texlab)];
|
||||
filetypes = ["tex" "plaintex" "context"];
|
||||
root_markers = [".git"];
|
||||
capabilities = {
|
||||
settings.texlab = (
|
||||
{
|
||||
# -- Completion --
|
||||
completion.matcher = "fuzzy-ignore-case";
|
||||
|
||||
# -- Diagnostics --
|
||||
diagnosticsDelay = 300;
|
||||
|
||||
# -- Formatters --
|
||||
formatterLineLength = 80;
|
||||
bibtexFormatter = "texlab";
|
||||
latexFormatter = "latexindent";
|
||||
|
||||
# -- Inlay Hints --
|
||||
inlayHints = {
|
||||
labelDefinitions = true;
|
||||
labelReferences = true;
|
||||
};
|
||||
}
|
||||
#
|
||||
# -- Build --
|
||||
// (optionalAttrs cfg.build.enable {
|
||||
build = {
|
||||
inherit
|
||||
(cfg.build)
|
||||
onSave
|
||||
useFileList
|
||||
auxDirectory
|
||||
logDirectory
|
||||
pdfDirectory
|
||||
filename
|
||||
forwardSearchAfter
|
||||
;
|
||||
inherit (builderCfg) args;
|
||||
executable = with builderCfg; "${package}/bin/${executable}";
|
||||
};
|
||||
})
|
||||
#
|
||||
# -- Forward Search --
|
||||
// (optionalAttrs (cfg.pdfViewer.enable) {
|
||||
forwardSearch = {
|
||||
inherit (pdfViewer) args;
|
||||
executable = with pdfViewer; "${package}/bin/${executable}";
|
||||
};
|
||||
})
|
||||
);
|
||||
};
|
||||
};
|
||||
};
|
||||
in {
|
||||
options.vim.languages.tex.lsp = {
|
||||
enable = mkEnableOption "TeX LSP support" // {default = config.vim.lsp.enable;};
|
||||
|
||||
servers = mkOption {
|
||||
description = "The TeX LSP servers to use";
|
||||
type = deprecatedSingleOrListOf "vim.language.tex.lsp.servers" (enum (attrNames servers));
|
||||
default = defaultServers;
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable (mkMerge [
|
||||
(mkIf cfg.lsp.enable {
|
||||
vim.lsp.servers =
|
||||
mapListToAttrs (name: {
|
||||
inherit name;
|
||||
value = servers.${name};
|
||||
})
|
||||
cfg.lsp.servers;
|
||||
})
|
||||
|
||||
# Add the chktex package when texlab has config is set that requires it.
|
||||
(mkIf (hasAttrByPath ["texlab" "capabilities" "settings" "chktex"] cfg.lsp.servers) {
|
||||
vim.extraPackages = [(pkgs.texlive.withPackages (ps: [ps.chktex]))];
|
||||
})
|
||||
]);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue