Closed CppCXY closed 2 weeks ago
Have you this error only with nightly build or with 0.0.1 release too?
Could you share your pr please?
From the picture it looks like I'm using 0.0.1, but I manually updated to 0.0.2.
but since this is 0.0.1, it will revert to 0.0.1 every time my debug.
How can I set 0.0.2?
here is the project
It should work with 0.0.1 too.
Let me try your project.
lsp4ij send rootPath endwith '/':
jetbrain lsp send rootPath without '/'
this(end with '/') cause sumneko lua can not work.
I cannot understand it seems your language server can be started now? Have you fixed your original error?
I cannot understand it seems your language server can be started now? Have you fixed your original error?
I didn't do any fixing, I just skipped the exception, because the exception doesn't affect my normal startup.
Can you provide a full stacktrace of the error (without skipping the exception)? Are you sure that the ending slash is causing it?
I'm sorry, I may not have made my questions clear. Actually, there are two issues. The first one is that a pop-up appears every time I debug. The second one is that after skipping the exception, the language server functionality in the opened IDEA instance is not quite normal. This might be due to a problem with the format of the workspace path. We have integrated the JetBrains LSP before, and this issue did not occur.
I can't provide the stack trace because it doesn't appear in the IDEA's log. I can only provide it in the form of a screenshot:
So I tried your plugin. First, I had to change the lsp4ij version to "com.redhat.devtools.lsp4ij:0.0.2-20240612-023956@nightly", because you're debugging with ideaSDKVersion = "LATEST-EAP-SNAPSHOT",
i.e. EAP 2024.2, which is not compatible with lsp4ij 0.0.1. Once that's done, the plugin starts with an error:
Internal error: java.lang.reflect.InvocationTargetException
java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$recursiveFindRpcMethods$0(GenericEndpoint.java:67)
at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.request(GenericEndpoint.java:120)
at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleRequest(RemoteEndpoint.java:261)
at org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:190)
at com.redhat.devtools.lsp4ij.LanguageServerWrapper.lambda$start$1(LanguageServerWrapper.java:261)
at java.base/java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804)
at java.base/java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1796)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:507)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1491)
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:2073)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:2035)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:187)
Caused by: java.lang.reflect.InvocationTargetException
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:118)
at java.base/java.lang.reflect.Method.invoke(Method.java:580)
at org.eclipse.lsp4j.jsonrpc.services.GenericEndpoint.lambda$recursiveFindRpcMethods$0(GenericEndpoint.java:65)
... 11 more
Caused by: java.lang.UnsupportedOperationException
at org.eclipse.lsp4j.services.LanguageClient.configuration(LanguageClient.java:138)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
... 13 more
this is caused by the LUA language server requesting workspace/configuration
, but LSP4IJ didn't advertise it supported it :
[Trace - 12:05:24] Received request 'workspace/configuration - (1)'
Params: {
"items": [
{
"scopeUri": "file:///Users/fbricon/Dev/souk/lua/",
"section": "Lua"
},
{
"scopeUri": "file:///Users/fbricon/Dev/souk/lua/",
"section": "files.associations"
},
{
"scopeUri": "file:///Users/fbricon/Dev/souk/lua/",
"section": "files.exclude"
},
{
"scopeUri": "file:///Users/fbricon/Dev/souk/lua/",
"section": "editor.semanticHighlighting.enabled"
},
{
"scopeUri": "file:///Users/fbricon/Dev/souk/lua/",
"section": "editor.acceptSuggestionOnEnter"
}
]
}
There's an open bug about the LUA server ignoring the Client capability configuration
Thanks, I'll ask the author to take care of this as soon as possible. but due to the ending slash, it can not work normal, and I find out that rootPath also has the leading slash:
rootPath = "/C:/Users/zc/Desktop/learn/",
rootUri = "file:///C:/Users/zc/Desktop/learn/",
trace = "off",
workspaceFolders = { {
name = "learn",
uri = "file:///C:/Users/zc/Desktop/learn/"
} }
@CppCXY I have created a PR to support configuration https://github.com/redhat-developer/lsp4ij/pull/346
I got the lua server working fine with #346 on Mac, the slashes may not be an issue. Please try to manually install the LSP4IJ-0.0.2-SNAPSHOT file from https://github.com/redhat-developer/lsp4ij/actions/runs/9480917967.
@CppCXY I found a real problem with lua on IntelliJ though, but it's unrelated to LSP4IJ or the Lua LSP itself, it's probably coming from your own lua parser: any file containing things like ---@diagnostic disable: lowercase-global
will cause Intellij to report an error:
I got the lua server working fine with #346 on Mac, the slashes may not be an issue. Please try to manually install the LSP4IJ-0.0.2-SNAPSHOT file from https://github.com/redhat-developer/lsp4ij/actions/runs/9480917967.
Thanks, I tried, but it still doesn't work, I know very well that it doesn't really read the data in the workspace, it reinterprets learn/ as learn/learn, see the log:
[20:00:52.152][warn] [#0:script\files.lua:111]: Fix real file uri: file:///c%3A/Users/zc/Desktop/learn/ -> file:///c%3A/Users/zc/Desktop/learn/learn
[20:00:52.152][info] [#0:script\workspace\workspace.lua:48]: Workspace create: file:///c%3A/Users/zc/Desktop/learn/learn
I know it's true that luals itself has processing problems, but it still works fine on other platforms like neovim.
Then it might be a windows specific issue, as I said, everything's fine on Mac. We need to check on windows
@CppCXY I found a real problem with lua on IntelliJ though, but it's unrelated to LSP4IJ or the Lua LSP itself, it's probably coming from your own lua parser: any file containing things like
---@diagnostic disable: lowercase-global
will cause Intellij to report an error:![]()
I'm aware of this problem, because its intellij frontend comes from emmylua, and intellij-emmylua doesn't yet support the doc syntax for luals, but neither jetbrain lsp nor lsp4ij support semantic highlighting, and I can't get intellij to read vscode syntax definitions. I may optimize the parser later, but it will take a lot of time.
I didn't install emmylua
I mean my intellij-sumnekolua its analyzing front-end is come from emmylua
I always get a startup error:
I created a PR for that https://github.com/redhat-developer/lsp4ij/pull/347
Thanks, I tried, but it still doesn't work, I know very well that it doesn't really read the data in the workspace, it reinterprets learn/ as learn/learn, see the log:
I'm studying the problem.
I tested the latest build from our main branch (https://github.com/redhat-developer/lsp4ij/actions/runs/9484891140) on a Windows 11 VM. The plugin starts, I don't see any issues with a trailing slash in the rootPath
I tested the latest build from our main branch (https://github.com/redhat-developer/lsp4ij/actions/runs/9484891140) on a Windows 11 VM. The plugin starts, I don't see any issues with a trailing slash in the rootPath
![]()
It actually doesn't get anything from the workspace, you can't get hints from other files and it can't read the .luarc.json file in the workspace. for example, if you choose to quick fix and disable a diagnostic in the workspace, it will completely fail.
@CppCXY I have tried your plugin on Windows OS and it seems working, I have completion, higlight, quick fixes etc.
The quickfix which doesn't work is the following:
When I apply it, I have the error message:
which comes from LSP trace:
[Trace - 09:08:32] Received notification 'window/showMessage'
Params: {
"type": 2,
"message": "Failed to modify settings\n\nPlease modify following settings manually:\n* `Lua.diagnostics.disable`: add element `\"undefined-global\"` ;\n"
}
When you say "fail", is it this problem?
Have you completion, higlight which is working?
@CppCXY I suggest that you use LSP console to track LSP messages https://github.com/redhat-developer/lsp4ij/blob/main/docs/UserGuide.md#lsp-console
Have you completion, higlight which is working?
highlighting is not a feature of the language server, it's handled by the PSI system of JetBrains that I'm using. as for completion, it doesn't provide completions from other files in the current workspace.
@CppCXY I suggest that you use LSP console to track LSP messages https://github.com/redhat-developer/lsp4ij/blob/main/docs/UserGuide.md#lsp-console
LuaLs has owner log file, see:
I can see the log about workspace:
[15:16:37.834][info] [#0:script\workspace\workspace.lua:38]: Workspace init root: file:///C:/Users/zc/Desktop/learn/
[15:16:37.834][info] [#0:script\workspace\workspace.lua:42]: Log path: C:/Users/zc/AppData/Roaming/JetBrains/IntelliJIdea2024.1/plugins/Sumneko-Lua/server/win32-x64/log/file_C_Users_zc_Desktop_learn_.log
[15:16:37.868][warn] [#0:script\files.lua:111]: Fix real file uri: file:///c%3A/Users/zc/Desktop/learn/ -> file:///c%3A/Users/zc/Desktop/learn/learn
[15:16:37.868][info] [#0:script\workspace\workspace.lua:48]: Workspace create: file:///c%3A/Users/zc/Desktop/learn/learn
due to the bug in luals, it incorrectly locates xx/learn/ to xx/learn/learn, so its analysis of the workspace actually failed, but I noticed that the rootPath sent by both the Jetbrains LSP client and the VSCode LSP client does not contain an ending slash.
[Trace - 09:08:32] Received notification 'window/showMessage' Params: { "type": 2, "message": "Failed to modify settings\n\nPlease modify following settings manually:\n*
Lua.diagnostics.disable
: add element\"undefined-global\"
;\n" }
the reason for this error is that LuaLS has analyzed a non-existent directory and it cannot create a configuration file there.
so, do we need to handle the ending slash?
Do you have a sample project we can test?
simpleTest.zip here the test project, when I install my plugin and open this project for the first time, I can't get completions here.
x.
highlighting is not a feature of the language server, it's handled by the PSI system of JetBrains that I'm using.
I mean document/documentHighlight
that you support:
[Trace - 10:04:31 AM] Sending request 'textDocument/documentHighlight - (53)'.
Params: {
"textDocument": {
"uri": "file:///c%3A/Users/azerr/IdeaProjects/pyright-langserver-for-pycharm-test/src/test.lua"
},
"position": {
"line": 1,
"character": 7
}
}
You can see that in the Trace
tab of LSP console by setting it to verbose. I suggest really that you work with those LSP traces to understand more the behavior of your LS.
I have installed your vscode-lua, and you can enable those LSP trace by adding in the settings.json
"Lua.trace.server": "verbose"
I suggest that you promote this settings (to have completion for this settings and in order to vscode recognize this settings) in yourpackage.json like we did for vscode-xml
the reason for this error is that LuaLS has analyzed a non-existent directory and it cannot create a configuration file there. so, do we need to handle the ending slash?
IMHO I think Lua LS should take care of that, but I created the following PR https://github.com/redhat-developer/lsp4ij/pull/348 which fixes the problem and the Quickfix (workspace) works now perfectly on Windows OS and generate the .lua.json file.
I fixed rootUri and rootPath but the fix was not enough. I had to do the same fix on WorkspaceFolder uri and now it is working pretty well with my Windows OS!
the reason for this error is that LuaLS has analyzed a non-existent directory and it cannot create a configuration file there. so, do we need to handle the ending slash?
IMHO I think Lua LS should take care of that, but I created the following PR #348 which fixes the problem and the Quickfix (workspace) works now perfectly on Windows OS and generate the .lua.json file.
I fixed rootUri and rootPath but the fix was not enough. I had to do the same fix on WorkspaceFolder uri and now it is working pretty well with my Windows OS!
Thanks!
here the test project, when I install my plugin and open this project for the first time, I can't get completions here.
It is working for me on my Windows OS:
Coud you enable LSP console as verbose and share your LSP traces please.
In my case I see:
here the test project, when I install my plugin and open this project for the first time, I can't get completions here.
It is working for me on my Windows OS:
Coud you enable LSP console as verbose and share your LSP traces please.
In my case I see:
it's a windows only problem. this problem should no longer exist after you fix it
it's a windows only problem. this problem should no longer exist after you fix it
You mean that my fix which removes '/' fixes your issue with completion? If it that I have tested without my PR and it is working too.
@CppCXY please try https://plugins.jetbrains.com/plugin/23257-lsp4ij/versions/nightly/555671?noRedirect=true it should work much better on windows
@CppCXY please try https://plugins.jetbrains.com/plugin/23257-lsp4ij/versions/nightly/555671?noRedirect=true it should work much better on windows
thanks, it work well.
I have another question. Currently, I can't find references by using Ctrl + left mouse click. JetBrains LSP will support using "Find Usage" for references in 2024.2 EAP 5. But I found that this plugin is implemented in goto/LSP references.
I have another question. Currently, I can't find references by using Ctrl + left mouse click. JetBrains LSP will support using "Find Usage" for references in 2024.2 EAP 5. But I found that this plugin is implemented in goto/LSP references.
See doc at https://github.com/redhat-developer/lsp4ij/blob/main/docs/LSPSupport.md#references
I have another question. Currently, I can't find references by using Ctrl + left mouse click. JetBrains LSP will support using "Find Usage" for references in 2024.2 EAP 5. But I found that this plugin is implemented in goto/LSP references.
See doc at https://github.com/redhat-developer/lsp4ij/blob/main/docs/LSPSupport.md#references
I can't see Find Usage
does the language server need to support all these features?
does the language server need to support all these features?
not all, just one
But as you are using custom FileType, I think it will not work.
does the language server need to support all these features?
not all, just one
But as you are using custom FileType, I think it will not work.
I have indeed implemented at least one of them here, and also defined the fileType, so I can't see Find Usage.
I have indeed implemented at least one of them here, and also defined the fileType, so I can't see Find Usage.
Let me try finding a solution...
@CppCXY please open a new ticket about find references, now that your plugin starts working with LSP4IJ
I always get a startup error:
cause by:
this my plugins.xml