From 75fa02fc028111835be01438c318e4e7549a0d34 Mon Sep 17 00:00:00 2001 From: Timothy DeHerrera Date: Mon, 11 Jan 2021 20:07:18 -0700 Subject: [PATCH] kakoune: add haskell lsp support --- pkgs/override.nix | 10 ++ profiles/develop/kakoune/default.nix | 11 +- profiles/develop/kakoune/kak-lsp.toml | 191 +++++++++++++++++++++++ profiles/develop/kakoune/lsp/common.kak | 2 +- profiles/develop/kakoune/lsp/haskell.kak | 3 + 5 files changed, 208 insertions(+), 9 deletions(-) create mode 100644 profiles/develop/kakoune/kak-lsp.toml create mode 100644 profiles/develop/kakoune/lsp/haskell.kak diff --git a/pkgs/override.nix b/pkgs/override.nix index bf146e2..e5720a6 100644 --- a/pkgs/override.nix +++ b/pkgs/override.nix @@ -14,4 +14,14 @@ pkgs: final: prev: signal-desktop starship; + haskellPackages = prev.haskellPackages.override { + overrides = hfinal: hprev: + let version = prev.lib.replaceChars [ "." ] [ "" ] prev.ghc.version; + in + { + # same for haskell packages, matching ghc versions + inherit (pkgs.haskell.packages."ghc${version}") + haskell-language-server; + }; + }; } diff --git a/profiles/develop/kakoune/default.nix b/profiles/develop/kakoune/default.nix index 90e8360..7365d4a 100644 --- a/profiles/develop/kakoune/default.nix +++ b/profiles/develop/kakoune/default.nix @@ -1,5 +1,5 @@ { pkgs, ... }: { - imports = [ ../python ]; + imports = [ ../python ../haskell ]; environment.systemPackages = with pkgs; [ clang-tools @@ -13,16 +13,11 @@ nix-linter dhall dhall-lsp-server + haskellPackages.haskell-language-server ]; environment.etc = { - "xdg/kak-lsp/kak-lsp.toml".text = '' - ${builtins.readFile "${pkgs.kak-lsp.src}/kak-lsp.toml"} - [language.dhall] - filetypes = ["dhall"] - roots = [".git"] - command = "dhall-lsp-server" - ''; + "xdg/kak-lsp/kak-lsp.toml".source = ./kak-lsp.toml; "xdg/kak/kakrc".source = ./kakrc; "xdg/kak/autoload/plugins".source = ./plugins; "xdg/kak/autoload/lint".source = ./lint; diff --git a/profiles/develop/kakoune/kak-lsp.toml b/profiles/develop/kakoune/kak-lsp.toml new file mode 100644 index 0000000..9f5d8fb --- /dev/null +++ b/profiles/develop/kakoune/kak-lsp.toml @@ -0,0 +1,191 @@ +snippet_support = true +verbosity = 2 + +[semantic_scopes] +# Map textmate scopes to kakoune faces for semantic highlighting +# the underscores are translated to dots, and indicate nesting. +# That is, if variable_other_field is omitted, it will try the face for +# variable_other and then variable +# +# To see a list of available scopes in the debug buffer, run lsp-semantic-available-scopes +variable = "variable" +entity_name_function = "function" +entity_name_type = "type" +variable_other_enummember = "variable" +entity_name_namespace = "module" + +# Semantic tokens support +# See https://github.com/microsoft/vscode-languageserver-node/blob/8c8981eb4fb6adec27bf1bb5390a0f8f7df2899e/client/src/semanticTokens.proposed.ts#L288 +# for token/modifier types. + +[semantic_tokens] +type = "type" +variable = "variable" +namespace = "module" +function = "function" +string = "string" +keyword = "keyword" +operator = "operator" +comment = "comment" + +[semantic_token_modifiers] +documentation = "documentation" +readonly = "default+d" + +[server] +# exit session if no requests were received during given period in seconds +# works only in unix sockets mode (-s/--session) +# set to 0 to disable +timeout = 1800 # seconds = 30 minutes + +[language.bash] +filetypes = ["sh"] +roots = [".git", ".hg"] +command = "bash-language-server" +args = ["start"] + +[language.c_cpp] +filetypes = ["c", "cpp"] +roots = ["compile_commands.json", ".clangd"] +command = "clangd" + +[language.crystal] +filetypes = ["crystal"] +roots = ["shard.yml"] +command = "scry" + +[language.css] +filetypes = ["css"] +roots = ["package.json"] +command = "css-languageserver" +args = ["--stdio"] + +[language.d] +filetypes = ["d", "di"] +roots = [".git", "dub.sdl", "dub.json"] +command = "dls" + +[language.dart] +# start shell to find path to dart analysis server source +filetypes = ["dart"] +roots = ["pubspec.yaml", ".git"] +command = "sh" +args = ["-c", "dart $(dirname $(which dart))/snapshots/analysis_server.dart.snapshot --lsp"] + +[language.elixir] +filetypes = ["elixir"] +roots = ["mix.exs"] +command = "elixir-ls" + +[language.elm] +filetypes = ["elm"] +roots = ["elm.json"] +command = "elm-language-server" +args = ["--stdio"] + +[language.elm.initialization_options] +runtime = "node" +elmPath = "elm" +elmFormatPath = "elm-format" +elmTestPath = "elm-test" + +[language.go] +filetypes = ["go"] +roots = ["Gopkg.toml", "go.mod", ".git", ".hg"] +command = "gopls" +offset_encoding = "utf-8" + +[language.haskell] +filetypes = ["haskell"] +roots = ["Setup.hs", "stack.yaml", "*.cabal"] +command = "haskell-language-server" +args = ["--lsp"] + +[language.html] +filetypes = ["html"] +roots = ["package.json"] +command = "html-languageserver" +args = ["--stdio"] + +[language.javascript] +filetypes = ["javascript"] +roots = [".flowconfig"] +command = "flow" +args = ["lsp"] + +[language.json] +filetypes = ["json"] +roots = ["package.json"] +command = "json-languageserver" +args = ["--stdio"] + +[language.latex] +filetypes = ["latex"] +roots = [".git"] +command = "texlab" + +[language.nim] +filetypes = ["nim"] +roots = ["*.nimble", ".git"] +command = "nimlsp" + +[language.nix] +filetypes = ["nix"] +roots = ["flake.nix", "shell.nix", ".git"] +command = "rnix-lsp" + +[language.dhall] +filetypes = ["dhall"] +roots = [".git"] +command = "dhall-lsp-server" + +[language.ocaml] +filetypes = ["ocaml"] +roots = ["Makefile", "opam", "*.opam", "dune"] +command = "ocaml-language-server" +args = ["--stdio"] + +[language.php] +filetypes = ["php"] +roots = [".htaccess", "composer.json"] +command = "intelephense" +args = ["--stdio"] + +[language.php.initialization_options] +storagePath = "/tmp/intelephense" + +[language.python] +filetypes = ["python"] +roots = ["requirements.txt", "setup.py", ".git", ".hg"] +command = "pyls" +offset_encoding = "utf-8" + +[language.reason] +filetypes = ["reason"] +roots = ["package.json", "Makefile", ".git", ".hg"] +command = "ocaml-language-server" +args = ["--stdio"] + +[language.ruby] +filetypes = ["ruby"] +roots = ["Gemfile"] +command = "solargraph" +args = ["stdio"] + +[language.rust] +filetypes = ["rust"] +roots = ["Cargo.toml"] +command = "sh" +args = ["-c", "if command -v rustup >/dev/null; then $(rustup which rls); else rls; fi"] + +# [language.rust] +# filetypes = ["rust"] +# roots = ["Cargo.toml"] +# command = "sh" +# args = ["-c", "if command -v rustup >/dev/null; then $(rustup which rust-analyzer); else rust-analyzer; fi"] + +[language.terraform] +filetypes = ["terraform"] +roots = ["*.tf"] +command = "terraform-ls" +args = ["serve"] diff --git a/profiles/develop/kakoune/lsp/common.kak b/profiles/develop/kakoune/lsp/common.kak index bf9253c..c2f55df 100644 --- a/profiles/develop/kakoune/lsp/common.kak +++ b/profiles/develop/kakoune/lsp/common.kak @@ -1,5 +1,5 @@ eval %sh{kak-lsp --kakoune -s $kak_session} -hook -group lsp global WinSetOption filetype=(elm|rust|c|cpp|python|dhall) %{ +hook -group lsp global WinSetOption filetype=(elm|rust|c|cpp|python|dhall|haskell) %{ lsp-auto-hover-enable # easily enter lsp mode diff --git a/profiles/develop/kakoune/lsp/haskell.kak b/profiles/develop/kakoune/lsp/haskell.kak new file mode 100644 index 0000000..ff927a3 --- /dev/null +++ b/profiles/develop/kakoune/lsp/haskell.kak @@ -0,0 +1,3 @@ +hook -group lsp global WinSetOption filetype=haskell %{ + lsp-enable-window +}