mirror of
https://github.com/NotAShelf/nvf.git
synced 2026-01-15 15:07:48 +00:00
Compare commits
2 commits
5087c3d64d
...
fee1b46924
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fee1b46924 |
||
|
|
52ad5ec34c |
7 changed files with 114 additions and 11 deletions
|
|
@ -76,6 +76,7 @@ isMaximal: {
|
|||
csharp.enable = isMaximal;
|
||||
julia.enable = isMaximal;
|
||||
vala.enable = isMaximal;
|
||||
nu.enable = false;
|
||||
};
|
||||
|
||||
visuals = {
|
||||
|
|
|
|||
|
|
@ -315,6 +315,7 @@ To migrate to `nixfmt`, simply change `vim.languages.nix.format.type` to
|
|||
the Typst language module.
|
||||
- Add LSP and Treesitter support for Assembly under `vim.languages.assembly`
|
||||
- Move [which-key](https://github.com/folke/which-key.nvim) to the new spec
|
||||
- Add LSP and Treesitter support for Nushell under `vim.languages.nu`
|
||||
|
||||
[Bloxx12](https://github.com/Bloxx12)
|
||||
|
||||
|
|
|
|||
6
flake.lock
generated
6
flake.lock
generated
|
|
@ -98,11 +98,11 @@
|
|||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1730958623,
|
||||
"narHash": "sha256-JwQZIGSYnRNOgDDoIgqKITrPVil+RMWHsZH1eE1VGN0=",
|
||||
"lastModified": 1732617236,
|
||||
"narHash": "sha256-PYkz6U0bSEaEB1al7O1XsqVNeSNS+s3NVclJw7YC43w=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "85f7e662eda4fa3a995556527c87b2524b691933",
|
||||
"rev": "af51545ec9a44eadf3fe3547610a5cdd882bc34e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ in {
|
|||
./zig.nix
|
||||
./csharp.nix
|
||||
./julia.nix
|
||||
./nu.nix
|
||||
];
|
||||
|
||||
options.vim.languages = {
|
||||
|
|
|
|||
70
modules/plugins/languages/nu.nix
Normal file
70
modules/plugins/languages/nu.nix
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
{
|
||||
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;
|
||||
})
|
||||
]);
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
config,
|
||||
...
|
||||
}: let
|
||||
inherit (builtins) toJSON typeOf head length filter concatLists concatStringsSep;
|
||||
inherit (builtins) toJSON typeOf head length filter concatLists concatStringsSep tryEval;
|
||||
inherit (lib.attrsets) mapAttrsToList;
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.generators) mkLuaInline;
|
||||
|
|
@ -21,10 +21,36 @@
|
|||
else keySpec.action;
|
||||
};
|
||||
|
||||
toLuaLznSpec = name: spec:
|
||||
toLuaLznSpec = name: spec: let
|
||||
packageName =
|
||||
if typeOf spec.package == "string"
|
||||
then spec.package
|
||||
else if (spec.package ? pname && (tryEval spec.package.pname).success)
|
||||
then spec.package.pname
|
||||
else spec.package.name;
|
||||
in
|
||||
(removeAttrs spec ["package" "setupModule" "setupOpts" "keys"])
|
||||
// {
|
||||
"@1" = name;
|
||||
"@1" =
|
||||
if spec.package != null && packageName != name && spec.load == null
|
||||
then
|
||||
abort ''
|
||||
vim.lazy.plugins.${name} does not match the package name ${packageName}.
|
||||
|
||||
Please either:
|
||||
- rename it to vim.lazy.plugins.${packageName}, or
|
||||
- if you intend to use a custom loader, specify a
|
||||
vim.lazy.plugins.${name}.load function.
|
||||
''
|
||||
else if spec.package == null && spec.load == null
|
||||
then
|
||||
abort ''
|
||||
vim.lazy.plugins.${name} has null package but no load function given.
|
||||
|
||||
Please either specify a package, or (if you know what you're doing) provide a
|
||||
custom load function.
|
||||
''
|
||||
else name;
|
||||
beforeAll =
|
||||
if spec.beforeAll != null
|
||||
then
|
||||
|
|
@ -62,7 +88,7 @@
|
|||
if spec.load != null
|
||||
then
|
||||
mkLuaInline ''
|
||||
funcion()
|
||||
function(name)
|
||||
${spec.load}
|
||||
end
|
||||
''
|
||||
|
|
@ -76,7 +102,7 @@
|
|||
};
|
||||
lznSpecs = mapAttrsToList toLuaLznSpec cfg.plugins;
|
||||
|
||||
pluginPackages = mapAttrsToList (_: plugin: plugin.package) cfg.plugins;
|
||||
pluginPackages = filter (x: x != null) (mapAttrsToList (_: plugin: plugin.package) cfg.plugins);
|
||||
|
||||
specToNotLazyConfig = _: spec: ''
|
||||
do
|
||||
|
|
|
|||
|
|
@ -66,8 +66,12 @@
|
|||
lznPluginType = submodule {
|
||||
options = {
|
||||
package = mkOption {
|
||||
type = pluginType;
|
||||
description = "Plugin package";
|
||||
type = nullOr pluginType;
|
||||
description = ''
|
||||
Plugin package.
|
||||
|
||||
If null, a custom load function must be provided
|
||||
'';
|
||||
};
|
||||
|
||||
setupModule = mkOption {
|
||||
|
|
@ -173,7 +177,7 @@
|
|||
description = ''
|
||||
Lua code to override the `vim.g.lz_n.load()` function for a single plugin.
|
||||
|
||||
This will be wrapped in a function.
|
||||
This will be wrapped in a `function(name) ... end`.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue