diff --git a/README.md b/README.md index fcf7905..df07c65 100644 --- a/README.md +++ b/README.md @@ -138,9 +138,8 @@ require("typescript-tools").setup { -- described below tsserver_format_options = {}, tsserver_file_preferences = {}, - -- mirror of https://github.com/microsoft/vscode/blob/885dba39a5f546c5077196a8c31b03d03a293b31/extensions/typescript-language-features/package.json#L145-L1266 - -- `typescript-tools.nvim` currently only supports `typescript.suggest.completeFunctionCalls` - vscode_configuration = { ["typescript.suggest.completeFunctionCalls"] = true }, + -- mirror of VSCode's `typescript.suggest.completeFunctionCalls` + complete_function_calls = false, }, } ``` diff --git a/lua/typescript-tools/config.lua b/lua/typescript-tools/config.lua index b988ab6..0ff56ef 100644 --- a/lua/typescript-tools/config.lua +++ b/lua/typescript-tools/config.lua @@ -1,6 +1,3 @@ ----@see https://github.com/microsoft/vscode/blob/885dba39a5f546c5077196a8c31b03d03a293b31/extensions/typescript-language-features/package.json#L145-L1266 ----@alias VsCodeConfiguration { typescript.suggest.completeFunctionCalls: boolean } - ---@class Settings ---@field plugin_name string ---@field separate_diagnostic_server boolean @@ -11,7 +8,7 @@ ---@field tsserver_format_options table|fun(filetype: string): table ---@field tsserver_file_preferences table|fun(filetype: string): table ---@field tsserver_max_memory number|"auto" ----@field vscode_configuration VsCodeConfiguration +---@field complete_function_calls boolean ---@field expose_as_code_action ("fix_all"| "add_missing_imports"| "remove_unused")[] local M = {} local __store = {} @@ -110,7 +107,7 @@ function M.load_settings(settings) { "number", "string" }, true, }, - ["settings.vscode_configuration"] = { settings.vscode_configuration, "table", true }, + ["settings.complete_function_calls"] = { settings.complete_function_calls, "boolean", true }, ["settings.expose_as_code_action"] = { settings.expose_as_code_action, "table", @@ -148,8 +145,8 @@ function M.load_settings(settings) __store.tsserver_max_memory = "auto" end - if not settings.vscode_configuration then - __store.vscode_configuration = {} + if not settings.complete_function_calls then + __store.complete_function_calls = false end if not settings.expose_as_code_action then diff --git a/lua/typescript-tools/protocol/utils.lua b/lua/typescript-tools/protocol/utils.lua index 6b90246..d74c635 100644 --- a/lua/typescript-tools/protocol/utils.lua +++ b/lua/typescript-tools/protocol/utils.lua @@ -231,7 +231,7 @@ function M.should_create_function_snippet(kind, filetype) local preferences = plugin_config.get_tsserver_file_preferences(filetype) return preferences.includeCompletionsWithSnippetText and (kind == c.CompletionItemKind.Function or kind == c.CompletionItemKind.Method) - and plugin_config.vscode_configuration["typescript.suggest.completeFunctionCalls"] + and plugin_config.complete_function_calls end return M diff --git a/tests/requests_spec.lua b/tests/requests_spec.lua index a44f5f7..e641a81 100644 --- a/tests/requests_spec.lua +++ b/tests/requests_spec.lua @@ -160,9 +160,8 @@ describe("Lsp request", function() assert.are.same(completions[#completions], "warn") -- same test as above but with function snippets enabled - local prev_config = - plugin_config.vscode_configuration["typescript.suggest.completeFunctionCalls"] - plugin_config.vscode_configuration["typescript.suggest.completeFunctionCalls"] = true + local prev_config = plugin_config.complete_function_calls + plugin_config.complete_function_calls = true ret = vim.lsp.buf_request_sync(0, methods.Completion, req) result = lsp_assert.response(ret) @@ -182,7 +181,7 @@ describe("Lsp request", function() assert.are.same(completions[1], "assert(...)") assert.are.same(completions[#completions], "warn(...)") - plugin_config.vscode_configuration["typescript.suggest.completeFunctionCalls"] = prev_config + plugin_config.complete_function_calls = prev_config end) it("should return correct response for " .. methods.CompletionResolve, function() @@ -212,9 +211,8 @@ describe("Lsp request", function() assert.are.same(result.detail, "(method) Console.warn(...data: any[]): void") -- same test as above but with function snippets enabled - local prev_config = - plugin_config.vscode_configuration["typescript.suggest.completeFunctionCalls"] - plugin_config.vscode_configuration["typescript.suggest.completeFunctionCalls"] = true + local prev_config = plugin_config.complete_function_calls + plugin_config.complete_function_calls = true req.label = "warn(...)" req.insertTextFormat = c.InsertTextFormat.Snippet @@ -225,7 +223,7 @@ describe("Lsp request", function() assert.are.same(result.insertText, "warn($1)$0") assert.are.same(result.detail, "(method) Console.warn(...data: any[]): void") - plugin_config.vscode_configuration["typescript.suggest.completeFunctionCalls"] = prev_config + plugin_config.complete_function_calls = prev_config end) it("should return correct response for " .. methods.SignatureHelp, function()