Skip to content

Commit

Permalink
feat: add option to customize tsserver locale
Browse files Browse the repository at this point in the history
  • Loading branch information
pmizio committed Oct 19, 2023
1 parent 47c0461 commit 2383b0a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ require("typescript-tools").setup {
-- described below
tsserver_format_options = {},
tsserver_file_preferences = {},
-- locale of all tsserver messages, supported locales you can find here:
-- https://github.com/microsoft/TypeScript/blob/3c221fc086be52b19801f6e8d82596d04607ede6/src/compiler/utilitiesPublic.ts#L620
tsserver_locale = "en",
-- mirror of VSCode's `typescript.suggest.completeFunctionCalls`
complete_function_calls = false,
include_completions_with_insert_text = true,
Expand Down
10 changes: 10 additions & 0 deletions lua/typescript-tools/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +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 tsserver_locale string
---@field complete_function_calls boolean
---@field expose_as_code_action ("fix_all"| "add_missing_imports"| "remove_unused" | "remove_unused_imports")[]
---@field include_completions_with_insert_text boolean
Expand Down Expand Up @@ -118,6 +119,11 @@ function M.load_settings(settings)
{ "number", "string" },
true,
},
["settings.tsserver_locale"] = {
settings.tsserver_locale,
"string",
true,
},
["settings.complete_function_calls"] = { settings.complete_function_calls, "boolean", true },
["settings.expose_as_code_action"] = {
settings.expose_as_code_action,
Expand Down Expand Up @@ -163,6 +169,10 @@ function M.load_settings(settings)
__store.tsserver_max_memory = "auto"
end

if not settings.tsserver_locale then
__store.tsserver_locale = "en"
end

if not settings.complete_function_calls then
__store.complete_function_calls = false
end
Expand Down
2 changes: 1 addition & 1 deletion lua/typescript-tools/process.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function Process.new(type, on_response, on_exit)
self.args = {
tsserver_provider:get_executable_path():absolute(),
"--stdio",
"--local", "en",
"--locale", plugin_config.tsserver_locale,
"--useInferredProjectPerProjectRoot",
"--validateDefaultNpmLocation",
"--noGetErrOnBackgroundUpdate",
Expand Down

0 comments on commit 2383b0a

Please sign in to comment.