Closed singlexyz closed 2 years ago
Your example does work for me, both on a production project and on a blank skeleton project. There's too many potential variables (versions, project configurations / structures) for me to figure out exactly what's going on. I can see that your tsserver
code actions are slightly different from the ones I get:
This leads me to believe that something about your local environment is causing this not to work. If you can put together a repository containing the code I need to replicate this, including the necessary versions of all the dependencies (React and TypeScript), I'm happy to look into this more.
+1, having the same issue and configuration as the author, :TSLspImportAll
and :TSLspImportCurrent
doesn't work even if the cursor is on the unimported part of the code (getting "No code actions available" message)
however :TSLspOrganize
and :TSLspRenameFile
seem to work fine
screenshots
observing code actions
running :TSLspImportCurrent
Your example does work for me, both on a production project and on a blank skeleton project. There's too many potential variables (versions, project configurations / structures) for me to figure out exactly what's going on. I can see that your
tsserver
code actions are slightly different from the ones I get:This leads me to believe that something about your local environment is causing this not to work. If you can put together a repository containing the code I need to replicate this, including the necessary versions of all the dependencies (React and TypeScript), I'm happy to look into this more.
This leads me to believe that something about your local environment is causing this not to work. If you can put together a repository containing the code I need to replicate this, including the necessary versions of all the dependencies (React and TypeScript), I'm happy to look into this more.
Yeah, global package
typescript-language-server@0.9.7
typescript@4.6.2
and the project create from vite:
yarn create vite@latest my-app
framework and variant options select react
both.
and create-react-app
also the same.
npx create-react-app my-app
Same jsconfig.json
{
"compilerOptions": {
"checkJs": true,
"jsx": "preserve"
}
}
I see, I didn't realize you were using JavaScript. I can replicate this on a new CRA project that's not initialized with TypeScript. I briefly looked into this and the issue seems to be that the title of the actions doesn't match the TypeScript equivalent, so :TSLspImportAll
ignores it.
JavaScript support in this plugin is, at best, accidental, since I don't personally use JavaScript and there's a ton of edge cases like this. If it's possible to add support without increasing complexity, I'm happy to review a PR, but I don't plan on fixing this myself. I'll also add a note to the README to specify that only TypeScript is officially supported.
Edit: For anyone who wants to work on this, this line is where the pattern fails to match. I briefly tried updating the pattern to make it pass, but the function still didn't work, so there's some more detective work to be done here.
@jose-elias-alvarez I have fully typescript project bootstrapped with npx create-next-app
here, _app.tsx
file - AppProps
can't be imported neither using :TSLspImportAll
nor :TSLspImportCurrent
, although we have import code action available
can you confirm this?
@jose-elias-alvarez I have fully typescript project bootstrapped with
npx create-next-app
here,_app.tsx
file -AppProps
can't be imported neither using:TSLspImportAll
nor:TSLspImportCurrent
, although we have import code action availablecan you confirm this?
Excellent, this repo is exactly what I needed to figure this out. Can you try #115?
FAQ
Issues
Neovim Version
NVIM v0.6.1
Steps to reproduce
Cursor on
useRef
, then execute:TSLspImportAll
or:TSLspImportCurrent
, nothing happen. Buy actually I had those actionsif execute them, it works.
Expected behavior
Auto Import.
Actual behavior
nothing happens.
Debug log
jsconfig:
I made a recording:
https://user-images.githubusercontent.com/4456413/158076857-ead3e4fb-7d46-4e87-977c-7972aea9956a.mov
And here's my lsp config:
Help
No
Implementation help
No response