aboutsummaryrefslogtreecommitdiffstats
path: root/lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua')
-rw-r--r--lua/nvim-lsp-installer.lua12
-rw-r--r--lua/nvim-lsp-installer/extras.lua11
-rw-r--r--lua/nvim-lsp-installer/extras/tsserver.lua37
-rw-r--r--lua/nvim-lsp-installer/installer.lua1
-rw-r--r--lua/nvim-lsp-installer/installers/tsserver.lua36
5 files changed, 48 insertions, 49 deletions
diff --git a/lua/nvim-lsp-installer.lua b/lua/nvim-lsp-installer.lua
index 76fd28d6..e19d27d7 100644
--- a/lua/nvim-lsp-installer.lua
+++ b/lua/nvim-lsp-installer.lua
@@ -8,16 +8,4 @@ M.get_uninstalled_servers = installer.get_uninstalled_servers
M.install = installer.install
M.uninstall = installer.uninstall
-function M.get_installer(server, only_installed)
- only_installed = only_installed ~= nil and only_installed or false
- local pool = only_installed and installer.get_installed_servers() or installer.get_available_servers()
-
- for _, server_installer in pairs(pool) do
- if server_installer.name == server then
- return server_installer
- end
- end
- return nil
-end
-
return M
diff --git a/lua/nvim-lsp-installer/extras.lua b/lua/nvim-lsp-installer/extras.lua
new file mode 100644
index 00000000..a9e2a07c
--- /dev/null
+++ b/lua/nvim-lsp-installer/extras.lua
@@ -0,0 +1,11 @@
+local M = {}
+
+function M.send_client_request(client_name, ...)
+ for _, client in pairs(vim.lsp.get_active_clients()) do
+ if client.name == client_name then
+ client.request(...)
+ end
+ end
+end
+
+return M
diff --git a/lua/nvim-lsp-installer/extras/tsserver.lua b/lua/nvim-lsp-installer/extras/tsserver.lua
new file mode 100644
index 00000000..201f80ca
--- /dev/null
+++ b/lua/nvim-lsp-installer/extras/tsserver.lua
@@ -0,0 +1,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
diff --git a/lua/nvim-lsp-installer/installer.lua b/lua/nvim-lsp-installer/installer.lua
index 59401e5c..bba50976 100644
--- a/lua/nvim-lsp-installer/installer.lua
+++ b/lua/nvim-lsp-installer/installer.lua
@@ -130,7 +130,6 @@ function M.create_lsp_config_installer(module)
vim.tbl_deep_extend('force', module.default_options, opts)
)
end,
- extras = module.extras or {},
}
end
diff --git a/lua/nvim-lsp-installer/installers/tsserver.lua b/lua/nvim-lsp-installer/installers/tsserver.lua
index eef82503..6ba1ec98 100644
--- a/lua/nvim-lsp-installer/installers/tsserver.lua
+++ b/lua/nvim-lsp-installer/installers/tsserver.lua
@@ -11,40 +11,4 @@ return installer.create_lsp_config_installer {
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,
- }
}