mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-06-22 08:53:33 +02:00
feat(typescript): open locations from lsp execute command with trouble for vtsls
This commit is contained in:
parent
1bd4d2fc72
commit
a636bf2022
2 changed files with 32 additions and 3 deletions
|
@ -72,14 +72,23 @@ return {
|
|||
{
|
||||
"gD",
|
||||
function()
|
||||
require("vtsls").commands.goto_source_definition(0)
|
||||
local params = vim.lsp.util.make_position_params()
|
||||
LazyVim.lsp.execute({
|
||||
command = "typescript.goToSourceDefinition",
|
||||
arguments = { params.textDocument.uri, params.position },
|
||||
open = true,
|
||||
})
|
||||
end,
|
||||
desc = "Goto Source Definition",
|
||||
},
|
||||
{
|
||||
"gR",
|
||||
function()
|
||||
require("vtsls").commands.file_references(0)
|
||||
LazyVim.lsp.execute({
|
||||
command = "typescript.findAllFileReferences",
|
||||
arguments = { vim.uri_from_bufnr(0) },
|
||||
open = true,
|
||||
})
|
||||
end,
|
||||
desc = "File References",
|
||||
},
|
||||
|
@ -106,7 +115,7 @@ return {
|
|||
{
|
||||
"<leader>cV",
|
||||
function()
|
||||
require("vtsls").commands.select_ts_version(0)
|
||||
LazyVim.lsp.execute({ command = "typescript.selectTypeScriptVersion" })
|
||||
end,
|
||||
desc = "Select TS workspace version",
|
||||
},
|
||||
|
|
|
@ -337,4 +337,24 @@ M.action = setmetatable({}, {
|
|||
end
|
||||
end,
|
||||
})
|
||||
|
||||
---@class LspCommand: lsp.ExecuteCommandParams
|
||||
---@field open? boolean
|
||||
|
||||
---@param opts LspCommand
|
||||
function M.execute(opts)
|
||||
local params = {
|
||||
command = opts.command,
|
||||
arguments = opts.arguments,
|
||||
}
|
||||
if opts.open then
|
||||
require("trouble").open({
|
||||
mode = "lsp_command",
|
||||
params = params,
|
||||
})
|
||||
else
|
||||
return vim.lsp.buf_request(0, "workspace/executeCommand", params)
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue