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
38
39
40
41
42
43
44
45
46
47
48
49
50
|
local installer = require('nvim-lsp-installer.installer')
local capabilities = require('nvim-lsp-installer.capabilities')
local root_dir = installer.get_server_root_path('tsserver')
return installer.create_lsp_config_installer {
name = "tsserver",
root_dir = root_dir,
install_cmd = [[npm install typescript-language-server]],
default_options = {
cmd = { root_dir .. '/node_modules/.bin/typescript-language-server', '--stdio' },
capabilities = capabilities.create(),
},
extras = {
rename_file = function(old, new)
local old_uri = vim.uri_from_fname(old)
local new_uri = vim.uri_from_fname(new)
-- TODO: send only to tsserver
for _, client in pairs(vim.lsp.get_active_clients()) do
client.request(
'workspace/executeCommand',
{
command = '_typescript.applyRenameFile',
arguments = {
{
sourceUri = old_uri,
targetUri = new_uri,
},
},
}
)
end
end,
organize_imports = function(bufname)
bufname = bufname or vim.api.nvim_buf_get_name(0)
-- TODO: send only to tsserver
for _, client in pairs(vim.lsp.get_active_clients()) do
client.request(
'workspace/executeCommand',
{
command = '_typescript.organizeImports',
arguments = {bufname},
}
)
end
end,
}
}
|