From 0dac6625740c824f651b256d03c3801c64ffc705 Mon Sep 17 00:00:00 2001 From: Tovi Jaeschke-Rogers Date: Wed, 11 Dec 2024 08:57:09 +1030 Subject: [PATCH] fix: find node module dir based on whether path exists not os --- .config/nvim/lua/plugins/lspconfig.lua | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/.config/nvim/lua/plugins/lspconfig.lua b/.config/nvim/lua/plugins/lspconfig.lua index 956557b..2a41ae1 100644 --- a/.config/nvim/lua/plugins/lspconfig.lua +++ b/.config/nvim/lua/plugins/lspconfig.lua @@ -92,19 +92,12 @@ return { local capabilities = vim.lsp.protocol.make_client_capabilities() capabilities = vim.tbl_deep_extend("force", capabilities, require("cmp_nvim_lsp").default_capabilities()) - -- Function to detect the operating system - local function get_os() - local handle = io.popen("uname") - if not handle then - return error("Failed to detect operating system") - end - local result = handle:read("*a") - handle:close() - return result:lower():gsub("%s+", "") - end - - local base_path = "/usr/lib/node_modules" - if get_os() == "darwin" then + local base_path = "" + if (vim.loop.fs_stat("/usr/lib/node_modules")) then + base_path = "/usr/lib/node_modules" + elseif (vim.loop.fs_stat("/usr/local/lib/node_modules")) then + base_path = "/usr/local/lib/node_modules" + elseif (vim.loop.fs_stat("/opt/homebrew/lib/node_modules")) then base_path = "/opt/homebrew/lib/node_modules" end