|
@@ -29,6 +29,8 @@ else
|
|
|
}
|
|
|
end
|
|
|
|
|
|
+ local base_on_attach = vim.lsp.config["ts_ls"].on_attach
|
|
|
+
|
|
|
vim.lsp.config("ts_ls", {
|
|
|
init_options = {
|
|
|
completionDisableFilterText = true,
|
|
@@ -43,21 +45,6 @@ else
|
|
|
['$/typescriptVersion'] = function(err, result, ctx, config)
|
|
|
vim.notify(string.format('Typescript %s', result.version))
|
|
|
end,
|
|
|
-
|
|
|
- -- handler used with extract type to interface, etc which asks to rename
|
|
|
- -- the newly created type
|
|
|
- ['_typescript.rename'] = function(err, result, ctx)
|
|
|
- local client = vim.lsp.get_client_by_id(ctx.client_id)
|
|
|
- vim.lsp.util.show_document({
|
|
|
- uri = result.textDocument.uri,
|
|
|
- range = {
|
|
|
- start = result.position,
|
|
|
- ['end'] = result.position,
|
|
|
- }
|
|
|
- }, client.offset_encoding)
|
|
|
- vim.lsp.buf.rename()
|
|
|
- return result
|
|
|
- end,
|
|
|
},
|
|
|
flags = {
|
|
|
debounce_text_changes = 150,
|
|
@@ -75,23 +62,9 @@ else
|
|
|
})
|
|
|
end,
|
|
|
on_attach = function(client)
|
|
|
+ base_on_attach(client)
|
|
|
-- add custom commands, we follow upstream's Lsp* prefix convention
|
|
|
|
|
|
- -- setup custom source actions, unlike code actions these apply to the
|
|
|
- -- whole file rather than a particular line.
|
|
|
- local function source_action(usercmd_name, command_name)
|
|
|
- vim.api.nvim_buf_create_user_command(0, usercmd_name, function()
|
|
|
- vim.lsp.buf.code_action({
|
|
|
- context = { only = { command_name } },
|
|
|
- apply = true,
|
|
|
- })
|
|
|
- end, {})
|
|
|
- end
|
|
|
-
|
|
|
- source_action("LspAddMissingImports", "source.addMissingImports.ts")
|
|
|
- source_action("LspOrganizeImports", "source.organizeImports.ts")
|
|
|
- source_action("LspRemoveUnusedImports", "source.removeUnusedImports.ts")
|
|
|
-
|
|
|
-- rename file with import renaming, this does no error checking
|
|
|
vim.api.nvim_buf_create_user_command(0, "LspRenameFile", function()
|
|
|
local source = vim.api.nvim_buf_get_name(0)
|