Skip to content

Commit d9dc62f

Browse files
committed
refactor: organize_imports
1 parent 7a37fb0 commit d9dc62f

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

lua/utils/organize_imports.lua

+3-10
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,9 @@ return function()
55
local tsserver_is_attached = next(vim.lsp.get_clients({ bufnr = bufnr, name = "tsserver" })) ~= nil
66
local command = tsserver_is_attached and "_typescript.organizeImports" or "source.organizeImports"
77

8-
if not tsserver_is_attached then
9-
local supports = false
10-
for _, client in ipairs(vim.lsp.get_clients({ bufnr = bufnr })) do
11-
if client.supports_method(method, { bufnr = bufnr }) then
12-
supports = true
13-
break
14-
end
15-
end
16-
if not supports then return end -- This client does not support the workspace/executeCommand method
17-
end
8+
local supports = tsserver_is_attached
9+
or next(vim.lsp.get_clients({ bufnr = bufnr, method = "workspace/executeCommand" })) ~= nil
10+
if not supports then return end -- This client does not support the workspace/executeCommand method
1811

1912
vim.lsp.buf_request_sync(bufnr, method, { command = command, arguments = { vim.api.nvim_buf_get_name(bufnr) } })
2013
end

0 commit comments

Comments
 (0)