Skip to content

Commit

Permalink
plugins/lsp: add nixd language server
Browse files Browse the repository at this point in the history
  • Loading branch information
GaetanLepage committed Jun 19, 2023
1 parent da04916 commit 885a746
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 6 deletions.
14 changes: 9 additions & 5 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";

beautysh.url = "github:lovesegfault/beautysh";
beautysh.inputs.nixpkgs.follows = "nixpkgs";

pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
pre-commit-hooks.inputs.nixpkgs.follows = "nixpkgs";
beautysh = {
url = "github:lovesegfault/beautysh";
inputs.nixpkgs.follows = "nixpkgs";
};

pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = {
Expand Down
47 changes: 47 additions & 0 deletions plugins/lsp/language-servers/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,53 @@ with lib; let
};
settings = cfg: {nil = {inherit (cfg) formatting diagnostics;};};
}
{
name = "nixd";
description = "Enable nixd, for Nix";
package = pkgs.nixd;
settings = cfg: {nixd = cfg;};
settingsOptions = {
# The evaluation section, provide auto completion for dynamic bindings.
eval = {
target = {
args = helpers.defaultNullOpts.mkNullable (with types; listOf str) "[]" ''
Accept args as "nix eval".
'';

installable = helpers.defaultNullOpts.mkStr "" ''
"nix eval"
'';
};

depth = helpers.defaultNullOpts.mkInt 0 "Extra depth for evaluation";

workers = helpers.defaultNullOpts.mkInt 3 "The number of workers for evaluation task.";
};

formatting = {
command = helpers.defaultNullOpts.mkStr "nixpkgs-fmt" ''
Which command you would like to do formatting
'';
};

options = {
enable = helpers.defaultNullOpts.mkBool true ''
Enable option completion task.
If you are writting a package, disable this
'';

target = {
args = helpers.defaultNullOpts.mkNullable (with types; listOf str) "[]" ''
Accept args as "nix eval".
'';

installable = helpers.defaultNullOpts.mkStr "" ''
"nix eval"
'';
};
};
};
}
{
name = "pylsp";
description = "Enable pylsp, for Python.";
Expand Down
35 changes: 35 additions & 0 deletions tests/test-sources/plugins/lsp/nixd.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{pkgs}: {
example = {
plugins.lsp = {
enable = true;

servers.nixd = {
# TODO nixd is currently broken on Darwin
# https://github.com/nix-community/nixd/issues/107
# Thus, this test is currently disabled.
enable = !pkgs.stdenv.isDarwin;

settings = {
eval = {
target = {
args = ["foo" "bar"];
installable = "";
};
depth = 0;
workers = 3;
};
formatting = {
command = "nixpkgs-fmt";
};
options = {
enable = true;
target = {
args = ["yes" "no" "maybe"];
installable = "";
};
};
};
};
};
};
}
6 changes: 5 additions & 1 deletion tests/test-sources/plugins/lsp/nvim-lsp.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
{pkgs}: {
empty = {
plugins.lsp.enable = true;
};
Expand Down Expand Up @@ -87,6 +87,10 @@
lua-ls.enable = true;
metals.enable = true;
nil_ls.enable = true;
# TODO nixd is currently broken on Darwin
# https://github.com/nix-community/nixd/issues/107
# Thus, this test is currently disabled.
nixd.enable = !pkgs.stdenv.isDarwin;
pylsp.enable = true;
pyright.enable = true;
rnix-lsp.enable = true;
Expand Down

0 comments on commit 885a746

Please sign in to comment.