From 36bc31ed5cb4b7d5d3b48ea2ac93cf6bee8d16dc Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Thu, 1 Dec 2022 14:05:35 +0000 Subject: [PATCH] lsp: add haskell language server --- plugins/languages/treesitter.nix | 8 ++- plugins/nvim-lsp/basic-servers.nix | 7 ++- tests/flake.lock | 88 ++++++++++++++++++++++++++---- tests/flake.nix | 20 ++++++- 4 files changed, 109 insertions(+), 14 deletions(-) diff --git a/plugins/languages/treesitter.nix b/plugins/languages/treesitter.nix index 3dffdff6..be4ed3ce 100644 --- a/plugins/languages/treesitter.nix +++ b/plugins/languages/treesitter.nix @@ -66,6 +66,12 @@ in folding = mkEnableOption "Enable tree-sitter based folding"; }; + + grammarPackages = mkOption { + type = with types; listOf package; + default = pkgs.tree-sitter.allGrammars; + description = "Grammar packages to install"; + }; }; config = @@ -107,7 +113,7 @@ in ''; extraPlugins = with pkgs; if cfg.nixGrammars then - [ (vimPlugins.nvim-treesitter.withPlugins (_: tree-sitter.allGrammars)) ] + [ (vimPlugins.nvim-treesitter.withPlugins (_: cfg.grammarPackages)) ] else [ vimPlugins.nvim-treesitter ]; extraPackages = [ pkgs.tree-sitter pkgs.nodejs ]; diff --git a/plugins/nvim-lsp/basic-servers.nix b/plugins/nvim-lsp/basic-servers.nix index ef1881a2..25e59bdc 100644 --- a/plugins/nvim-lsp/basic-servers.nix +++ b/plugins/nvim-lsp/basic-servers.nix @@ -26,7 +26,7 @@ let name = "elixirls"; description = "Enable elixirls"; packages = [ ]; - cmd = ["${pkgs.elixir_ls}/bin/elixir-ls"]; + cmd = [ "${pkgs.elixir_ls}/bin/elixir-ls" ]; } { name = "gdscript"; @@ -78,6 +78,11 @@ let name = "zls"; description = "Enable zls, for Zig."; } + { + name = "hls"; + description = "Enable haskell language server"; + packages = [ pkgs.haskell-language-server ]; + } ]; in { diff --git a/tests/flake.lock b/tests/flake.lock index b6272a30..a1a8df89 100644 --- a/tests/flake.lock +++ b/tests/flake.lock @@ -46,6 +46,25 @@ "type": "github" } }, + "build-ts": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + }, + "locked": { + "lastModified": 1669771646, + "narHash": "sha256-IfH9zCq0+QpAB8D1ClhISfWcR59mSDsi91/2NW0RWfs=", + "owner": "pta2002", + "repo": "build-ts-grammar.nix", + "rev": "bba8a5b14a4632f25411dbf0fb01de69e999ce82", + "type": "github" + }, + "original": { + "owner": "pta2002", + "repo": "build-ts-grammar.nix", + "type": "github" + } + }, "flake-utils": { "locked": { "lastModified": 1667395993, @@ -91,6 +110,37 @@ "type": "github" } }, + "flake-utils_4": { + "locked": { + "lastModified": 1667395993, + "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "gleam": { + "flake": false, + "locked": { + "lastModified": 1669665314, + "narHash": "sha256-aeho84P91cH13j7uLJwyD/zj8O/peROrpfa41HA/FGo=", + "owner": "gleam-lang", + "repo": "tree-sitter-gleam", + "rev": "97611918f79643ade377a156f3e4192cd50dc3e6", + "type": "github" + }, + "original": { + "owner": "gleam-lang", + "repo": "tree-sitter-gleam", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1663491030, @@ -135,28 +185,42 @@ "type": "indirect" } }, + "nixpkgs_3": { + "locked": { + "lastModified": 1663491030, + "narHash": "sha256-MVsfBhE9US5DvLtBAaTRjwYdv1tLO8xjahM8qLXTgTo=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "767542707d394ff15ac1981e903e005ba69528b5", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "type": "indirect" + } + }, "nixvim": { "inputs": { "beautysh": "beautysh", - "flake-utils": "flake-utils_2", - "nixpkgs": "nixpkgs_2", + "flake-utils": "flake-utils_3", + "nixpkgs": "nixpkgs_3", "nmdSrc": "nmdSrc" }, "locked": { "lastModified": 0, - "narHash": "sha256-sjdU/aCTVFGSDxU+jxgaHtDsZQeFNb1nA55wRPgc3tU=", - "path": "/nix/store/5wxj9v7dzrga7xvp4pr825ph20i1qb42-source", + "narHash": "sha256-HWr75pPDcv+OM0BRyQUtIDPJ4W1V1iDzsEVXY6JQz6E=", + "path": "/nix/store/hgr3qr1x8gndpdkaj8cx2xclmd7v20b9-source", "type": "path" }, "original": { - "path": "/nix/store/5wxj9v7dzrga7xvp4pr825ph20i1qb42-source", + "path": "/nix/store/hgr3qr1x8gndpdkaj8cx2xclmd7v20b9-source", "type": "path" } }, "nixvim-stable": { "inputs": { "beautysh": "beautysh_2", - "flake-utils": "flake-utils_3", + "flake-utils": "flake-utils_4", "nixpkgs": [ "nixpkgs-stable" ], @@ -164,12 +228,12 @@ }, "locked": { "lastModified": 0, - "narHash": "sha256-sjdU/aCTVFGSDxU+jxgaHtDsZQeFNb1nA55wRPgc3tU=", - "path": "/nix/store/5wxj9v7dzrga7xvp4pr825ph20i1qb42-source", + "narHash": "sha256-HWr75pPDcv+OM0BRyQUtIDPJ4W1V1iDzsEVXY6JQz6E=", + "path": "/nix/store/hgr3qr1x8gndpdkaj8cx2xclmd7v20b9-source", "type": "path" }, "original": { - "path": "/nix/store/5wxj9v7dzrga7xvp4pr825ph20i1qb42-source", + "path": "/nix/store/hgr3qr1x8gndpdkaj8cx2xclmd7v20b9-source", "type": "path" } }, @@ -261,8 +325,10 @@ }, "root": { "inputs": { - "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs", + "build-ts": "build-ts", + "flake-utils": "flake-utils_2", + "gleam": "gleam", + "nixpkgs": "nixpkgs_2", "nixpkgs-stable": "nixpkgs-stable", "nixvim": "nixvim", "nixvim-stable": "nixvim-stable" diff --git a/tests/flake.nix b/tests/flake.nix index 8fc73a7d..735e6910 100644 --- a/tests/flake.nix +++ b/tests/flake.nix @@ -4,13 +4,17 @@ inputs.flake-utils.url = "github:numtide/flake-utils"; inputs.nixvim.url = "./.."; + inputs.build-ts.url = "github:pta2002/build-ts-grammar.nix"; + inputs.gleam.url = "github:gleam-lang/tree-sitter-gleam"; + inputs.gleam.flake = false; + inputs.nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-22.05"; inputs.nixvim-stable = { url = "./.."; inputs.nixpkgs.follows = "nixpkgs-stable"; }; - outputs = { self, nixvim, nixvim-stable, nixpkgs, flake-utils, nixpkgs-stable, ... }: + outputs = { self, nixvim, nixvim-stable, nixpkgs, flake-utils, nixpkgs-stable, build-ts, gleam, ... }: (flake-utils.lib.eachDefaultSystem (system: let @@ -238,6 +242,20 @@ Normal.fg = "#ff0000"; }; }; + + ts-custom = build { + plugins.treesitter = { + enable = true; + nixGrammars = true; + grammarPackages = [ + (build-ts.lib.buildGrammar pkgs { + language = "gleam"; + version = "0.25.0"; + source = gleam; + }) + ]; + }; + }; }; })) // { nixosConfigurations.nixvim-machine = nixpkgs.lib.nixosSystem {