Sublime Forum

Setting up matlab language server

#1

Hey, I’m trying to set up matlab lsp language server as described here: matlab language server

I’m using this setting:

"matlab": {
               "command": ["/path/to/lsp-matlab", "--stdio", "--matlabInstallPath '/usr/local/MATLAB/R2023a'"],
               "enabled": true,
               "selector": "source.m"
           }

where the lsp-matlab file has this:

#!/usr/bin/env bash

node /home/user/software/MATLAB-language-server/out/index.js $@

But nothing happens. Can you tell what I’m doing wrong?

Regards

0 Likes

#2

source.matlab, to see the scope, press ctrt+alt+shift+p

0 Likes

#3

after doing that I got this log:

startup, version: 4169 linux x64 channel: stable
executable: /opt/sublime_text/sublime_text
application: /opt/sublime_text
working dir: /home/kira
packages path: /home/kira/.config/sublime-text/Packages
state path: /home/kira/.config/sublime-text/Local
zip path: /opt/sublime_text/Packages
zip path: /home/kira/.config/sublime-text/Installed Packages
ignored_packages: ["Vintage"]
Errors parsing theme:
  "class" is required in Packages/User/Adaptive.sublime-theme:10:17
pre session restore time: 0.123094
loading dictionary Packages/Language - English/en_US.dic
startup time: 0.305648
first paint time: 0.318158
reloading plugin Default.arithmetic
reloading plugin Default.auto_indent_tag
reloading plugin Default.block
reloading plugin Default.colors
reloading plugin Default.comment
reloading plugin Default.convert_color_scheme
reloading plugin Default.convert_syntax
reloading plugin Default.copy_path
reloading plugin Default.echo
reloading plugin Default.exec
reloading python 3.3 plugin AutoFileName.autofilename
reloading plugin Default.fold
reloading python 3.3 plugin AutoFileName.getimageinfo
reloading python 3.3 plugin BracketHighlighter.bh_core
reloading plugin Default.font
reloading plugin Default.goto_line
reloading plugin Default.history_list
reloading plugin Default.html_print
reloading plugin Default.indentation
reloading plugin Default.install_package_control
reloading plugin Default.keymap
reloading plugin Default.kill_ring
reloading plugin Default.mark
reloading plugin Default.new_templates
reloading plugin Default.open_context_url
reloading plugin Default.open_in_browser
reloading plugin Default.pane
reloading plugin Default.paragraph
reloading plugin Default.paste_from_history
reloading plugin Default.profile
reloading plugin Default.quick_panel
reloading plugin Default.rename
reloading plugin Default.run_syntax_tests
reloading plugin Default.save_on_focus_lost
reloading plugin Default.scroll
reloading plugin Default.set_unsaved_view_name
reloading plugin Default.settings
reloading plugin Default.show_scope_name
reloading plugin Default.side_bar
reloading plugin Default.sort
reloading plugin Default.switch_file
reloading plugin Default.symbol
reloading plugin Default.transform
reloading plugin Default.transpose
reloading plugin Default.ui
reloading plugin CSS.css_completions
reloading plugin Diff.diff
reloading plugin HTML.encode_html_entities
reloading plugin HTML.html_completions
reloading plugin MarkdownEditing.plugin
reloading plugin Package Control.plugin
reloading python 3.3 plugin BracketHighlighter.bh_logging
reloading python 3.3 plugin BracketHighlighter.bh_plugin
reloading python 3.3 plugin BracketHighlighter.bh_popup
reloading python 3.3 plugin BracketHighlighter.bh_regions
reloading python 3.3 plugin BracketHighlighter.bh_remove
reloading python 3.3 plugin BracketHighlighter.bh_rules
reloading python 3.3 plugin BracketHighlighter.bh_search
reloading python 3.3 plugin BracketHighlighter.bh_swapping
reloading python 3.3 plugin BracketHighlighter.bh_wrapping
reloading python 3.3 plugin BracketHighlighter.support
reloading python 3.3 plugin LSP-bash.plugin
reloading python 3.3 plugin LSP-clangd.plugin
reloading python 3.3 plugin LSP-html.plugin
reloading python 3.3 plugin LSP-html.types
reloading python 3.3 plugin LSP-json.commands
reloading python 3.3 plugin LSP-json.plugin
reloading python 3.3 plugin LSP-json.schema_store
reloading python 3.3 plugin LSP-marksman.plugin
reloading python 3.3 plugin LSP-pyright.commands
reloading python 3.3 plugin LSP-pyright.plugin
reloading python 3.3 plugin LSP-R.plugin
reloading python 3.3 plugin LSP-TexLab.const
reloading python 3.3 plugin LSP-TexLab.lsp_texlab_auto_complete
reloading python 3.3 plugin LSP-TexLab.lsp_texlab_build_system
reloading python 3.3 plugin LSP-TexLab.plugin
reloading python 3.3 plugin LSP-TexLab.server
reloading python 3.3 plugin LSP-TexLab.tarball
reloading python 3.3 plugin LSP.boot
reloading python 3.3 plugin PackageDev._logging
reloading python 3.3 plugin PackageDev.main
reloading python 3.3 plugin Sync View Scroll.syncscroll
reloading python 3.3 plugin Terminus.main
reloading python 3.3 plugin View In Browser.ViewInBrowserCommand
reloading python 3.3 plugin SendCode.choose_prog
reloading python 3.3 plugin SendCode.exec
reloading python 3.3 plugin SendCode.install_xdotool
reloading python 3.3 plugin SendCode.send_code
reloading python 3.3 plugin SendCode.settings
plugins loaded
rlang is disabled by LSP-R.
LSP: enabled configs: LSP-R, LSP-TexLab, LSP-bash, LSP-html, LSP-json, LSP-pyright, clangd, marksman, matlab, nushell
LSP: disabled configs: erlang-ls, ocaml, polymer-ide, rlang, ruby, sorbet
syncScroll starting
Traceback (most recent call last):
  File "/home/kira/.config/sublime-text/Installed Packages/LSP.sublime-package/plugin/core/windows.py", line 484, in _update_panel_main_thread
    panel.run_command("lsp_update_panel", {"characters": characters})
  File "/opt/sublime_text/Lib/python33/sublime.py", line 1395, in run_command
    sublime_api.view_run_command(self.view_id, cmd, args)
  File "/opt/sublime_text/Lib/python33/sublime_plugin.py", line 1495, in run_
    self.view.end_edit(edit)
  File "/opt/sublime_text/Lib/python33/sublime.py", line 1356, in end_edit
    sublime_api.view_end_edit(self.view_id, edit.edit_token)
  File "/opt/sublime_text/Lib/python33/sublime_plugin.py", line 924, in on_modified
    run_view_callbacks('on_modified', view_id)
  File "/opt/sublime_text/Lib/python33/sublime_plugin.py", line 708, in run_view_callbacks
    callback(v, *args)
  File "/opt/sublime_text/Lib/python33/sublime_plugin.py", line 152, in profiler
    return event_handler(*args)
  File "/home/kira/.config/sublime-text/Installed Packages/AutoFileName.sublime-package/autofilename.py", line 162, in on_modified
    sel = view.sel()[0].a
  File "/opt/sublime_text/Lib/python33/sublime.py", line 1087, in __getitem__
    raise IndexError()
