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

Helix Edior - nimlangserver exits on startup #59

Closed
AxelRHD opened this issue Nov 9, 2023 · 7 comments · Fixed by #179
Closed

Helix Edior - nimlangserver exits on startup #59

AxelRHD opened this issue Nov 9, 2023 · 7 comments · Fixed by #179
Assignees

Comments

@AxelRHD
Copy link

AxelRHD commented Nov 9, 2023

I've just started programming nim and wanted to use nimlangserver in my helix editor.

Installed it with nimble install nimlangserver and tested it with both the version 1.6.1 and version 2.0.0.

But the language-server always exits on startup of helix with the following error:

2023-11-09T16:16:45.888 helix_lsp::transport [ERROR] nimlangserver err <- "DBG Router: dispatching                        method=initialize id=0\n"
2023-11-09T16:16:45.888 helix_lsp::transport [ERROR] nimlangserver err <- "DBG Initialize received...                    \n"
2023-11-09T16:16:45.888 helix_lsp::transport [ERROR] nimlangserver err <- "DBG Router: sending response                   method=initialize id=0\n"
2023-11-09T16:16:45.889 helix_lsp::transport [ERROR] nimlangserver err <- "DBG Router: dispatching                        method=initialized id=null\n"
2023-11-09T16:16:45.889 helix_lsp::transport [ERROR] nimlangserver err <- "DBG Client initialized.                       \n"
2023-11-09T16:16:45.889 helix_lsp::transport [ERROR] nimlangserver err <- "DBG Requesting configuration from the client  \n"
2023-11-09T16:16:45.889 helix_lsp::transport [ERROR] nimlangserver err <- "DBG Router: dispatching                        method=textDocument/didOpen id=null\n"
2023-11-09T16:16:45.889 helix_lsp::transport [ERROR] nimlangserver err <- "DBG New document opened for URI:               uri=file:///home/axelr/test.nim\n"
2023-11-09T16:16:45.889 helix_lsp::transport [ERROR] nimlangserver err <- "Shutting down due to an error: Invalid scheme: , only \"file\" is supported\n"
2023-11-09T16:16:45.889 helix_lsp::transport [ERROR] nimlangserver err <- "utils.nim(87)            uriToPath\n"
2023-11-09T16:16:45.889 helix_lsp::transport [ERROR] nimlangserver err <- "asyncfutures.nim(389)    read\n"
2023-11-09T16:16:45.889 helix_lsp::transport [ERROR] nimlangserver err <- "asyncfutures.nim(389)    read\n"
2023-11-09T16:16:45.889 helix_lsp::transport [ERROR] nimlangserver err <- "asyncfutures.nim(389)    read\n"
2023-11-09T16:16:45.889 helix_lsp::transport [ERROR] nimlangserver err <- "???                      routeIter\n"
2023-11-09T16:16:45.889 helix_lsp::transport [ERROR] nimlangserver err <- "asyncfutures.nim(389)    read\n"
2023-11-09T16:16:45.889 helix_lsp::transport [ERROR] nimlangserver err <- "asyncfutures.nim(389)    read\n"
2023-11-09T16:16:45.889 helix_lsp::transport [ERROR] nimlangserver err <- "\n"
2023-11-09T16:16:45.889 helix_lsp::transport [ERROR] nimlangserver err: <- StreamClosed

So I think, this is the problem: Shutting down due to an error: Invalid scheme: , only \"file\" is supported
But I don't know, how to solve it.

Can anyone help out? I've made no other changes for the nim lang in the config.toml of helix.

Thanks a lot.

@tomob
Copy link

tomob commented Nov 18, 2023

Here's little insight into the problem.

Helix sends the following JSON with the initialize method:

