aboutsummaryrefslogtreecommitdiffstats
path: root/lua/nvim-lsp-installer/extras/tsserver.lua
blob: e8a85227375ff4de342cb09795e5f9a1bb9b0b8b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
local extras = require "nvim-lsp-installer.extras.utils"

local M = {}

function M.rename_file(old, new)
    local old_uri = vim.uri_from_fname(old)
    local new_uri = vim.uri_from_fname(new)

    extras.send_client_request("tsserver", "workspace/executeCommand", {
        command = "_typescript.applyRenameFile",
        arguments = {
            {
                sourceUri = old_uri,
                targetUri = new_uri,
            },
        },
    })
end

function M.organize_imports(bufname)
    bufname = bufname or vim.api.nvim_buf_get_name(0)

    extras.send_client_request("tsserver", "workspace/executeCommand", {
        command = "_typescript.organizeImports",
        arguments = { bufname },
    })
end

return M