mirror of
https://github.com/NotAShelf/nvf.git
synced 2026-04-27 20:05:23 +00:00
languages/astro: refactor lsp.servers to use lsp/presets/<name>
This commit is contained in:
parent
700ddae60c
commit
faa5885703
2 changed files with 13 additions and 33 deletions
|
|
@ -9,37 +9,15 @@
|
|||
inherit (lib.options) mkEnableOption mkOption literalExpression;
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.meta) getExe;
|
||||
inherit (lib.types) enum coercedTo;
|
||||
inherit (lib.types) enum coercedTo listOf;
|
||||
inherit (lib.nvim.attrsets) mapListToAttrs;
|
||||
inherit (lib.nvim.types) mkGrammarOption diagnostics deprecatedSingleOrListOf;
|
||||
inherit (lib.generators) mkLuaInline;
|
||||
inherit (lib) genAttrs;
|
||||
|
||||
cfg = config.vim.languages.astro;
|
||||
|
||||
defaultServers = ["astro"];
|
||||
servers = {
|
||||
astro = {
|
||||
enable = true;
|
||||
cmd = [(getExe pkgs.astro-language-server) "--stdio"];
|
||||
filetypes = ["astro"];
|
||||
root_markers = ["package.json" "tsconfig.json" "jsconfig.json" ".git"];
|
||||
init_options = {
|
||||
typescript = {};
|
||||
};
|
||||
before_init =
|
||||
mkLuaInline
|
||||
/*
|
||||
lua
|
||||
*/
|
||||
''
|
||||
function(_, config)
|
||||
if config.init_options and config.init_options.typescript and not config.init_options.typescript.tsdk then
|
||||
config.init_options.typescript.tsdk = util.get_typescript_server_path(config.root_dir)
|
||||
end
|
||||
end
|
||||
'';
|
||||
};
|
||||
};
|
||||
defaultServers = ["astro-language-server"];
|
||||
servers = ["astro-language-server"];
|
||||
|
||||
defaultFormat = ["prettier"];
|
||||
formats = let
|
||||
|
|
@ -107,7 +85,7 @@ in {
|
|||
defaultText = literalExpression "config.vim.lsp.enable";
|
||||
};
|
||||
servers = mkOption {
|
||||
type = deprecatedSingleOrListOf "vim.language.astro.lsp.servers" (enum (attrNames servers));
|
||||
type = listOf (enum servers);
|
||||
default = defaultServers;
|
||||
description = "Astro LSP server to use";
|
||||
};
|
||||
|
|
@ -151,12 +129,12 @@ in {
|
|||
})
|
||||
|
||||
(mkIf cfg.lsp.enable {
|
||||
vim.lsp.servers =
|
||||
mapListToAttrs (n: {
|
||||
name = n;
|
||||
value = servers.${n};
|
||||
})
|
||||
cfg.lsp.servers;
|
||||
vim.lsp = {
|
||||
presets = genAttrs cfg.lsp.servers (_: {enable = true;});
|
||||
servers = genAttrs cfg.lsp.servers (_: {
|
||||
filetypes = ["astro"];
|
||||
});
|
||||
};
|
||||
})
|
||||
|
||||
(mkIf cfg.format.enable {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue