2021-10-27 20:37:42 +02:00
|
|
|
local lsp_installer = require("nvim-lsp-installer")
|
2022-04-15 14:52:17 +02:00
|
|
|
local lsp_format = require("lsp-format");
|
|
|
|
lsp_format.setup {}
|
|
|
|
|
|
|
|
local function organize_imports()
|
|
|
|
local params = {
|
|
|
|
command = "_typescript.organizeImports",
|
|
|
|
arguments = {vim.api.nvim_buf_get_name(0)},
|
|
|
|
title = ""
|
|
|
|
}
|
|
|
|
vim.lsp.buf.execute_command(params)
|
|
|
|
end
|
2022-04-09 19:38:57 +02:00
|
|
|
|
2021-10-27 20:37:42 +02:00
|
|
|
|
2022-03-14 19:21:46 +01:00
|
|
|
lsp_installer.on_server_ready(
|
|
|
|
function(server)
|
2022-04-15 14:52:17 +02:00
|
|
|
|
2022-04-09 19:38:57 +02:00
|
|
|
local opts = {
|
2022-04-15 14:52:17 +02:00
|
|
|
on_attach = lsp_format.on_attach
|
2022-04-09 19:38:57 +02:00
|
|
|
}
|
2022-04-15 14:52:17 +02:00
|
|
|
|
|
|
|
if server.name == "tsserver" then
|
|
|
|
opts.commands = {
|
|
|
|
OrganizeImports = {
|
|
|
|
organize_imports,
|
|
|
|
description = "Organize Imports"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
2021-10-27 20:37:42 +02:00
|
|
|
|
2022-03-14 19:21:46 +01:00
|
|
|
-- This setup() function is exactly the same as lspconfig's setup function (:help lspconfig-quickstart)
|
2022-04-09 19:38:57 +02:00
|
|
|
server:setup(opts)
|
2022-03-14 19:21:46 +01:00
|
|
|
end
|
|
|
|
)
|