sublimelsp / LSP-typescript

TypeScript, JavaScript support for Sublime LSP plugin
MIT License
131 stars 11 forks source link

How to configure for locally installed language servers? #219

Closed benfrain closed 11 months ago

benfrain commented 11 months ago

On my work machines we are unable to access npm.

Therefore, my local versions of my LSPs are installed here: $HOME/.local/share/nvim/spec/node_modules/.bin:$PATH

Is there a way to configure LSP-typescript (or even the LSP package in general) to look here for the language servers?

I have already updated my .zshrc with this and the LSPs work fine in Neovim.

export PATH="$HOME/.local/share/nvim/spec/node_modules/.bin:$PATH"

Here is the output from the ST console:

>>> import os;
>>> os.environ["PATH"]
'/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin'
benfrain commented 11 months ago

Realise this will be better dealt with in Discord

gxanshu commented 2 weeks ago

What you mean with in Discord ?

did you find solution

benfrain commented 2 weeks ago

Here is the Sublime Text Discord channel: https://discord.gg/D43Pecu

no, unfortunately, despite a lot of effort I haven’t found a way to use locally installed LSPs

predragnikolic commented 2 weeks ago

While I would suggest just overriding the start command in LSP-typescript.sublime-settings:

{
    "command": [
        "${node_bin}",
        "path/to/node_modules/typescript-language-server/lib/cli.mjs",
        "--stdio"
    ],
}

I guess that will not work, because LSP-typescript will try to run npm install at some point during the setup of the package, and it will fail if you don't have access to npm.

This option will work for people who have access to npm.

Second option is to configure a Client Configuration manually and not use LSP-typescript https://lsp.sublimetext.io/client_configuration/ In LSP.sublime-settings, you can set:

{
    "clients": {
        "typescript-language-server": {
            "enabled": true,
            "command": [
                "${node_bin}",
                "path/to/node_modules/typescript-language-server/lib/cli.mjs",
                "--stdio"
            ],
            "selector": "source.js, source.jsx, source.ts, source.tsx",
        }   
    },
}

That should work. The bad side is that you will lose some features that LSP-typescript provides.

gxanshu commented 2 weeks ago

@predragnikolic path/to/node_modules/ is related to which folder i'm working on. I'm working on monorepo so server path will change as i started working on some other sub package (folder)

benfrain commented 2 weeks ago

Tangentially related; some LSPs I think make use of Python dependencies so if your environment also has packagecontrol blocked, you might also struggle because of that.