summaryrefslogtreecommitdiffstats
path: root/modules/plugins/lsp/presets/harper.nix
blob: 20e3b8fc3794cca7b72e16d603520114e831d24d (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
{
  config,
  lib,
  pkgs,
  ...
}: let
  inherit (lib.modules) mkIf;
  inherit (lib.nvim.types) mkLspPresetEnableOption;
  inherit (lib.meta) getExe;

  cfg = config.vim.lsp.presets.harper;
  filetypes = [
    # <https://writewithharper.com/docs/integrations/language-server#Supported-Languages>
    "asciidoc"
    "c"
    "clojure"
    "cmake"
    "cpp"
    "cs"
    "dart"
    "gitcommit"
    "go"
    "haskell"
    "html"
    "java"
    "javascript"
    "javascriptreact"
    "kotlin"
    "lhaskell"
    "lua"
    "mail"
    "markdown"
    "nix"
    "php"
    "python"
    "ruby"
    "rust"
  ];
in {
  options.vim.lsp.presets.harper = {
    enable = mkLspPresetEnableOption {
      option = "harper";
      display = "Harper";
      defaultFiletypes = filetypes;
    };
  };

  config = mkIf cfg.enable {
    vim.lsp.servers.harper = {
      enable = true;
      cmd = [(getExe pkgs.harper) "--stdio"];
      root_markers = [".git" ".harper-dictionary.txt"];
      # Make Harper shut up in the logs, that its key is required, when nothing is configured.
      settings.harper-ls = {};
      inherit filetypes;
    };
  };
}