Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad completion in string #832

Open
CppCXY opened this issue Feb 11, 2025 · 24 comments
Open

Bad completion in string #832

CppCXY opened this issue Feb 11, 2025 · 24 comments

Comments

@CppCXY
Copy link
Contributor

CppCXY commented Feb 11, 2025

Image

see the gif

@angelozerr
Copy link
Contributor

Could you share your LSP trace please.

Have you this problem with old version of LSP4IJ?

@CppCXY
Copy link
Contributor Author

CppCXY commented Feb 11, 2025

[Trace - 22:30:04] Received response 'textDocument/completion - (659)' in 0ms.
Result: [
  {
    "label": "collect",
    "kind": 20
  },
  {
    "label": "stop",
    "kind": 20
  },
  {
    "label": "restart",
    "kind": 20
  },
  {
    "label": "count",
    "kind": 20
  },
  {
    "label": "step",
    "kind": 20
  },
  {
    "label": "setpause",
    "kind": 20
  },
  {
    "label": "incremental",
    "kind": 20
  },
  {
    "label": "generational",
    "kind": 20
  },
  {
    "label": "isrunning",
    "kind": 20
  }
]

@angelozerr
Copy link
Contributor

I don't see any double quotes " in your completion response? How vscode knows that it must add double quotes?

@CppCXY
Copy link
Contributor Author

CppCXY commented Feb 11, 2025

I don't see any double quotes " in your completion response? How vscode knows that it must add double quotes?

Based on the current cursor context, I will return different completion items. If the cursor is not within a string, I will return completion items with double quotes. If the completion was triggered by typing double quotes, I will return versions without quotes.

@CppCXY
Copy link
Contributor Author

CppCXY commented Feb 11, 2025

Image
it work well in previous version:

Image

@CppCXY
Copy link
Contributor Author

CppCXY commented Feb 11, 2025

And I found that it works very well when I removed the plugin and manually configured the language server through LSP4IJ's configuration.

Image

Image

@angelozerr
Copy link
Contributor

Is it a problem with custom PsiFile?

I suggest that you compare the 2 LSP traces completion response (the one which is working and the other)

@CppCXY
Copy link
Contributor Author

CppCXY commented Feb 11, 2025

When both the plugin and the language server configured with lsp4ij are enabled, regardless of which completion item is selected, the result is incorrect. I suspect it’s a CustomPSI issue.

Image

@angelozerr
Copy link
Contributor

@CppCXY the problem comes from your PsiFile, right?

@CppCXY
Copy link
Contributor Author

CppCXY commented Feb 19, 2025

@CppCXY the problem comes from your PsiFile, right?

my PSI doesn't provide any functionality for autocompletion. I believe it's solely because I defined PSI that this error occurred.

@CppCXY
Copy link
Contributor Author

CppCXY commented Feb 19, 2025

To be honest, I don't really want to define PSI, but currently comments, bracket matching, and so on cannot be defined through language server.

@angelozerr
Copy link
Contributor

What about using language-configuration.json supported by IntelliJ himself?

@CppCXY
Copy link
Contributor Author

CppCXY commented Feb 19, 2025

What about using language-configuration.json supported by IntelliJ himself?

Is there any documentation about it?

@angelozerr
Copy link
Contributor

I don't think so.

You can try it quickly, you will need just to register textmate by selecting the folder which contains package.json from https://github.com/EmmyLua/VSCode-EmmyLua

It should register textmate and language-configuration.json. To do that with code, I don't know, you should ask to JetBrains.

@angelozerr
Copy link
Contributor

@CppCXY that's strange, it seems IntelliJ provides a lua support with language-configuration.json out of the box https://github.com/JetBrains/intellij-community/blob/0627fa7b16a28b49f23122226d73e46f2c859ed0/plugins/textmate/lib/bundles/lua/language-configuration.json#L4

@CppCXY
Copy link
Contributor Author

CppCXY commented Feb 19, 2025

@CppCXY that's strange, it seems IntelliJ provides a lua support with language-configuration.json out of the box https://github.com/JetBrains/intellij-community/blob/0627fa7b16a28b49f23122226d73e46f2c859ed0/plugins/textmate/lib/bundles/lua/language-configuration.json#L4

The definitions it provides are insufficient. We are Emmylua—a set of annotation convention plugins on top of Lua. Many parts of the Neovim community use luacats/Emmylua doc definitions.

@CppCXY
Copy link
Contributor Author

CppCXY commented Feb 19, 2025

I observed an interesting phenomenon. I think this is an issue that needs addressing because I treated Java as a Lua file directly, and the same bug occurred.

@CppCXY
Copy link
Contributor Author

CppCXY commented Feb 19, 2025

Image

@angelozerr
Copy link
Contributor

If you think there is a bug from LSP4IJ, please compare LSP tarces from Intellij and vscode.

According your trace #832 (comment), the apply completion doesn't contains quote to insert.

@CppCXY
Copy link
Contributor Author

CppCXY commented Feb 19, 2025

this is log in vscode:

[2025-02-19 16:19:46 +08:00 DEBUG lsp_server::msg] > {"jsonrpc":"2.0","id":146,"result":[{"kind":20,"label":"collect"},{"kind":20,"label":"stop"},{"kind":20,"label":"restart"},{"kind":20,"label":"count"},{"kind":20,"label":"step"},{"kind":20,"label":"setpause"},{"kind":20,"label":"incremental"},{"kind":20,"label":"generational"},{"kind":20,"label":"isrunning"}]}

they are same

@CppCXY
Copy link
Contributor Author

CppCXY commented Feb 19, 2025

this is log in vscode:

[2025-02-19 16:19:46 +08:00 DEBUG lsp_server::msg] > {"jsonrpc":"2.0","id":146,"result":[{"kind":20,"label":"collect"},{"kind":20,"label":"stop"},{"kind":20,"label":"restart"},{"kind":20,"label":"count"},{"kind":20,"label":"step"},{"kind":20,"label":"setpause"},{"kind":20,"label":"incremental"},{"kind":20,"label":"generational"},{"kind":20,"label":"isrunning"}]}

they are same

However, I'm not sure how to view the contents received by VS Code. What I have here are the logs recorded by my language server.

@angelozerr
Copy link
Contributor

To activate LSP traces in vscode, add in your settings JSON

"XXXX.trace.server": "verbose"

where XXXX is your language server id.

@CppCXY
Copy link
Contributor Author

CppCXY commented Feb 19, 2025

To activate LSP traces in vscode, add in your settings JSON

"XXXX.trace.server": "verbose"

where XXXX is your language server id.

I found out that this is not a universal method; my language server itself does not support this approach. However, I already showed the messages sent to VSCode, and they are the same as Intellij's.

@angelozerr
Copy link
Contributor

I have tested with your language server without custom PsiFile and it works great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants