mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-02-22 11:28:01 +00:00
languages: begin converting language modules to new lsp options format
This commit is contained in:
parent
208f02f3e8
commit
d827ac8771
3 changed files with 109 additions and 44 deletions
|
@ -4,12 +4,34 @@
|
||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
|
inherit (builtins) attrNames;
|
||||||
inherit (lib.options) mkEnableOption mkOption;
|
inherit (lib.options) mkEnableOption mkOption;
|
||||||
inherit (lib.modules) mkIf mkMerge;
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
inherit (lib.types) package;
|
inherit (lib.types) enum either listOf package str;
|
||||||
|
inherit (lib.lists) isList;
|
||||||
|
inherit (lib.meta) getExe;
|
||||||
|
inherit (lib.generators) mkLuaInline;
|
||||||
|
inherit (lib.nvim.lua) expToLua toLuaObject;
|
||||||
|
inherit (lib.nvim.languages) lspOptions;
|
||||||
inherit (lib.nvim.types) mkGrammarOption;
|
inherit (lib.nvim.types) mkGrammarOption;
|
||||||
|
|
||||||
cfg = config.vim.languages.assembly;
|
cfg = config.vim.languages.assembly;
|
||||||
|
|
||||||
|
defaultServer = "asm-lsp";
|
||||||
|
servers = {
|
||||||
|
asm-lsp = {
|
||||||
|
package = pkgs.asm-lsp;
|
||||||
|
options = {
|
||||||
|
capabilities = mkLuaInline "capabilities";
|
||||||
|
on_attach = mkLuaInline "attach_keymaps";
|
||||||
|
filetypes = ["asm" "vasm"];
|
||||||
|
cmd =
|
||||||
|
if isList cfg.lsp.package
|
||||||
|
then expToLua cfg.lsp.package
|
||||||
|
else ["${getExe cfg.lsp.package}"];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
in {
|
in {
|
||||||
options.vim.languages.assembly = {
|
options.vim.languages.assembly = {
|
||||||
enable = mkEnableOption "Assembly support";
|
enable = mkEnableOption "Assembly support";
|
||||||
|
@ -22,28 +44,46 @@ in {
|
||||||
lsp = {
|
lsp = {
|
||||||
enable = mkEnableOption "Assembly LSP support (asm-lsp)" // {default = config.vim.languages.enableLSP;};
|
enable = mkEnableOption "Assembly LSP support (asm-lsp)" // {default = config.vim.languages.enableLSP;};
|
||||||
|
|
||||||
|
server = mkOption {
|
||||||
|
description = "Assembly LSP server to use";
|
||||||
|
type = enum (attrNames servers);
|
||||||
|
default = defaultServer;
|
||||||
|
};
|
||||||
|
|
||||||
package = mkOption {
|
package = mkOption {
|
||||||
type = package;
|
description = "asm-lsp LSP server package, or the command to run as a list of strings";
|
||||||
default = pkgs.asm-lsp;
|
example = ''[lib.getExe pkgs.asm-lsp "--quiet"]'';
|
||||||
description = "asm-lsp package";
|
type = either package (listOf str);
|
||||||
|
default = servers.${cfg.lsp.server}.package;
|
||||||
|
};
|
||||||
|
|
||||||
|
options = mkOption {
|
||||||
|
type = lspOptions;
|
||||||
|
default = servers.${cfg.lsp.server}.options;
|
||||||
|
description = ''
|
||||||
|
LSP options for Assembly language support.
|
||||||
|
|
||||||
|
This option is freeform, you may add options that are not set by default
|
||||||
|
and they will be merged into the final table passed to lspconfig.
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
config = mkIf cfg.enable (mkMerge [
|
config = mkIf cfg.enable (mkMerge [
|
||||||
(mkIf cfg.treesitter.enable {
|
(mkIf cfg.treesitter.enable {
|
||||||
vim.treesitter.enable = true;
|
vim.treesitter = {
|
||||||
vim.treesitter.grammars = [cfg.treesitter.package];
|
enable = true;
|
||||||
|
grammars = [cfg.treesitter.package];
|
||||||
|
};
|
||||||
})
|
})
|
||||||
|
|
||||||
(mkIf cfg.lsp.enable {
|
(mkIf cfg.lsp.enable {
|
||||||
vim.lsp.lspconfig.enable = true;
|
vim.lsp.lspconfig = {
|
||||||
vim.lsp.lspconfig.sources.asm-lsp = ''
|
enable = true;
|
||||||
lspconfig.asm_lsp.setup {
|
sources.asm-lsp = ''
|
||||||
capabilities = capabilities,
|
lspconfig.("asm_lsp").setup (${toLuaObject cfg.lsp.options})
|
||||||
on_attach = default_on_attach,
|
'';
|
||||||
cmd = {"${cfg.lsp.package}/bin/asm-lsp"},
|
};
|
||||||
}
|
|
||||||
'';
|
|
||||||
})
|
})
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,11 +7,12 @@
|
||||||
inherit (builtins) attrNames;
|
inherit (builtins) attrNames;
|
||||||
inherit (lib.options) mkEnableOption mkOption;
|
inherit (lib.options) mkEnableOption mkOption;
|
||||||
inherit (lib.modules) mkIf mkMerge;
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
|
inherit (lib.types) enum either listOf package str;
|
||||||
inherit (lib.lists) isList;
|
inherit (lib.lists) isList;
|
||||||
inherit (lib.meta) getExe;
|
inherit (lib.meta) getExe;
|
||||||
inherit (lib.types) enum either listOf package str;
|
inherit (lib.generators) mkLuaInline;
|
||||||
inherit (lib.nvim.lua) expToLua;
|
inherit (lib.nvim.lua) expToLua toLuaObject;
|
||||||
inherit (lib.nvim.languages) diagnosticsToLua;
|
inherit (lib.nvim.languages) diagnosticsToLua lspOptions;
|
||||||
inherit (lib.nvim.types) mkGrammarOption diagnostics;
|
inherit (lib.nvim.types) mkGrammarOption diagnostics;
|
||||||
|
|
||||||
cfg = config.vim.languages.astro;
|
cfg = config.vim.languages.astro;
|
||||||
|
@ -20,17 +21,16 @@
|
||||||
servers = {
|
servers = {
|
||||||
astro = {
|
astro = {
|
||||||
package = pkgs.astro-language-server;
|
package = pkgs.astro-language-server;
|
||||||
lspConfig = ''
|
options = {
|
||||||
lspconfig.astro.setup {
|
capabilities = mkLuaInline "capabilities";
|
||||||
capabilities = capabilities;
|
on_attach = mkLuaInline "attach_keymaps";
|
||||||
on_attach = attach_keymaps,
|
filetypes = ["astro"];
|
||||||
cmd = ${
|
init_options = {typescript = {};};
|
||||||
|
cmd =
|
||||||
if isList cfg.lsp.package
|
if isList cfg.lsp.package
|
||||||
then expToLua cfg.lsp.package
|
then expToLua cfg.lsp.package
|
||||||
else ''{"${cfg.lsp.package}/bin/astro-ls", "--stdio"}''
|
else ["${getExe cfg.lsp.package}" "--stdio"];
|
||||||
}
|
};
|
||||||
}
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -83,8 +83,7 @@ in {
|
||||||
|
|
||||||
treesitter = {
|
treesitter = {
|
||||||
enable = mkEnableOption "Astro treesitter" // {default = config.vim.languages.enableTreesitter;};
|
enable = mkEnableOption "Astro treesitter" // {default = config.vim.languages.enableTreesitter;};
|
||||||
|
package = mkGrammarOption pkgs "astro";
|
||||||
astroPackage = mkGrammarOption pkgs "astro";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
lsp = {
|
lsp = {
|
||||||
|
@ -96,6 +95,17 @@ in {
|
||||||
default = defaultServer;
|
default = defaultServer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
options = mkOption {
|
||||||
|
type = lspOptions;
|
||||||
|
default = servers.${cfg.lsp.server}.options;
|
||||||
|
description = ''
|
||||||
|
LSP options for Astro language support.
|
||||||
|
|
||||||
|
This option is freeform, you may add options that are not set by default
|
||||||
|
and they will be merged into the final table passed to lspconfig.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
package = mkOption {
|
package = mkOption {
|
||||||
description = "Astro LSP server package, or the command to run as a list of strings";
|
description = "Astro LSP server package, or the command to run as a list of strings";
|
||||||
example = ''[lib.getExe pkgs.astro-language-server "--minify" "--stdio"]'';
|
example = ''[lib.getExe pkgs.astro-language-server "--minify" "--stdio"]'';
|
||||||
|
@ -134,12 +144,14 @@ in {
|
||||||
config = mkIf cfg.enable (mkMerge [
|
config = mkIf cfg.enable (mkMerge [
|
||||||
(mkIf cfg.treesitter.enable {
|
(mkIf cfg.treesitter.enable {
|
||||||
vim.treesitter.enable = true;
|
vim.treesitter.enable = true;
|
||||||
vim.treesitter.grammars = [cfg.treesitter.astroPackage];
|
vim.treesitter.grammars = [cfg.treesitter.package];
|
||||||
})
|
})
|
||||||
|
|
||||||
(mkIf cfg.lsp.enable {
|
(mkIf cfg.lsp.enable {
|
||||||
vim.lsp.lspconfig.enable = true;
|
vim.lsp.lspconfig.enable = true;
|
||||||
vim.lsp.lspconfig.sources.astro-lsp = servers.${cfg.lsp.server}.lspConfig;
|
vim.lsp.lspconfig.sources.astro-lsp = ''
|
||||||
|
lspconfig.("astro").setup (${toLuaObject cfg.lsp.options})
|
||||||
|
'';
|
||||||
})
|
})
|
||||||
|
|
||||||
(mkIf cfg.format.enable {
|
(mkIf cfg.format.enable {
|
||||||
|
|
|
@ -7,11 +7,13 @@
|
||||||
inherit (builtins) attrNames;
|
inherit (builtins) attrNames;
|
||||||
inherit (lib.options) mkOption mkEnableOption literalExpression;
|
inherit (lib.options) mkOption mkEnableOption literalExpression;
|
||||||
inherit (lib.modules) mkIf mkMerge;
|
inherit (lib.modules) mkIf mkMerge;
|
||||||
|
inherit (lib.types) enum either listOf package str bool;
|
||||||
inherit (lib.lists) isList;
|
inherit (lib.lists) isList;
|
||||||
inherit (lib.types) enum either package listOf str bool;
|
inherit (lib.meta) getExe;
|
||||||
inherit (lib.nvim.languages) diagnosticsToLua;
|
inherit (lib.generators) mkLuaInline;
|
||||||
inherit (lib.nvim.types) diagnostics mkGrammarOption;
|
inherit (lib.nvim.lua) expToLua toLuaObject;
|
||||||
inherit (lib.nvim.lua) expToLua;
|
inherit (lib.nvim.languages) diagnosticsToLua lspOptions;
|
||||||
|
inherit (lib.nvim.types) mkGrammarOption diagnostics;
|
||||||
|
|
||||||
cfg = config.vim.languages.bash;
|
cfg = config.vim.languages.bash;
|
||||||
|
|
||||||
|
@ -19,17 +21,15 @@
|
||||||
servers = {
|
servers = {
|
||||||
bash-ls = {
|
bash-ls = {
|
||||||
package = pkgs.bash-language-server;
|
package = pkgs.bash-language-server;
|
||||||
lspConfig = ''
|
options = {
|
||||||
lspconfig.bashls.setup{
|
capabilities = mkLuaInline "capabilities";
|
||||||
capabilities = capabilities;
|
on_attach = mkLuaInline "default_on_attach";
|
||||||
on_attach = default_on_attach;
|
filetypes = ["bash" "sh"];
|
||||||
cmd = ${
|
cmd =
|
||||||
if isList cfg.lsp.package
|
if isList cfg.lsp.package
|
||||||
then expToLua cfg.lsp.package
|
then expToLua cfg.lsp.package
|
||||||
else ''{"${cfg.lsp.package}/bin/bash-language-server", "start"}''
|
else ["${getExe cfg.lsp.package}" "start"];
|
||||||
};
|
};
|
||||||
}
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -87,6 +87,17 @@ in {
|
||||||
type = either package (listOf str);
|
type = either package (listOf str);
|
||||||
default = pkgs.bash-language-server;
|
default = pkgs.bash-language-server;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
options = mkOption {
|
||||||
|
type = lspOptions;
|
||||||
|
default = servers.${cfg.lsp.server}.options;
|
||||||
|
description = ''
|
||||||
|
LSP options for Bash language support.
|
||||||
|
|
||||||
|
This option is freeform, you may add options that are not set by default
|
||||||
|
and they will be merged into the final table passed to lspconfig.
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
format = {
|
format = {
|
||||||
|
@ -126,7 +137,9 @@ in {
|
||||||
|
|
||||||
(mkIf cfg.lsp.enable {
|
(mkIf cfg.lsp.enable {
|
||||||
vim.lsp.lspconfig.enable = true;
|
vim.lsp.lspconfig.enable = true;
|
||||||
vim.lsp.lspconfig.sources.bash-lsp = servers.${cfg.lsp.server}.lspConfig;
|
vim.lsp.lspconfig.sources.bash-lsp = ''
|
||||||
|
lspconfig.("bashls").setup (${toLuaObject cfg.lsp.options})
|
||||||
|
'';
|
||||||
})
|
})
|
||||||
|
|
||||||
(mkIf cfg.format.enable {
|
(mkIf cfg.format.enable {
|
||||||
|
|
Loading…
Add table
Reference in a new issue