Browse Source

fix: find node module dir based on whether path exists not os

master
Tovi Jaeschke-Rogers 2 weeks ago
parent
commit
0dac662574
1 changed files with 6 additions and 13 deletions
  1. +6
    -13
      .config/nvim/lua/plugins/lspconfig.lua

+ 6
- 13
.config/nvim/lua/plugins/lspconfig.lua View File

@ -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


Loading…
Cancel
Save