typescript-strict-plugin icon indicating copy to clipboard operation
typescript-strict-plugin copied to clipboard

How to use with an LSP host other than vscode?

Open beaugunderson opened this issue 1 year ago • 5 comments

Hi there, I'm using neovim with the typescript-language-server language server. How can I see my strict violations using this language server?

I use mason to manage my LSP configs, so the version installed gets installed by mason as:

/Users/beau/.local/share/nvim/mason/packages/typescript-language-server/node_modules/typescript/lib/tsserver.js

Anyone had luck getting this working in vim?

beaugunderson avatar May 18 '23 23:05 beaugunderson

Hey I'm using nvim with typescript-language-server and mason and it works for me. If you've followed every step from readme it should work out of the box.

KostkaBrukowa avatar May 19 '23 07:05 KostkaBrukowa

the only thing I've done differently is added a non-existent path as the paths array and used the @ts-strict comment instead so that my project is opt-in instead of opt-out... it works for tsc-strict but I get nothing in vim sadly

beaugunderson avatar May 19 '23 08:05 beaugunderson

Could you share you vim config?

KostkaBrukowa avatar May 21 '23 09:05 KostkaBrukowa

@KostkaBrukowa sure! here you go: https://gist.github.com/beaugunderson/7acffd22a8df616cba263655aaa6b6fe

and alternately, since yours is working, if you share yours I can see how it differs from my own :)

61091

12774

beaugunderson avatar May 21 '23 15:05 beaugunderson

Just fyi, I ran across this issue and took many hours of debugging but I realized it was due to a pathing issue for me.

Basically I had a few tsconfig.json scattered throughout my proj directory, that extends the main one in root. But because the root directory for mason tsserver resolves to the nearest tsconfig... it ended up with the wrong root dir which mean't all the relative paths included in the plugin technically were incorrect.

i.e.

// main tsconfig.json in root
{
  "compilerOptions": {
    "plugins": [
      {
        "name": "typescript-strict-plugin",
        "paths": [
          "foo/bar/baz",
        ]
     }
   ]
 }
// tsconfig.json in foo/bar
{
  extends: "../../tsconfig.json"
}

Above setup causes:

tsserver root dir = root/foo/bar and now the plugin path instead of being ./foo/bar/baz which I expected, ended up being root/foo/bar/foo/bar/baz which does not exist.

Thus the following worked for me:

  • Removing the other tsconfig's
  • Adding absolute paths for the plugin
  • Adding ./ path for the plugin

YMMV however

kaiwah avatar Dec 14 '23 04:12 kaiwah