mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-06-29 04:00:11 +02:00
refactor: refactored mason/typescript/vue support
This commit is contained in:
parent
135150307b
commit
9d999fa210
6 changed files with 70 additions and 37 deletions
|
@ -106,8 +106,7 @@ return {
|
|||
{ "<leader>dPc", function() require('dap-python').test_class() end, desc = "Debug Class", ft = "python" },
|
||||
},
|
||||
config = function()
|
||||
local path = require("mason-registry").get_package("debugpy"):get_install_path()
|
||||
require("dap-python").setup(path .. "/venv/bin/python")
|
||||
require("dap-python").setup(LazyVim.get_pkg_path("debugpy", "/venv/bin/python"))
|
||||
end,
|
||||
},
|
||||
},
|
||||
|
|
|
@ -32,10 +32,21 @@ return {
|
|||
enabled = false,
|
||||
},
|
||||
vtsls = {
|
||||
-- explicitly add default filetypes, so that we can extend
|
||||
-- them in related extras
|
||||
filetypes = {
|
||||
"javascript",
|
||||
"javascriptreact",
|
||||
"javascript.jsx",
|
||||
"typescript",
|
||||
"typescriptreact",
|
||||
"typescript.tsx",
|
||||
},
|
||||
settings = {
|
||||
complete_function_calls = true,
|
||||
vtsls = {
|
||||
enableMoveToFileCodeAction = true,
|
||||
autoUseWorkspaceTsdk = true,
|
||||
experimental = {
|
||||
completion = {
|
||||
enableServerSideFuzzyMatch = true,
|
||||
|
@ -147,8 +158,7 @@ return {
|
|||
command = "node",
|
||||
-- 💀 Make sure to update this path to point to your installation
|
||||
args = {
|
||||
require("mason-registry").get_package("js-debug-adapter"):get_install_path()
|
||||
.. "/js-debug/src/dapDebugServer.js",
|
||||
LazyVim.get_pkg_path("js-debug-adapter", "/js-debug/src/dapDebugServer.js"),
|
||||
"${port}",
|
||||
},
|
||||
},
|
||||
|
|
|
@ -6,6 +6,9 @@ return {
|
|||
})
|
||||
end,
|
||||
|
||||
-- depends on the typescript extra
|
||||
{ import = "lazyvim.plugins.extras.lang.typescript" },
|
||||
|
||||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
opts = function(_, opts)
|
||||
|
@ -15,34 +18,30 @@ return {
|
|||
end,
|
||||
},
|
||||
|
||||
-- Add LSP servers
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
opts = {
|
||||
servers = {
|
||||
volar = {},
|
||||
vtsls = {},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- Configure tsserver plugin
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
opts = function(_, opts)
|
||||
local vue_typescript_plugin = require("mason-registry").get_package("vue-language-server"):get_install_path()
|
||||
.. "/node_modules/@vue/language-server"
|
||||
.. "/node_modules/@vue/typescript-plugin"
|
||||
|
||||
opts.servers = vim.tbl_deep_extend("force", opts.servers, {
|
||||
volar = {},
|
||||
-- Volar 2.0 has discontinued their "take over mode" which in previous version provided support for typescript in vue files.
|
||||
-- The new approach to get typescript support involves using the typescript language server along side volar.
|
||||
vtsls = {
|
||||
filetypes = {
|
||||
"javascript",
|
||||
"javascriptreact",
|
||||
"javascript.jsx",
|
||||
"typescript",
|
||||
"typescriptreact",
|
||||
"typescript.tsx",
|
||||
"vue",
|
||||
},
|
||||
},
|
||||
})
|
||||
table.insert(opts.servers.vtsls.filetypes, "vue")
|
||||
LazyVim.extend(opts.servers.vtsls, "settings.vtsls.tsserver.globalPlugins", {
|
||||
{
|
||||
name = "@vue/typescript-plugin",
|
||||
location = vue_typescript_plugin,
|
||||
location = LazyVim.get_pkg_path("vue-language-server", "/node_modules/@vue/language-server"),
|
||||
languages = { "vue" },
|
||||
configNamespace = "typescript",
|
||||
enableForWorkspaceTypeScriptVersions = true,
|
||||
},
|
||||
})
|
||||
end,
|
||||
},
|
||||
|
|
|
@ -284,19 +284,15 @@ return {
|
|||
})
|
||||
end, 100)
|
||||
end)
|
||||
local function ensure_installed()
|
||||
|
||||
mr.refresh(function()
|
||||
for _, tool in ipairs(opts.ensure_installed) do
|
||||
local p = mr.get_package(tool)
|
||||
if not p:is_installed() then
|
||||
p:install()
|
||||
end
|
||||
end
|
||||
end
|
||||
if mr.refresh then
|
||||
mr.refresh(ensure_installed)
|
||||
else
|
||||
ensure_installed()
|
||||
end
|
||||
end)
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ local prios = {
|
|||
["lazyvim.plugins.extras.editor.aerial"] = 100,
|
||||
["lazyvim.plugins.extras.editor.outline"] = 100,
|
||||
["lazyvim.plugins.extras.editor.trouble-v3"] = 100,
|
||||
["lazyvim.plugins.extras.lang.typescript"] = 5,
|
||||
["lazyvim.plugins.extras.ui.edgy"] = 2,
|
||||
["lazyvim.plugins.extras.test.core"] = 1,
|
||||
["lazyvim.plugins.extras.dap.core"] = 1,
|
||||
|
|
|
@ -72,7 +72,12 @@ function M.on_very_lazy(fn)
|
|||
})
|
||||
end
|
||||
|
||||
function M.extend(t, key, value)
|
||||
---@generic T
|
||||
---@param t T[]
|
||||
---@param key string
|
||||
---@param values T[]
|
||||
---@return T[]?
|
||||
function M.extend(t, key, values)
|
||||
local keys = vim.split(key, ".", { plain = true })
|
||||
for i = 1, #keys do
|
||||
local k = keys[i]
|
||||
|
@ -82,7 +87,7 @@ function M.extend(t, key, value)
|
|||
end
|
||||
t = t[k]
|
||||
end
|
||||
t[#t + 1] = value
|
||||
return vim.list_extend(t, values)
|
||||
end
|
||||
|
||||
---@param name string
|
||||
|
@ -211,4 +216,27 @@ function M.create_undo()
|
|||
end
|
||||
end
|
||||
|
||||
--- Gets a path to a package in the Mason registry.
|
||||
--- Prefer this to `get_package`, since the package might not always be
|
||||
--- available yet and trigger errors.
|
||||
---@param pkg string
|
||||
---@param path? string
|
||||
function M.get_pkg_path(pkg, path)
|
||||
path = path or ""
|
||||
local ret = vim.env.MASON .. "/packages/" .. pkg .. "/" .. path
|
||||
if not vim.loop.fs_stat(ret) then
|
||||
M.warn(("Mason package path not found for **%s**:\n- `%s`"):format(pkg, path))
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
--- Override the default title for notifications.
|
||||
for _, level in ipairs({ "info", "warn", "error" }) do
|
||||
M[level] = function(msg, opts)
|
||||
opts = opts or {}
|
||||
opts.title = opts.title or "LazyVim"
|
||||
return LazyUtil[level](msg, opts)
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue