Skip to content

Make node executable configurable #237

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ require("typescript-tools").setup {
-- 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",
-- Node executable configuration (for example, bun)
tsserver_node_executable = "bun",
-- 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 @@ -9,6 +9,7 @@
---@field tsserver_file_preferences table|fun(filetype: string): table
---@field tsserver_max_memory number|"auto"
---@field tsserver_locale string
---@field tsserver_node_executable 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 @@ -125,6 +126,11 @@ function M.load_settings(settings)
"string",
true,
},
["settings.tsserver_node_executable"] = {
settings.tsserver_node_executable,
"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_file_preferences = {}
end

if not settings.tsserver_node_executable then
__store.tsserver_node_executable = "node"
end

if not M.tsserver_log_level[settings.tsserver_logs] then
__store.tsserver_logs = M.tsserver_log_level.off
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 @@ -123,7 +123,7 @@ local function parse_response(initial_chunk, on_response)
end

function Process:start()
local command = is_win and "cmd.exe" or "node"
local command = is_win and "cmd.exe" or plugin_config.tsserver_node_executable
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved default value to config.


if type(plugin_config.tsserver_max_memory) == "number" then
table.insert(self.args, 1, "--max-old-space-size=" .. plugin_config.tsserver_max_memory)
Expand Down