IndexError
LSP: starting ['/home/kira/Yandex.Disk/Comandos_bash_for_nushell/lsp-matlab', '--stdio', "--matlabInstallPath '/usr/local/MATLAB/R2023a'"] in /opt/sublime_text
LSP: matlab: Supported execute commands: ['matlabls.lint.suppress.line', 'matlabls.lint.suppress.file']
LSP: matlab: registering capability: didChangeConfigurationProvider
LSP: matlab: registering capability: workspace.workspaceFolders
LSP: matlab crashed (1 / 5 times in the last 180.0 seconds), exit code 1, exception: None
LSP: starting ['/home/kira/Yandex.Disk/Comandos_bash_for_nushell/lsp-matlab', '--stdio', "--matlabInstallPath '/usr/local/MATLAB/R2023a'"] in /opt/sublime_text
LSP: matlab: Supported execute commands: ['matlabls.lint.suppress.line', 'matlabls.lint.suppress.file']
LSP: matlab: registering capability: didChangeConfigurationProvider
LSP: matlab: registering capability: workspace.workspaceFolders
LSP: matlab crashed (2 / 5 times in the last 180.0 seconds), exit code 1, exception: None
LSP: starting ['/home/kira/Yandex.Disk/Comandos_bash_for_nushell/lsp-matlab', '--stdio', "--matlabInstallPath '/usr/local/MATLAB/R2023a'"] in /opt/sublime_text
LSP: matlab: Supported execute commands: ['matlabls.lint.suppress.line', 'matlabls.lint.suppress.file']
LSP: matlab: registering capability: didChangeConfigurationProvider
LSP: matlab: registering capability: workspace.workspaceFolders
LSP: matlab crashed (3 / 5 times in the last 180.0 seconds), exit code 1, exception: None
LSP: starting ['/home/kira/Yandex.Disk/Comandos_bash_for_nushell/lsp-matlab', '--stdio', "--matlabInstallPath '/usr/local/MATLAB/R2023a'"] in /opt/sublime_text
LSP: matlab: Supported execute commands: ['matlabls.lint.suppress.line', 'matlabls.lint.suppress.file']
LSP: matlab: registering capability: didChangeConfigurationProvider
LSP: matlab: registering capability: workspace.workspaceFolders
LSP: matlab crashed (4 / 5 times in the last 180.0 seconds), exit code 1, exception: None
LSP: starting ['/home/kira/Yandex.Disk/Comandos_bash_for_nushell/lsp-matlab', '--stdio', "--matlabInstallPath '/usr/local/MATLAB/R2023a'"] in /opt/sublime_text
LSP: matlab: Supported execute commands: ['matlabls.lint.suppress.line', 'matlabls.lint.suppress.file']
LSP: matlab: registering capability: didChangeConfigurationProvider
LSP: matlab: registering capability: workspace.workspaceFolders
LSP: matlab crashed (5 / 5 times in the last 180.0 seconds), exit code 1, exception: None
Package Control: Skipping automatic upgrade, last run at 2023-12-03 16:45:12, next run at 2023-12-04 00:45:12 or after
LSP: starting ['/home/kira/Yandex.Disk/Comandos_bash_for_nushell/lsp-matlab', '--stdio', "--matlabInstallPath '/usr/local/MATLAB/R2023a'"] in /opt/sublime_text
LSP: matlab: Supported execute commands: ['matlabls.lint.suppress.line', 'matlabls.lint.suppress.file']
LSP: matlab: registering capability: didChangeConfigurationProvider
LSP: matlab: registering capability: workspace.workspaceFolders
LSP: matlab crashed (5 / 5 times in the last 180.0 seconds), exit code 1, exception: None
0 Likes

#4

That said it’s now starting. As for how to properly set it up, you may have to ask its author, read its docs, or worstly, read its source codes.

0 Likes

#5

Is there any other option in the configuration that could help?

0 Likes

#6

This is still my answer. This is not LSP plugin issue. The first thing is to know how to start the server properly (what cli command should be used? what initializationOptions should be used? what settings should be used?), which is not LSP-related and not ST-related.

0 Likes

#7

Currently, this project is not intended to be installed on its own, however that may change in the future.

It seems to be another case of “LSP is for VSCode, we don’t care about other editors…” :poop:


Is there any error message from the server in the log panel (LSP: Toggle Log Panel from the command palette)?

0 Likes

#8

yes, I got THIS (too long to post).

0 Likes

#9

Can you instead try the following command? Just a shot in the dark here.

"command": ["/path/to/lsp-matlab", "--stdio", "--matlabInstallPath",  "/usr/local/MATLAB/R2023a"]
0 Likes

#10

I see that you have a single file open due to 'workspaceFolders': None.

Can you instead try opening a root directory?

(I would expect single files to work nonetheless, since VSCode supports that as well).

0 Likes

#11

what do you mean opening a root directory?
if you mean open a folder with sublime text, I updated the LOG:

0 Likes

#12

Looking at the neovim config,

In case they are initializationOptions, try this:

        "matlab": {
            "command": [
                "/path/to/lsp-matlab",
                "--stdio",
                "--matlabInstallPath",
                "/usr/local/MATLAB/R2023a"
            ],
            "enabled": true,
            "selector": "source.m",
            "initializationOptions": {
                "MATLAB.indexWorkspace": true,
                "MATLAB.installPath": "/usr/local/MATLAB/R2023a",
                "MATLAB.matlabConnectionTiming": "onStart",
                "MATLAB.telemetry": false
            }
        }

In case they are server settings, try this configuration:

        "matlab": {
            "command": [
                "/path/to/lsp-matlab",
                "--stdio",
                "--matlabInstallPath",
                "/usr/local/MATLAB/R2023a"
            ],
            "enabled": true,
            "selector": "source.m",
            "settings": {
                "MATLAB.indexWorkspace": true,
                "MATLAB.installPath": "/usr/local/MATLAB/R2023a",
                "MATLAB.matlabConnectionTiming": "onStart",
                "MATLAB.telemetry": false
            }
        }
0 Likes

#13

ok, let me try it

0 Likes

#14

Hey, thatk you very much!!
using system settings didn’t crash even in a single file. It seems to be working fine, although I haven’t read what should do, is recognizing basic stuff like missing semicolon or non used variables.

1 Like

#15

I just put all together in this little REPO, with instructions on how to install the server.

0 Likes