From 5eb30c9d70f0bef087cacc1f93543c2cf02366b1 Mon Sep 17 00:00:00 2001 From: luca-sartore-prorob <59091319+lucaSartore@users.noreply.github.com> Date: Wed, 30 Apr 2025 13:44:25 +0200 Subject: perf: execute sanitize_cmd only on Windows to speed up WSL #3808 Co-authored-by: Justin M. Keyes --- lua/lspconfig/configs.lua | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lua/lspconfig') diff --git a/lua/lspconfig/configs.lua b/lua/lspconfig/configs.lua index b32b8001..344b648e 100644 --- a/lua/lspconfig/configs.lua +++ b/lua/lspconfig/configs.lua @@ -24,8 +24,13 @@ local configs = {} --- @field root_dir? string|fun(filename: string, bufnr: number) --- @field commands? table +--- For Windows: calls exepath() to ensure .cmd/.bat (if appropriate) on commands. https://github.com/neovim/nvim-lspconfig/issues/3704 --- @param cmd any local function sanitize_cmd(cmd) + -- exepath() is slow, so avoid it on non-Windows. + if vim.fn.has('win32') == 0 then + return + end if cmd and type(cmd) == 'table' and not vim.tbl_isempty(cmd) then local original = cmd[1] cmd[1] = vim.fn.exepath(cmd[1]) -- cgit v1.2.3-70-g09d2