jose-elias-alvarez / nvim-lsp-ts-utils

Utilities to improve the TypeScript development experience for Neovim's built-in LSP client.
The Unlicense
438 stars 18 forks source link

fix(import all): match additional patterns #115

Closed jose-elias-alvarez closed 2 years ago

jose-elias-alvarez commented 2 years ago

Closes #112.

For whatever reason, it looks like tsserver code actions can conform to various patterns. We handle this pattern correctly:

Import 'useEffect' from module "React"

But these patterns are ignored, since they don't specify a target:

Add import from "next/app"
Update import from "next/app"

This PR handles patterns 2 and 3 and generally cleans up pattern handling a bit.

jose-elias-alvarez commented 2 years ago

Separately, I have no idea why these actions have different titles and why I didn't see this before. The commit history for typescript-language-server doesn't have any clues. The TypeScript repo is too gigantic to go through it, but I wonder when and why this started happening.

sinnrrr commented 2 years ago

now it works as expected there is only one UB left

image

when I do :TSLspImoprtAll or :TSLspImportCurrent it uses second option, while obviously first option matches better and it is first (other imports work okay, but this one is strange)

jose-elias-alvarez commented 2 years ago

I don't know about the project your screenshot is from, but on your sample repo from the issue, the function adds an import from "next/app". Improving selection behavior is a separate issue, so since this solves the issue of imports not working at all, I'll go ahead and merge it.

sinnrrr commented 2 years ago

@jose-elias-alvarez thanks a lot!