mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2024-12-22 02:59:49 +01:00
52ad5ec34c
* modules/languages: add nu * configuration: enable nu for maximal * flake.lock: update nixpkgs * languages/nu: TS parser is now in nixpkgs * docs: added changelog entry for nu * modules/plugins/languages/nu.nix: applying suggested change for option ordering Co-authored-by: raf <raf@notashelf.dev> * configuration.nix: don't enable nu on maximal * modules/nu: removed useless comments * languages/nu: cleaning up after removing formatter code * modules/plugins/languages/nu.nix: better attrs ordering Co-authored-by: raf <raf@notashelf.dev> --------- Co-authored-by: diniamo <diniamo53@gmail.com> Co-authored-by: raf <raf@notashelf.dev>
70 lines
1.8 KiB
Nix
70 lines
1.8 KiB
Nix
{
|
|
lib,
|
|
pkgs,
|
|
config,
|
|
...
|
|
}: let
|
|
inherit (lib.options) mkEnableOption mkOption;
|
|
inherit (lib.types) str either package listOf;
|
|
inherit (lib.modules) mkIf mkMerge;
|
|
inherit (lib.nvim.lua) expToLua;
|
|
inherit (lib.nvim.types) mkGrammarOption;
|
|
inherit (builtins) isList;
|
|
|
|
defaultServer = "nushell";
|
|
servers = {
|
|
nushell = {
|
|
package = pkgs.nushell;
|
|
lspConfig = ''
|
|
lspconfig.nushell.setup{
|
|
capabilities = capabilities,
|
|
on_attach = default_on_attach,
|
|
cmd = ${
|
|
if isList cfg.lsp.package
|
|
then expToLua cfg.lsp.package
|
|
else ''{"${cfg.lsp.package}/bin/nu", "--no-config-file", "--lsp"}''
|
|
}
|
|
}
|
|
'';
|
|
};
|
|
};
|
|
|
|
cfg = config.vim.languages.nu;
|
|
in {
|
|
options.vim.languages.nu = {
|
|
enable = mkEnableOption "Nu language support";
|
|
|
|
treesitter = {
|
|
enable = mkEnableOption "Nu treesitter" // {default = config.vim.languages.enableTreesitter;};
|
|
package = mkGrammarOption pkgs "nu";
|
|
};
|
|
|
|
lsp = {
|
|
enable = mkEnableOption "Nu LSP support" // {default = config.vim.languages.enableLSP;};
|
|
server = mkOption {
|
|
type = str;
|
|
default = defaultServer;
|
|
description = "Nu LSP server to use";
|
|
};
|
|
|
|
package = mkOption {
|
|
type = either package (listOf str);
|
|
default = servers.${cfg.lsp.server}.package;
|
|
example = ''[(lib.getExe pkgs.nushell) "--lsp"]'';
|
|
description = "Nu LSP server package, or the command to run as a list of strings";
|
|
};
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable (mkMerge [
|
|
(mkIf cfg.treesitter.enable {
|
|
vim.treesitter.enable = true;
|
|
vim.treesitter.grammars = [cfg.treesitter.package];
|
|
})
|
|
|
|
(mkIf cfg.lsp.enable {
|
|
vim.lsp.lspconfig.enable = true;
|
|
vim.lsp.lspconfig.sources.nu-lsp = servers.${cfg.lsp.server}.lspConfig;
|
|
})
|
|
]);
|
|
}
|