diff options
author | Linnnus <[email protected]> | 2024-09-18 22:21:17 +0200 |
---|---|---|
committer | Linnnus <[email protected]> | 2024-09-18 22:25:05 +0200 |
commit | 1af0311f02e9035a9ff5789207974e642ca8b784 (patch) | |
tree | a7c09d5a3227ae9f83d4ffa1c78b78741ea69a88 /hosts | |
parent | 5a4a0326a41c067e3f265fe8d3d8fc15ee7b07e2 (diff) |
muhammed: Add nodeJS and TS server
Diffstat (limited to 'hosts')
-rw-r--r-- | hosts/muhammed/home/dev-utils/default.nix | 1 | ||||
-rw-r--r-- | hosts/muhammed/home/neovim/lsp.nix | 25 |
2 files changed, 26 insertions, 0 deletions
diff --git a/hosts/muhammed/home/dev-utils/default.nix b/hosts/muhammed/home/dev-utils/default.nix index 209c17b..a2a3a40 100644 --- a/hosts/muhammed/home/dev-utils/default.nix +++ b/hosts/muhammed/home/dev-utils/default.nix @@ -30,6 +30,7 @@ guile vemf gleam + nodejs_latest # Rust ecosystem rustc diff --git a/hosts/muhammed/home/neovim/lsp.nix b/hosts/muhammed/home/neovim/lsp.nix index b776b08..840d919 100644 --- a/hosts/muhammed/home/neovim/lsp.nix +++ b/hosts/muhammed/home/neovim/lsp.nix @@ -61,6 +61,7 @@ root_dir = function(startpath) if util.find_package_json_ancestor(startpath) then -- This is a Node project; let tsserver handle this one. + -- This exactly mirrors how typescript-langauge-server yields to this server for Deno projects. return nil else -- Otherwise, we try to find the root or @@ -70,6 +71,30 @@ end end, }, + -- NOTE: Will be renamed to ts_ls shortly + -- See: https://github.com/neovim/nvim-lspconfig/commit/bdbc65aadc708ce528efb22bca5f82a7cca6b54d + tsserver = { + cmd = { "${pkgs.nodePackages_latest.typescript-language-server}/bin/typescript-language-server", "--stdio" }, + root_dir = function(startpath) + local find_deno_root_dir = util.root_pattern("deno.json", "deno.jsonc") + if find_deno_root_dir(startpath) then + -- This is a Deno project; let deno-lsp handle this one. + -- This exactly mirrors how deno-lsp yields to this server for Node projects. + return nil + else + -- Otherwise fall back to the usual resolution method. + -- See: https://github.com/neovim/nvim-lspconfig/blob/056f569f71e4b726323b799b9cfacc53653bceb3/lua/lspconfig/server_configurations/ts_ls.lua#L15 + return util.root_pattern("tsconfig.json", "jsconfig.json", "package.json", ".git")(startpath) + end + end, + -- We also have to disallow starting in without a root directory, as otherwise returning + -- nil from find_root will just cause the LSP to be spawned in single file mode instead of yielding to deno-lsp. + -- + -- This has the side effect that Deno LSP will be preferred in a single file context which is what we want! + -- + -- See: https://github.com/neovim/nvim-lspconfig/blob/056f569f71e4b726323b799b9cfacc53653bceb3/lua/lspconfig/manager.lua#L281-L286 + single_file_support = false, + }, clangd = { cmd = { "${pkgs.clang-tools}/bin/clangd" }, }, |