From 1f5c005c030233438f049ec4de312b4e60184fda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BA=B3=E8=A5=BF=E5=A6=B2=20=C2=B7=20Nahida?= Date: Thu, 22 Aug 2024 02:01:03 +0800 Subject: [PATCH] feat(extras): custum the path of packages --- lua/lazyvim/plugins/extras/lang/angular.lua | 10 +++++++++- lua/lazyvim/plugins/extras/lang/astro.lua | 10 +++++++++- lua/lazyvim/plugins/extras/lang/python.lua | 9 +++++++-- lua/lazyvim/plugins/extras/lang/svelte.lua | 10 +++++++++- lua/lazyvim/plugins/extras/lang/typescript.lua | 10 +++++++++- lua/lazyvim/plugins/extras/lang/vue.lua | 10 +++++++++- 6 files changed, 52 insertions(+), 7 deletions(-) diff --git a/lua/lazyvim/plugins/extras/lang/angular.lua b/lua/lazyvim/plugins/extras/lang/angular.lua index f039c3a0..32d391da 100644 --- a/lua/lazyvim/plugins/extras/lang/angular.lua +++ b/lua/lazyvim/plugins/extras/lang/angular.lua @@ -1,3 +1,10 @@ +if lazyvim_docs then + -- If you don't use Mason to install the `angular-language-server` you can use the following to custom path for `@angular/language-server`. + vim.g.pkg_path = { + ["@angular/language-server"] = "path_to_this_node_package", + } +end + return { recommended = function() return LazyVim.extras.wants({ @@ -51,7 +58,8 @@ return { LazyVim.extend(opts.servers.vtsls, "settings.vtsls.tsserver.globalPlugins", { { name = "@angular/language-server", - location = LazyVim.get_pkg_path("angular-language-server", "/node_modules/@angular/language-server"), + location = vim.g.pkg_path and vim.g.pkg_path["@angular/language-server"] + or LazyVim.get_pkg_path("angular-language-server", "/node_modules/@angular/language-server"), enableForWorkspaceTypeScriptVersions = false, }, }) diff --git a/lua/lazyvim/plugins/extras/lang/astro.lua b/lua/lazyvim/plugins/extras/lang/astro.lua index 1364902b..58dca9bd 100644 --- a/lua/lazyvim/plugins/extras/lang/astro.lua +++ b/lua/lazyvim/plugins/extras/lang/astro.lua @@ -1,3 +1,10 @@ +if lazyvim_docs then + -- If you don't use Mason to install the `astro-language-server` you can use the following to custom path for `@astrojs/ts-plugin`. + vim.g.pkg_path = { + ["@astro/ts-plugin"] = "path_to_this_node_package", + } +end + return { recommended = function() return LazyVim.extras.wants({ @@ -37,7 +44,8 @@ return { LazyVim.extend(opts.servers.vtsls, "settings.vtsls.tsserver.globalPlugins", { { name = "@astrojs/ts-plugin", - location = LazyVim.get_pkg_path("astro-language-server", "/node_modules/@astrojs/ts-plugin"), + location = vim.g.pkg_path and vim.g.pkg_path["@astro/ts-plugin"] + or LazyVim.get_pkg_path("astro-language-server", "/node_modules/@astrojs/ts-plugin"), enableForWorkspaceTypeScriptVersions = true, }, }) diff --git a/lua/lazyvim/plugins/extras/lang/python.lua b/lua/lazyvim/plugins/extras/lang/python.lua index f85b23be..e22951ea 100644 --- a/lua/lazyvim/plugins/extras/lang/python.lua +++ b/lua/lazyvim/plugins/extras/lang/python.lua @@ -4,6 +4,10 @@ if lazyvim_docs then vim.g.lazyvim_python_lsp = "pyright" -- Set to "ruff_lsp" to use the old LSP implementation version. vim.g.lazyvim_python_ruff = "ruff" + -- If you don't use Mason to install the `debugpy` you can use the following to custom path for `debugpy`. + vim.g.pkg_path = { + ["debugpy"] = "path_to_this_package", + } end local lsp = vim.g.lazyvim_python_lsp or "pyright" @@ -103,10 +107,11 @@ return { { "dPc", function() require('dap-python').test_class() end, desc = "Debug Class", ft = "python" }, }, config = function() + local debugpy = vim.g.pkg_path and vim.g.pkg_path.debugpy if vim.fn.has("win32") == 1 then - require("dap-python").setup(LazyVim.get_pkg_path("debugpy", "/venv/Scripts/pythonw.exe")) + require("dap-python").setup(debugpy or LazyVim.get_pkg_path("debugpy", "/venv/Scripts/pythonw.exe")) else - require("dap-python").setup(LazyVim.get_pkg_path("debugpy", "/venv/bin/python")) + require("dap-python").setup(debugpy or LazyVim.get_pkg_path("debugpy", "/venv/bin/python")) end end, }, diff --git a/lua/lazyvim/plugins/extras/lang/svelte.lua b/lua/lazyvim/plugins/extras/lang/svelte.lua index 565e50e5..3fd5e746 100644 --- a/lua/lazyvim/plugins/extras/lang/svelte.lua +++ b/lua/lazyvim/plugins/extras/lang/svelte.lua @@ -1,3 +1,10 @@ +if lazyvim_docs then + -- If you don't use Mason to install the `svelte-language-server` you can use the following to custom path for `svelte-language-server`. + vim.g.pkg_path = { + ["svelte-language-server"] = "path_to_this_node_package", + } +end + return { recommended = function() return LazyVim.extras.wants({ @@ -48,7 +55,8 @@ return { LazyVim.extend(opts.servers.vtsls, "settings.vtsls.tsserver.globalPlugins", { { name = "typescript-svelte-plugin", - location = LazyVim.get_pkg_path("svelte-language-server", "/node_modules/typescript-svelte-plugin"), + location = vim.g.pkg_path and vim.g.pkg_path["typescript-svelte-plugin"] + or LazyVim.get_pkg_path("svelte-language-server", "/node_modules/typescript-svelte-plugin"), enableForWorkspaceTypeScriptVersions = true, }, }) diff --git a/lua/lazyvim/plugins/extras/lang/typescript.lua b/lua/lazyvim/plugins/extras/lang/typescript.lua index 71ec4604..b99e7fe3 100644 --- a/lua/lazyvim/plugins/extras/lang/typescript.lua +++ b/lua/lazyvim/plugins/extras/lang/typescript.lua @@ -1,3 +1,10 @@ +if lazyvim_docs then + -- If you don't use Mason to install the `js-debug-adapter` you can use the following to custom path for `js-debug-adapter`. + vim.g.pkg_path = { + ["js-debug-adapter"] = "path_to_this_node_package", + } +end + return { recommended = function() return LazyVim.extras.wants({ @@ -200,7 +207,8 @@ return { command = "node", -- 💀 Make sure to update this path to point to your installation args = { - LazyVim.get_pkg_path("js-debug-adapter", "/js-debug/src/dapDebugServer.js"), + vim.g.pkg_path and vim.g.pkg_path["js-debug-adapter"] + or LazyVim.get_pkg_path("js-debug-adapter", "/js-debug/src/dapDebugServer.js"), "${port}", }, }, diff --git a/lua/lazyvim/plugins/extras/lang/vue.lua b/lua/lazyvim/plugins/extras/lang/vue.lua index 088ce6a9..5eee954e 100644 --- a/lua/lazyvim/plugins/extras/lang/vue.lua +++ b/lua/lazyvim/plugins/extras/lang/vue.lua @@ -1,3 +1,10 @@ +if lazyvim_docs then + -- If you don't use Mason to install the `vue-language-server` you can use the following to custom path for `@vue/language-server`. + vim.g.pkg_path = { + ["@vue/language-server"] = "path_to_this_node_package", + } +end + return { recommended = function() return LazyVim.extras.wants({ @@ -39,7 +46,8 @@ return { LazyVim.extend(opts.servers.vtsls, "settings.vtsls.tsserver.globalPlugins", { { name = "@vue/typescript-plugin", - location = LazyVim.get_pkg_path("vue-language-server", "/node_modules/@vue/language-server"), + location = vim.g.pkg_path and vim.g.pkg_path["@vue/language-server"] + or LazyVim.get_pkg_path("vue-language-server", "/node_modules/@vue/language-server"), languages = { "vue" }, configNamespace = "typescript", enableForWorkspaceTypeScriptVersions = true,