aboutsummaryrefslogtreecommitdiffstats
path: root/lua/nvim-lsp-installer/extras/tsserver.lua
blob: 201f80cafd39bb13e9819d4eb3c2571002a05be2 (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
30
31
32
33
34
35
36
37
local extras = require'nvim-lsp-installer.extras'

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