summaryrefslogtreecommitdiffstats
path: root/modules/plugins/lsp/presets/nushell.nix
blob: 0f82f8b3c46e8d897b88df0e36e1789e5c098185 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
{
  config,
  lib,
  pkgs,
  ...
}: let
  inherit (lib.modules) mkIf;
  inherit (lib.nvim.types) mkLspPresetEnableOption;
  inherit (lib.meta) getExe;
  inherit (lib.generators) mkLuaInline;

  cfg = config.vim.lsp.presets.nushell;
in {
  options.vim.lsp.presets.nushell = {
    enable = mkLspPresetEnableOption {
      option = "nushell";
      display = "NuShell";
    };
  };

  config = mkIf cfg.enable {
    vim.lsp.servers.nushell = {
      enable = true;
      cmd = [(getExe pkgs.nushell) "--no-config-file" "--lsp"];
      root_dir = mkLuaInline ''
        function(bufnr, on_dir)
          on_dir(vim.fs.root(bufnr, { '.git' }) or vim.fs.dirname(vim.api.nvim_buf_get_name(bufnr)))
        end
      '';
    };
  };
}