Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Use Helix in conjunction with MATLAB Language Server #8947

Closed
SubtleMuffin opened this issue Nov 29, 2023 · 2 comments
Closed

Use Helix in conjunction with MATLAB Language Server #8947

SubtleMuffin opened this issue Nov 29, 2023 · 2 comments

Comments

@SubtleMuffin
Copy link

Quick background

MathWorks published their own MATLAB language server, and it is now working with neovim (via nvim-lspconfig and mason. In the discussions under issue 4, people can compile the language server and interact with it through neovim. I tried to do the same thing with Helix, but failed. Here are my steps so far:

  1. Clone the MATLAB language server via
git clone https://github.com/mathworks/MATLAB-language-server ~/.local/share/MATLAB-language-server
  1. Compile the package via
cd ~/.local/share/MATLAB-language-server && npm install . && npm run package
  1. Verify that it is working via
node out/index.js --stdio
  1. Make a short script matlab_ls as follows, mark it executable via chmod, and store it somewhere on the $PATH. Below, I am using mason installed version, but it should be the same.
#!/usr/bin/env bash
exec node "/home/$USER/.local/share/nvim/mason/packages/matlab-language-server/out/index.js" "$@"
  1. Add the following to the Helix language settings, i.e., <config_dir>/helix/languages.toml
[[language]]
name = "matlab"
scope = "source.m"
file-types = ["m"]
comment-token = "%"
shebangs = ["matlab"]
indent = { tab-width = 2, unit = "  " }
language-servers = ["matlab_ls"]

[language-server.matlab_ls]
command = "matlab_ls"
args = ["--stdio"]
config = { provideFormatter = true }
environment = { "installPath" = "/usr/share/matlab", "indexWorkspace" = "true", "matlabConnectionTiming" = "onStart", "telemetry" = "false" }
  1. Open a .m file under a git-managed folder with helix -v test.m, and see if the language server is responding.

Here are the relevant log files:

  1. ~/.cache/helix/helix.log
2023-11-29T18:39:42.207 helix_vcs [INFO] file is untracked
2023-11-29T18:39:42.207 helix_vcs [INFO] failed to open diff base for /home/$USER/Documents/folder/test.m
2023-11-29T18:39:42.207 helix_lsp::client [INFO] Using custom LSP config: {"provideFormatter":true}
2023-11-29T18:39:42.207 helix_lsp::transport [INFO] matlab_ls -> {"jsonrpc":"2.0","method":"initialize","params":{"capabilities":{"general":{"positionEncodings":["utf-8","utf-32","utf-16"]},"textDocument":{"codeAction":{"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","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","additionalTextEdits"]},"snippetSupport":true,"tagSupport":{"valueSet":[1]}},"completionItemKind":{}},"hover":{"contentFormat":["markdown"]},"inlayHint":{"dynamicRegistration":false},"publishDiagnostics":{"versionSupport":true},"rename":{"dynamicRegistration":false,"honorsChangeAnnotations":false,"prepareSupport":true},"signatureHelp":{"signatureInformation":{"activeParameterSupport":true,"documentationFormat":["markdown"],"parameterInformation":{"labelOffsetSupport":true}}}},"window":{"workDoneProgress":true},"workspace":{"applyEdit":true,"configuration":true,"didChangeConfiguration":{"dynamicRegistration":false},"didChangeWatchedFiles":{"dynamicRegistration":true,"relativePatternSupport":false},"executeCommand":{"dynamicRegistration":false},"inlayHint":{"refreshSupport":false},"symbol":{"dynamicRegistration":false},"workspaceEdit":{"documentChanges":true,"failureHandling":"abort","normalizesLineEndings":false,"resourceOperations":["create","rename","delete"]},"workspaceFolders":true}},"clientInfo":{"name":"helix","version":"23.10"},"initializationOptions":{"provideFormatter":true},"processId":33265,"rootPath":"/home/$USER/Documents/folder","rootUri":"file:///home/$USER/Documents/folder","workspaceFolders":[{"name":"folder","uri":"file:///home/$USER/Documents/folder"}]},"id":0}
2023-11-29T18:39:42.370 helix_lsp::transport [ERROR] matlab_ls err <- "(node:33293) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.\n"
2023-11-29T18:39:42.370 helix_lsp::transport [ERROR] matlab_ls err <- "(Use `node --trace-deprecation ...` to show where the warning was created)\n"
2023-11-29T18:39:42.372 helix_lsp::transport [INFO] matlab_ls <- {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":4,"message":"(18:39:42) matlabls: Log Directory: /tmp/matlabls_33293"}}
2023-11-29T18:39:42.372 helix_term::application [INFO] window/logMessage: LogMessageParams { typ: Log, message: "(18:39:42) matlabls: Log Directory: /tmp/matlabls_33293" }
2023-11-29T18:39:42.374 helix_lsp::transport [INFO] matlab_ls <- {"jsonrpc":"2.0","id":0,"result":{"capabilities":{"codeActionProvider":true,"completionProvider":{"triggerCharacters":[".","("," ",",","/","\\"]},"definitionProvider":true,"documentFormattingProvider":true,"executeCommandProvider":{"commands":["matlabls.lint.suppress.line","matlabls.lint.suppress.file"]},"referencesProvider":true,"signatureHelpProvider":{"triggerCharacters":["(",","]},"documentSymbolProvider":true,"textDocumentSync":2}}}
2023-11-29T18:39:42.374 helix_lsp::transport [INFO] matlab_ls <- {"capabilities":{"codeActionProvider":true,"completionProvider":{"triggerCharacters":[".","("," ",",","/","\\"]},"definitionProvider":true,"documentFormattingProvider":true,"documentSymbolProvider":true,"executeCommandProvider":{"commands":["matlabls.lint.suppress.line","matlabls.lint.suppress.file"]},"referencesProvider":true,"signatureHelpProvider":{"triggerCharacters":["(",","]},"textDocumentSync":2}}
2023-11-29T18:39:42.374 helix_lsp::transport [INFO] matlab_ls -> {"jsonrpc":"2.0","method":"initialized","params":{}}
2023-11-29T18:39:42.374 helix_lsp::transport [INFO] matlab_ls -> {"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{"provideFormatter":true}}}
2023-11-29T18:39:42.374 helix_lsp::transport [INFO] matlab_ls -> {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"matlab","text":"a = 3;\n","uri":"file:///home/$USER/Documents/folder/test.m","version":0}}}
2023-11-29T18:39:42.377 helix_lsp::transport [INFO] matlab_ls <- {"jsonrpc":"2.0","id":0,"method":"client/registerCapability","params":{"registrations":[{"id":"e64ea922-6bff-4ad7-93b8-c87065e27d40","method":"workspace/didChangeConfiguration","registerOptions":{}}]}}
2023-11-29T18:39:42.377 helix_term::application [WARN] Ignoring a client/registerCapability request because dynamic capability registration is not enabled. Please report this upstream to the language server
2023-11-29T18:39:42.377 helix_lsp::transport [INFO] matlab_ls -> {"jsonrpc":"2.0","result":null,"id":0}
2023-11-29T18:39:42.377 helix_lsp::transport [INFO] matlab_ls <- {"jsonrpc":"2.0","id":1,"method":"client/registerCapability","params":{"registrations":[{"id":"50e746db-07a7-490d-96c6-0f66a6dc6519","method":"workspace/didChangeWorkspaceFolders","registerOptions":{}}]}}
2023-11-29T18:39:42.377 helix_term::application [WARN] Ignoring a client/registerCapability request because dynamic capability registration is not enabled. Please report this upstream to the language server
2023-11-29T18:39:42.377 helix_lsp::transport [INFO] matlab_ls -> {"jsonrpc":"2.0","result":null,"id":1}
2023-11-29T18:39:42.378 helix_lsp::transport [INFO] matlab_ls <- {"jsonrpc":"2.0","id":2,"method":"workspace/configuration","params":{"items":[{"section":"MATLAB"}]}}
2023-11-29T18:39:42.378 helix_lsp::transport [INFO] matlab_ls -> {"jsonrpc":"2.0","result":[null],"id":2}
2023-11-29T18:39:42.378 helix_lsp::transport [INFO] matlab_ls <- {"jsonrpc":"2.0","id":3,"method":"workspace/configuration","params":{"items":[{"section":"MATLAB"}]}}
2023-11-29T18:39:42.378 helix_lsp::transport [INFO] matlab_ls -> {"jsonrpc":"2.0","result":[null],"id":3}
2023-11-29T18:39:42.379 helix_lsp::transport [INFO] matlab_ls <- {"jsonrpc":"2.0","method":"telemetry/logdata","params":{"eventKey":"ACTIONS","data":{"action_type":"openFile","result":"1"}}}
2023-11-29T18:39:42.379 helix_lsp::transport [INFO] matlab_ls <- {"jsonrpc":"2.0","id":4,"method":"workspace/configuration","params":{"items":[{"section":"MATLAB"}]}}
2023-11-29T18:39:42.379 helix_term::application [ERROR] received malformed notification from Language Server: Unhandled
2023-11-29T18:39:42.379 helix_lsp::transport [INFO] matlab_ls -> {"jsonrpc":"2.0","result":[null],"id":4}
2023-11-29T18:39:42.384 helix_lsp::transport [ERROR] matlab_ls err <- "/home/$USER/.local/share/nvim/mason/packages/matlab-language-server/out/index.js:1\n"
2023-11-29T18:39:42.384 helix_lsp::transport [ERROR] matlab_ls err <- ""<reducted> 
2023-11-29T18:39:42.385 helix_lsp::transport [ERROR] matlab_ls err <- "Node.js v21.2.0\n"
2023-11-29T18:39:42.389 helix_lsp::transport [ERROR] matlab_ls err: <- StreamClosed
  1. File /tmp/matlabls_12345/languageServerLog.txt:
(18:39:42) matlabls: Log Directory: /tmp/matlabls_33293

What I have observed

Helix is able to talk to the language server just momentarily. :lsp-workspace-command can show two items, which are correct: matlabls.lint.suppress.line and matlabls.lint.suppress.file. However, the server is shutdown as above log shows.

Any suggestions / ideas? Thank you!

@gabydd
Copy link
Member

gabydd commented Nov 30, 2023

Hmm two things does it work properly in neovim? Also the stuff under environment should be under config.matlab I think

@SubtleMuffin
Copy link
Author

Thanks for the info! I can confirm that it works properly in neovim. I cannot seem to find the documentation for config.<language>. Could you please elaborate?

@helix-editor helix-editor locked and limited conversation to collaborators Nov 30, 2023
@the-mikedavis the-mikedavis converted this issue into discussion #8956 Nov 30, 2023

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants