1

I am trying to get this Matlab language server to work with lsp-mode. Following the instructions in lsp-mode's github page, I inserted the following in my init.el:

(use-package lsp-mode
  :ensure t
  :commands (lsp lsp-deferred)
  :config
  (setq lsp-auto-configure t)
  (lsp-register-client
   (make-lsp-client :new-connection (lsp-stdio-connection "~/.local/share/git/matlab-langserver/matlab-langserver.sh")
                    :major-modes '(matlab-mode)
                    :server-id 'matlab-langserver)))

Where matlab-langserver.sh is

#!/usr/bin/env bash

cd ~/.local/share/git/matlab-langserver/
MATLABROOT="/opt/MATLAB/R2018b"
java -Djava.library.path=$MATLABROOT/bin/glnxa64 -cp $MATLABROOT/extern/engines/java/jar/engine.jar:$MATLABROOT/java/jar/jmi.jar:./build/libs/lsp-matlab-0.1.jar org.tokor.lspmatlab.Application

That last java command being the way to start the server. Here's what happens if I just run this script:

➜  matlab-langserver git:(master) ✗ ./matlab-langserver.sh
2019-11-27 12:50:27.252 [main] INFO  org.tokor.lspmatlab.Application {} - Starting server
2019-11-27 12:50:27.542 [main] INFO  org.tokor.lspmatlab.MATLABEngineSingleton {} - Could not find existing sessions. Starting MATLAB Engine...

When I load up a Matlab m file and start lsp, it connects successfully to the server, but then doesn't do anything. No autocomplete, no hover, nothing.

Here is some sample output from *lsp-log*

[Trace - 12:41:59 PM] Sending request 'textDocument/signatureHelp - (14)'.
Params: {
  "textDocument": {
    "uri": "file:///home/user/Documents/freq_resp_with_damping.m"
  },
  "position": {
    "line": 33,
    "character": 16
  }
}


[Trace - 12:41:59 PM] Received response 'textDocument/signatureHelp - (14)' in 10ms.
Result: null


[Trace - 12:42:07 PM] Sending request 'textDocument/signatureHelp - (15)'.
Params: {
  "textDocument": {
    "uri": "file:///home/user/Documents/freq_resp_with_damping.m"
  },
  "position": {
    "line": 60,
    "character": 27
  }
}


[Trace - 12:42:07 PM] Received response 'textDocument/signatureHelp - (15)' in 10ms.
Result: null

Any ideas how I can get it to work?

  • Have you tried with the eglot package? – Stefan Nov 27 '19 at 21:43
  • Yes I did. The behavior appears to be the same, although I'm not able to access eglot's I/O log of the conversation with the server. – Karthik Nov 27 '19 at 22:40
0

It looks like the issue is not in the client (lsp-mode) but it is in the server. My guess is that it needs some special initializationOptions or it is broken(e. g. does not support the file you are testing with).

The options are:

  • Test with other clients that are working fine. I usually check what vscode client does since most of the time there is no documentation on what additionally the server require.
  • Ask in the server repo for guidance.
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.