You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The LSPServer package provides a Wolfram Language LSP server for any LSP client, so if your vim or neovim has LSP client support, then it should definitely work just fine.
Maybe necro bump and not relevant, but I want to document it somewhere. With Kate I also hade some trouble setting up LSPServer, here is how I solved it.
First I ran the provided PacletInstall commands inside Mathematica, that is documented (mostly) clearly and worked without issue. However the documentation felt a bit ambiguous about the version information, as first I thougth it is also only available from 13+ based on the Setup while I was running 12.2. Based on my experience now I understand that from 13+ you don't have to run PacletInstall and it is needed (but works!) on earlier versions.
What I needed next was a command that Kate can run to fire up the server, however the oneliner with arguments did not work, so I created a script file (under Linux it was a bash script, but I think bat file under Windows, or the equivalent under Mac works the same) that contains the following:
If I may suggest, please update the 'Using LSPServer" section of the Readme with some hints around the used arguments and that it is not just a test, however this should be given also to the lspclient. It may be evident to someone with knowledge around the protocol, but it took me a couple of hours to figure out.
Also, to leave a positive comment as well, I really like the fact that Wolfram Mathematica contains everything essential to be used even without the notebook frontend. 🎉
A possible source of confusion about versions may be about the specific versions that appear in the paths for WolframKernel. When talking about the full path to WolframKernel on your machine, I like to give the default location for the latest version, so for example on Windows, it would be: C:\Program Files\Wolfram Research\Wolfram Engine\13.1\WolframKernel.exe
And this will be updated when 13.2 is released.
But this in no way implies that 13.1 is required. In fact, if you built from sources, you would be to go back to using version 12.1.
I'd like to understand any suggestion for better documentation around version information.
I will work to update the "Using LSPServer" section to be more clear.
Hello @even4void I am having some problems connecting Wolfram LSP and neovim, could you provide some more details about your config file? It should be placed under init.vim ?
Do you think it is possible to provide wolfram language support using COC ?
could you provide some more details about your config file? It should be placed under init.vim ?
I put everything related to LSP in a dedicated file (http://ix.io/4rAH), then require it from my init fiile (http://ix.io/4rAI), or rather a separate file (http://ix.io/4rAJ) where I manage plugins. I don't know about your config, but the above config is tied to a proper setup of nvim-lspconfig. I don't use COC so I can't tell if these settings apply in this case (probably not, since COC uses its own setup).
I had success with @JuanG970 ’s config, thanks! I think the "kernel" item in cmd table is not needed, but it also didn’t really do any harm either. In Sublime repo the kernel is just a variable that gets replaced with the path to the WolframKernel executable, which is already passed prior. Semantic tokens are enabled by default and that caused errors with sematicTokensProvider on every keypress:
vim.schedule callback:
....12.3/share/nvim/runtime/lua/vim/lsp/semantic_tokens.lua:437:
....12.3/share/nvim/runtime/lua/vim/lsp/semantic_tokens.lua:85:
attempt to index field 'semanticTokensProvider' (a userdata value)
I solved it by disabling semantic tokens for Wolfram LS by adding this to the start command:
localclient=vim.lsp.start ({
-- ... rest of the config ...on_init=function(client, _)
client.server_capabilities.semanticTokensProvider=nilend
})
Activity
bostick commentedon Aug 26, 2022
The LSPServer package provides a Wolfram Language LSP server for any LSP client, so if your vim or neovim has LSP client support, then it should definitely work just fine.
What have you tried so far?
hooger commentedon Nov 5, 2022
Maybe necro bump and not relevant, but I want to document it somewhere. With Kate I also hade some trouble setting up LSPServer, here is how I solved it.
First I ran the provided PacletInstall commands inside Mathematica, that is documented (mostly) clearly and worked without issue. However the documentation felt a bit ambiguous about the version information, as first I thougth it is also only available from 13+ based on the Setup while I was running 12.2. Based on my experience now I understand that from 13+ you don't have to run PacletInstall and it is needed (but works!) on earlier versions.
What I needed next was a command that Kate can run to fire up the server, however the oneliner with arguments did not work, so I created a script file (under Linux it was a bash script, but I think bat file under Windows, or the equivalent under Mac works the same) that contains the following:
and provided the script to the lspclient. The oneliner does not look the same as in the "Using LSPServer" section in the readme. I copied it from the sublime extensions source code, here: https://github.com/WolframResearch/Sublime-WolframLanguage/blob/master/WolframLanguage.sublime-settings#L21-L36 I'm not sure why it differs from the readme.
If I may suggest, please update the 'Using LSPServer" section of the Readme with some hints around the used arguments and that it is not just a test, however this should be given also to the lspclient. It may be evident to someone with knowledge around the protocol, but it took me a couple of hours to figure out.
Also, to leave a positive comment as well, I really like the fact that Wolfram Mathematica contains everything essential to be used even without the notebook frontend. 🎉
bostick commentedon Nov 7, 2022
Thank you for the feedback.
A possible source of confusion about versions may be about the specific versions that appear in the paths for WolframKernel. When talking about the full path to WolframKernel on your machine, I like to give the default location for the latest version, so for example on Windows, it would be:
C:\Program Files\Wolfram Research\Wolfram Engine\13.1\WolframKernel.exeAnd this will be updated when 13.2 is released.
But this in no way implies that 13.1 is required. In fact, if you built from sources, you would be to go back to using version 12.1.
I'd like to understand any suggestion for better documentation around version information.
I will work to update the "Using LSPServer" section to be more clear.
Thanks again!
even4void commentedon Feb 21, 2023
I can confirm that @hooger's solution works in Neovim (nightly). Here is part of my config that shows how to setup Wolfram Language Server:
Note that:
mmafiletype, even for wls scripts.autostart = true).on_attachin addition to LSP mappings, or use a custom mapping in yourftplugindirectory, e.g.:JuanG970 commentedon Mar 22, 2023
Hello @even4void I am having some problems connecting Wolfram LSP and neovim, could you provide some more details about your config file? It should be placed under init.vim ?
Do you think it is possible to provide wolfram language support using COC ?
even4void commentedon Mar 23, 2023
I put everything related to LSP in a dedicated file (http://ix.io/4rAH), then require it from my init fiile (http://ix.io/4rAI), or rather a separate file (http://ix.io/4rAJ) where I manage plugins. I don't know about your config, but the above config is tied to a proper setup of nvim-lspconfig. I don't use COC so I can't tell if these settings apply in this case (probably not, since COC uses its own setup).
JuanG970 commentedon Feb 29, 2024
I have this working using the following settings inside my
init.vimfile:Essentially, starts the LSP each time a mathematica file is opened.
Abastro commentedon Jul 31, 2024
Was anyone able to setup with CoC? While I set it up to start the server, it stops at
ArttuLai commentedon Jun 29, 2026
I had success with @JuanG970 ’s config, thanks! I think the
"kernel"item incmdtable is not needed, but it also didn’t really do any harm either. In Sublime repo thekernelis just a variable that gets replaced with the path to theWolframKernelexecutable, which is already passed prior. Semantic tokens are enabled by default and that caused errors withsematicTokensProvideron every keypress:I solved it by disabling semantic tokens for Wolfram LS by adding this to the start command: