8000 How to control tsserver process launch or tell it to use a specific node path? · Issue #259 · pmizio/typescript-tools.nvim · GitHub
[go: up one dir, main page]

Skip to content
How to control tsserver process launch or tell it to use a specific node path? #259
Open
@unphased

Description

@unphased

Background:

I'm trying to set up typescript scripts as dependency-free scripts for macos and linux so I can move forward from shell scripts. Still love shell scripts, but sometimes it would be great to get javascript capabilities in the course of general scripting.

To facilitate this I use a shebang to a shell wrapper that will launch the program under tsx, the shebang wrapper script is as follows in case anyone is curious:

#!/usr/bin/env bash
echo Hello from tsx launcher in cwd "$(pwd)"
NODE_PATH=/opt/ts-global/node_modules:NODE_PATH exec npx tsx "$@"

As you can see, this defines a global store for npm dependencies. It all works, really well I might add.

The wrinkle now is with editing. Editing a plain typescript file in the absence of any of the usual typescript project files leads to tsserver throwing tons of errors for obvious reasons.

So, the natural approach is to put a basic tsconfig.json into the home directory. This seems to get picked up. However, it fails spectacularly (I tested with regular tsserver setup and with typescript-tools). It will recursively search my 600GB home dir and crash after a few minutes by running out of memory!

What I need to do for neovim, then, is since I'm already centralizing the "global" one off script dependency dir to /opt/ts-global/, I need to also configure NODE_PATH for the tsserver node process launched via Mason to point here, and possibly some other flags to convince it to look for tsconfig in this dir rather than try to pick it up where it usually looks.

I need to find a way to do this for typescript-tools.nvim because I rely on this implementation to obtain the move-to-file code action.

I looked at the readme and it shows how we can configure tsserver UserPreferences and FormatCodeSettings but presumably I want a way to manipulate CompilerOptions.

I think i will try to see if i can use paths or something in a ~/tsconfig.json though to have it point at this dir. that may work...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0