mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-12-26 20:52:22 +00:00
Compare commits
4 commits
7bd4156e94
...
0078779e93
Author | SHA1 | Date | |
---|---|---|---|
|
0078779e93 | ||
|
fd4df3432e | ||
|
6d07646fae | ||
|
88834cc93f |
7 changed files with 182 additions and 15 deletions
|
@ -48,6 +48,7 @@ isMaximal: {
|
|||
|
||||
# Assembly is not common, and the asm LSP is a major hit-or-miss
|
||||
assembly.enable = false;
|
||||
astro.enable = false;
|
||||
markdown.enable = isMaximal;
|
||||
html.enable = isMaximal;
|
||||
css.enable = isMaximal;
|
||||
|
|
|
@ -383,3 +383,7 @@ The changes are, in no particular order:
|
|||
[Nowaaru](https://github.com/Nowaaru):
|
||||
|
||||
- Add `precognition-nvim`.
|
||||
|
||||
[DamitusThyYeeticus123](https://github.com/DamitusThyYeetus123):
|
||||
|
||||
- Add support for [Astro](https://astro.build/) language server.
|
||||
|
|
|
@ -38,11 +38,11 @@
|
|||
},
|
||||
"mnw": {
|
||||
"locked": {
|
||||
"lastModified": 1733021555,
|
||||
"narHash": "sha256-bc+reHXXfdn94MnDsqBrNm2ojOnJfbd64e00nzsP0EI=",
|
||||
"lastModified": 1731821965,
|
||||
"narHash": "sha256-QiGi/HBQRnIRGY4gQPuH7T3hr7NznOpEO7qNpF5ldmE=",
|
||||
"owner": "Gerg-L",
|
||||
"repo": "mnw",
|
||||
"rev": "6841d93fe50eb335da45e11d4dabaa1844f3f79a",
|
||||
"rev": "5fe5c41975ed0af55f55dc37cd28ba906a5d015e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
159
modules/plugins/languages/astro.nix
Normal file
159
modules/plugins/languages/astro.nix
Normal file
|
@ -0,0 +1,159 @@
|
|||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (builtins) attrNames;
|
||||
inherit (lib.options) mkEnableOption mkOption;
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.lists) isList;
|
||||
inherit (lib.meta) getExe;
|
||||
inherit (lib.types) enum either listOf package str;
|
||||
inherit (lib.nvim.lua) expToLua;
|
||||
inherit (lib.nvim.languages) diagnosticsToLua;
|
||||
inherit (lib.nvim.types) mkGrammarOption diagnostics;
|
||||
|
||||
cfg = config.vim.languages.astro;
|
||||
|
||||
defaultServer = "astro";
|
||||
servers = {
|
||||
astro = {
|
||||
package = pkgs.astro-language-server;
|
||||
lspConfig = ''
|
||||
lspconfig.astro.setup {
|
||||
capabilities = capabilities;
|
||||
on_attach = attach_keymaps,
|
||||
cmd = ${
|
||||
if isList cfg.lsp.package
|
||||
then expToLua cfg.lsp.package
|
||||
else ''{"${cfg.lsp.package}/bin/astro-ls", "--stdio"}''
|
||||
}
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
# TODO: specify packages
|
||||
defaultFormat = "prettier";
|
||||
formats = {
|
||||
prettier = {
|
||||
package = pkgs.nodePackages.prettier;
|
||||
nullConfig = ''
|
||||
table.insert(
|
||||
ls_sources,
|
||||
null_ls.builtins.formatting.prettier.with({
|
||||
command = "${cfg.format.package}/bin/prettier",
|
||||
})
|
||||
)
|
||||
'';
|
||||
};
|
||||
|
||||
biome = {
|
||||
package = pkgs.biome;
|
||||
nullConfig = ''
|
||||
table.insert(
|
||||
ls_sources,
|
||||
null_ls.builtins.formatting.biome.with({
|
||||
command = "${cfg.format.package}/bin/biome",
|
||||
})
|
||||
)
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
# TODO: specify packages
|
||||
defaultDiagnosticsProvider = ["eslint_d"];
|
||||
diagnosticsProviders = {
|
||||
eslint_d = {
|
||||
package = pkgs.eslint_d;
|
||||
nullConfig = pkg: ''
|
||||
table.insert(
|
||||
ls_sources,
|
||||
null_ls.builtins.diagnostics.eslint_d.with({
|
||||
command = "${getExe pkg}",
|
||||
})
|
||||
)
|
||||
'';
|
||||
};
|
||||
};
|
||||
in {
|
||||
options.vim.languages.astro = {
|
||||
enable = mkEnableOption "Astro language support";
|
||||
|
||||
treesitter = {
|
||||
enable = mkEnableOption "Astro treesitter" // {default = config.vim.languages.enableTreesitter;};
|
||||
|
||||
astroPackage = mkGrammarOption pkgs "astro";
|
||||
};
|
||||
|
||||
lsp = {
|
||||
enable = mkEnableOption "Astro LSP support" // {default = config.vim.languages.enableLSP;};
|
||||
|
||||
server = mkOption {
|
||||
description = "Astro LSP server to use";
|
||||
type = enum (attrNames servers);
|
||||
default = defaultServer;
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
description = "Astro LSP server package, or the command to run as a list of strings";
|
||||
example = ''[lib.getExe pkgs.astro-language-server "--minify" "--stdio"]'';
|
||||
type = either package (listOf str);
|
||||
default = servers.${cfg.lsp.server}.package;
|
||||
};
|
||||
};
|
||||
|
||||
format = {
|
||||
enable = mkEnableOption "Astro formatting" // {default = config.vim.languages.enableFormat;};
|
||||
|
||||
type = mkOption {
|
||||
description = "Astro formatter to use";
|
||||
type = enum (attrNames formats);
|
||||
default = defaultFormat;
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
description = "Astro formatter package";
|
||||
type = package;
|
||||
default = formats.${cfg.format.type}.package;
|
||||
};
|
||||
};
|
||||
|
||||
extraDiagnostics = {
|
||||
enable = mkEnableOption "extra Astro diagnostics" // {default = config.vim.languages.enableExtraDiagnostics;};
|
||||
|
||||
types = diagnostics {
|
||||
langDesc = "Astro";
|
||||
inherit diagnosticsProviders;
|
||||
inherit defaultDiagnosticsProvider;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable (mkMerge [
|
||||
(mkIf cfg.treesitter.enable {
|
||||
vim.treesitter.enable = true;
|
||||
vim.treesitter.grammars = [cfg.treesitter.astroPackage];
|
||||
})
|
||||
|
||||
(mkIf cfg.lsp.enable {
|
||||
vim.lsp.lspconfig.enable = true;
|
||||
vim.lsp.lspconfig.sources.astro-lsp = servers.${cfg.lsp.server}.lspConfig;
|
||||
})
|
||||
|
||||
(mkIf cfg.format.enable {
|
||||
vim.lsp.null-ls.enable = true;
|
||||
vim.lsp.null-ls.sources.astro-format = formats.${cfg.format.type}.nullConfig;
|
||||
})
|
||||
|
||||
(mkIf cfg.extraDiagnostics.enable {
|
||||
vim.lsp.null-ls.enable = true;
|
||||
vim.lsp.null-ls.sources = diagnosticsToLua {
|
||||
lang = "astro";
|
||||
config = cfg.extraDiagnostics.types;
|
||||
inherit diagnosticsProviders;
|
||||
};
|
||||
})
|
||||
]);
|
||||
}
|
|
@ -3,6 +3,7 @@
|
|||
in {
|
||||
imports = [
|
||||
./asm.nix
|
||||
./astro.nix
|
||||
./bash.nix
|
||||
./dart.nix
|
||||
./clang.nix
|
||||
|
|
|
@ -5,11 +5,10 @@
|
|||
...
|
||||
}: let
|
||||
inherit (lib.modules) mkIf mkDefault;
|
||||
inherit (lib.nvim.binds) addDescriptionsToMappings mkSetLznBinding mkSetLuaLznBinding;
|
||||
inherit (lib.nvim.binds) mkKeymap;
|
||||
|
||||
cfg = config.vim.runner.run-nvim;
|
||||
mappingDefinitions = options.vim.runner.run-nvim.mappings;
|
||||
mappings = addDescriptionsToMappings cfg.mappings mappingDefinitions;
|
||||
inherit (options.vim.runner.run-nvim) mappings;
|
||||
in {
|
||||
config = mkIf cfg.enable {
|
||||
vim = {
|
||||
|
@ -21,14 +20,17 @@ in {
|
|||
cmd = "Run";
|
||||
|
||||
keys = [
|
||||
(mkSetLznBinding "n" mappings.run "<cmd>Run<CR>")
|
||||
(mkSetLznBinding "n" mappings.runOverride "<cmd>Run!<CR>")
|
||||
(mkSetLuaLznBinding "n" mappings.runCommand ''
|
||||
(mkKeymap "n" cfg.mappings.run "<cmd>Run<CR>" {desc = mappings.run.description;})
|
||||
(mkKeymap "n" cfg.mappings.runOverride "<cmd>Run!<CR>" {desc = mappings.runOverride.description;})
|
||||
(mkKeymap "n" cfg.mappings.runCommand ''
|
||||
function()
|
||||
local input = vim.fn.input("Run command: ")
|
||||
if input ~= "" then require("run").run(input, false) end
|
||||
end
|
||||
'')
|
||||
'' {
|
||||
desc = mappings.run.description;
|
||||
lua = true;
|
||||
})
|
||||
];
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue