language-tools icon indicating copy to clipboard operation
language-tools copied to clipboard

Auto import doesn't work at first attempt, I need to delete and re-type component name, also doesn't add to `components`

Open vedmant opened this issue 1 year ago • 1 comments

Auto import doesn't work at first attempt, I need to delete and re-type component name. And also doesn't add an object to components:

https://github.com/vuejs/language-tools/assets/5052406/a808f185-0a77-4f77-ab19-eab4381e1f4b

vedmant avatar Jun 05 '24 07:06 vedmant

Please upgrade to the latest version and check if components.d.ts is generated correctly. If the error still happens, please share a minimal reproduction project. Thanks!

kermanx avatar Aug 14 '24 04:08 kermanx

Please upgrade to the latest version and check if components.d.ts is generated correctly. If the error still happens, please share a minimal reproduction project. Thanks!

How can I verify that components.d.ts has been generated correctly?

immortal521 avatar Jun 02 '25 18:06 immortal521

components.d.ts is not generated since I disabled it in Nuxt settings autoImport: false,. I import components implicitly. I just checked again and it imports component, however it's not using aliases and instead imports with relative path. Also for Options API it doesn't add component to components:{}. Which makes this less usable. I switched to WebStorm it can import properly, with aliases and adds to components:{}

vedmant avatar Jun 03 '25 03:06 vedmant

I am guessing this due to getComponentNames is not triggered or delayed on first entry into the workspace.

RayGuo-ergou avatar Jun 03 '25 09:06 RayGuo-ergou

In VS Code, entering a component name automatically triggers auto-import. However, in Neovim, I need to add a space after <, then delete the space, and only after that will auto-import suggestions appear when typing the component name.

immortal521 avatar Jun 03 '25 09:06 immortal521

I do think it's a matter of time, not input event. E.g. if you open a vue file, wait for few second, then it should show.

Probably due to vue lsp has to wait for tsserver to be ready. Astro lsp has the same issue and I would guess it also a tsserver plugin so same thing.

For vscode, it takes like 100 days to load, when you can open a file I think things already loaded which explained why it takes soooooo long.

RayGuo-ergou avatar Jun 03 '25 10:06 RayGuo-ergou

I’ve tried opening the Vue file and waiting for a while, but typing < followed by the component name still doesn’t trigger auto-import suggestions. The suggestions only appear if I insert a space after <, delete the space, and then type the component name.

immortal521 avatar Jun 03 '25 10:06 immortal521

interesting it does work for me as I am also a neovim user, but I use nvim-cmp instead of blink. Maybe that makes the different?

RayGuo-ergou avatar Jun 03 '25 10:06 RayGuo-ergou

interesting it does work for me as I am also a neovim user, but I use nvim-cmp instead of blink. Maybe that makes the different?

After I switched from blink.cmp to nvim-cmp, it started working normally.

immortal521 avatar Jun 03 '25 12:06 immortal521

I asked about this in a blink.cmp issue, and the author responded with this explanation.

nvim-cmp makes a request when typing the trigger character < and then seems to send another request after typing any alphanumeric character (H in your case), so it ends up hiding the issue. But the LSP spec expects the completion plugin to filter on the client side after typing H, rather than making a new request afaict, so this is still an LSP issue.

So at this point, I'm not really sure what's actually causing the problem.

immortal521 avatar Jun 03 '25 15:06 immortal521