2023-11-18T01:17:41.970 helix_lsp::transport [INFO] nimlangserver -> {"jsonrpc":"2.0","method":"initialize","params":{"capabilities":{"general":{"positionEncodings":["ut
f-8","utf-32","utf-16"]},"textDocument":{"codeAction":{"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.in
line","refactor.rewrite","source","source.organizeImports"]}},"dataSupport":true,"disabledSupport":true,"isPreferredSupport":true,"resolveSupport":{"properties":["edit",
"command"]}},"completion":{"completionItem":{"deprecatedSupport":true,"insertReplaceSupport":true,"resolveSupport":{"properties":["documentation","detail","additionalTex
tEdits"]},"snippetSupport":true,"tagSupport":{"valueSet":[1]}},"completionItemKind":{}},"hover":{"contentFormat":["markdown"]},"inlayHint":{"dynamicRegistration":false},
"publishDiagnostics":{"versionSupport":true},"rename":{"dynamicRegistration":false,"honorsChangeAnnotations":false,"prepareSupport":true},"signatureHelp":{"signatureInfo
rmation":{"activeParameterSupport":true,"documentationFormat":["markdown"],"parameterInformation":{"labelOffsetSupport":true}}}},"window":{"workDoneProgress":true},"work
space":{"applyEdit":true,"configuration":true,"didChangeConfiguration":{"dynamicRegistration":false},"didChangeWatchedFiles":{"dynamicRegistration":true,"relativePattern
Support":false},"executeCommand":{"dynamicRegistration":false},"inlayHint":{"refreshSupport":false},"symbol":{"dynamicRegistration":false},"workspaceEdit":{"documentChan
ges":true,"failureHandling":"abort","normalizesLineEndings":false,"resourceOperations":["create","rename","delete"]},"workspaceFolders":true}},"clientInfo":{"name":"heli
x","version":"23.10 (f6021dd0)"},"processId":1980741,"rootPath":"/some/path","rootUri":null,"workspaceFolders":[]},"id":0}

The rootUri property is null, the rootPath contains the path to the directory containing the project file(s), which is valid according to the spec. However, the lang server does not account for the null value there:

rootPath = AbsoluteDir(ls.initializeParams.rootUri.uriToPath)
.

Hope that helps.

@yyoncho
Copy link
Collaborator

yyoncho commented Nov 19, 2023

Although it is optional in the spec from the language server perspective we need a project root in order to determine where to start the compiler from. I will leave the issue open to work out a better error message.

@omentic
Copy link

omentic commented Nov 19, 2023

Can the project root default to the working directory?

@yyoncho
Copy link
Collaborator

yyoncho commented Nov 19, 2023

Can the project root default to the working directory?

Technically we can, the issue is that this might introduce non-deterministic behavior based on whether the user has first opened foo/a.nim or bar/b.nim in the same project.

@tomob
Copy link

tomob commented Nov 20, 2023

Although it is optional in the spec from the language server perspective we need a project root in order to determine where to start the compiler from. I will leave the issue open to work out a better error message.

The path is sent in the rootPath property.

@AxelRHD
Copy link
Author

AxelRHD commented Nov 23, 2023

Here's little insight into the problem.

Helix sends the following JSON with the initialize method:

2023-11-18T01:17:41.970 helix_lsp::transport [INFO] nimlangserver -> {"jsonrpc":"2.0","method":"initialize","params":{"capabilities":{"general":{"positionEncodings":["ut
f-8","utf-32","utf-16"]},"textDocument":{"codeAction":{"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.in
line","refactor.rewrite","source","source.organizeImports"]}},"dataSupport":true,"disabledSupport":true,"isPreferredSupport":true,"resolveSupport":{"properties":["edit",
"command"]}},"completion":{"completionItem":{"deprecatedSupport":true,"insertReplaceSupport":true,"resolveSupport":{"properties":["documentation","detail","additionalTex
tEdits"]},"snippetSupport":true,"tagSupport":{"valueSet":[1]}},"completionItemKind":{}},"hover":{"contentFormat":["markdown"]},"inlayHint":{"dynamicRegistration":false},
"publishDiagnostics":{"versionSupport":true},"rename":{"dynamicRegistration":false,"honorsChangeAnnotations":false,"prepareSupport":true},"signatureHelp":{"signatureInfo
rmation":{"activeParameterSupport":true,"documentationFormat":["markdown"],"parameterInformation":{"labelOffsetSupport":true}}}},"window":{"workDoneProgress":true},"work
space":{"applyEdit":true,"configuration":true,"didChangeConfiguration":{"dynamicRegistration":false},"didChangeWatchedFiles":{"dynamicRegistration":true,"relativePattern
Support":false},"executeCommand":{"dynamicRegistration":false},"inlayHint":{"refreshSupport":false},"symbol":{"dynamicRegistration":false},"workspaceEdit":{"documentChan
ges":true,"failureHandling":"abort","normalizesLineEndings":false,"resourceOperations":["create","rename","delete"]},"workspaceFolders":true}},"clientInfo":{"name":"heli
x","version":"23.10 (f6021dd0)"},"processId":1980741,"rootPath":"/some/path","rootUri":null,"workspaceFolders":[]},"id":0}

The rootUri property is null, the rootPath contains the path to the directory containing the project file(s), which is valid according to the spec. However, the lang server does not account for the null value there:

rootPath = AbsoluteDir(ls.initializeParams.rootUri.uriToPath)

.
Hope that helps.

Not 100% where do I have to add the missing information?

@jming422
Copy link

Although it is optional in the spec from the language server perspective we need a project root in order to determine where to start the compiler from. I will leave the issue open to work out a better error message.

The path is sent in the rootPath property.

This sounds to me like a solution may be to fallback to the rootPath property of ls.initializeParams when rootUri is null?

I ran into this issue while setting up my environment to start learning Nim, so I've never written Nim before, otherwise I'd open a PR myself. Once I've at least done some tutorials I will return to attempt the change if it's welcome and if it hasn't been made already by then

@nickysn nickysn self-assigned this Feb 6, 2024
nickysn added a commit to nickysn/langserver that referenced this issue Feb 6, 2024
… of using

  the current directory. This should improve performance with editors that only
  send rootPath, but no rootUri, such as Helix. Fixes nim-lang#59.
nickysn added a commit to nickysn/langserver that referenced this issue Feb 6, 2024
… of using

  the current directory. This should improve performance with editors that only
  send rootPath, but no rootUri, such as Helix. Fixes nim-lang#59.
nickysn added a commit that referenced this issue Feb 6, 2024
… of using (#179)

the current directory. This should improve performance with editors that only
  send rootPath, but no rootUri, such as Helix. Fixes #59.
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

Successfully merging a pull request may close this issue.

6 participants