{"id":13761294,"url":"https://github.com/WolframResearch/LSPServer","last_synced_at":"2025-05-10T12:31:41.346Z","repository":{"id":38796703,"uuid":"400618753","full_name":"WolframResearch/LSPServer","owner":"WolframResearch","description":"LSPServer is a package that implements the Language Server Protocol for Wolfram Language and allows a Wolfram Language kernel to run as an LSP server.","archived":false,"fork":false,"pushed_at":"2022-12-19T12:12:52.000Z","size":2310,"stargazers_count":52,"open_issues_count":2,"forks_count":9,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-28T17:49:29.341Z","etag":null,"topics":["editor","ide","language-server-protocol","lsp","lsp-client","lsp-server","mathematica","sublime-text","visual-studio-code","wolfram","wolfram-language","wolfram-mathematica"],"latest_commit_sha":null,"homepage":"","language":"Mathematica","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/WolframResearch.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-08-27T19:43:08.000Z","updated_at":"2025-03-27T16:37:39.000Z","dependencies_parsed_at":"2023-01-29T21:31:10.065Z","dependency_job_id":null,"html_url":"https://github.com/WolframResearch/LSPServer","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WolframResearch%2FLSPServer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WolframResearch%2FLSPServer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WolframResearch%2FLSPServer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WolframResearch%2FLSPServer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WolframResearch","download_url":"https://codeload.github.com/WolframResearch/LSPServer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253415538,"owners_count":21904872,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["editor","ide","language-server-protocol","lsp","lsp-client","lsp-server","mathematica","sublime-text","visual-studio-code","wolfram","wolfram-language","wolfram-mathematica"],"created_at":"2024-08-03T13:01:47.869Z","updated_at":"2025-05-10T12:31:40.969Z","avatar_url":"https://github.com/WolframResearch.png","language":"Mathematica","funding_links":[],"categories":["Mathematica"],"sub_categories":[],"readme":"# LSPServer\n\nLSPServer is a package that implements the [Language Server Protocol](https://microsoft.github.io/language-server-protocol/) for Wolfram Language and allows a Wolfram Language kernel to run as an LSP server.\n\n[Developing Wolfram Language Code in Other Editors and IDEs with LSP from WTC 2021: Watch Video (youtube)](https://www.youtube.com/watch?v=nXVEOUMZbzQ)\n\nLSPServer implements several LSP features:\n* Code diagnostics\n* Suggestions for fixes\n* Formatting files and selections\n* Semantic highlighting\n* Expand / shrink selection\n* Outline\n* Color swatches\n* Symbol references\n* Documentation on hover\n\nThis repo is for users who are interested in adding LSP support for Wolfram Language to LSP clients.\n\nThere are official Wolfram LSP clients for [Sublime Text](https://github.com/WolframResearch/Sublime-WolframLanguage) and [Visual Studio Code](https://github.com/WolframResearch/vscode-wolfram).\n\n\n## Setup\n\nLSPServer depends on [CodeParser paclet](https://github.com/WolframResearch/codeparser), [CodeInspector paclet](https://github.com/WolframResearch/codeinspector), and [CodeFormatter paclet](https://github.com/WolframResearch/codeformatter).\n\nLSPServer and its dependencies are included in Mathematica 13.0 and above.\n\nInstall LSPServer paclet and dependencies from the public paclet server:\n```\nPacletInstall[\"CodeParser\"]\nPacletInstall[\"CodeInspector\"]\nPacletInstall[\"CodeFormatter\"]\nPacletInstall[\"LSPServer\"]\n```\n\n[Build and install the LSPServer paclet locally](HowToBuild.md)\n\n\n## Using LSPServer\n\n99% of users will not need to worry about using LSPServer directly. LSPServer is used internally when an LSP client launches a Wolfram kernel as an LSP server. This all happens in the background.\n\nBut it can be useful to run LSPServer when developing a new LSP client.\n\nCreate a file named server.wl:\n```\nNeeds[\"LSPServer`\"]\n\nStartServer[]\n```\n\nAnd run from the command-line:\n```\nbrenton@brenton2maclap % WolframKernel -noprompt -run Get\\[\\\"server.wl\\\"\\]\n14:03:48.605 $CommandLine: {WolframKernel, -noprompt, -run, Get[\"server.wl\"]}\n14:03:48.607 \n\n\n14:03:48.608 $commProcess: StdIO\n14:03:48.608 \n\n\n14:03:48.608 $ProcessID: 54603\n14:03:48.609 \n\n\n14:03:48.609 $ParentProcessID: 54582\n14:03:48.609 \n\n\n14:03:48.609 Starting server... (If this is the last line you see, then StartServer[] may have been called in an unexpected way and the server is hanging.)\n14:03:48.610 \n```\n\nNotice the proper character escapes on the command-line.\n\nThe kernel process is blocked waiting on input to its stdin.\n\nProperly formed LSP JSON-RPC can be sent to the kernel, and the kernel would send its response to stdout.\n\n\n## Troubleshooting\n\nMake sure that the paclets can be found on your system:\n```\nNeeds[\"LSPServer`\"]\n```\n\nYou may get `LibraryFunction` messages:\n```\n14:49:15.663 $CommandLine: {/Applications/Mathematica.app/Contents/MacOS/WolframKernel, -noinit, -noprompt, -nopaclet, -nostartuppaclets, -noicon, -run, Needs[\"LSPServer`\"];LSPServer`StartServer[\"/Users/user/logs/\"]}\n14:49:15.664 \n\n\n14:49:15.664 $commProcess: StdIO\n14:49:15.664 \n\n\n14:49:15.665 $ProcessID: 22400\n14:49:15.665 \n\n\n14:49:15.666 $ParentProcessID: 22394\n14:49:15.666 \n\n\n14:49:15.667 Directory[]: /private/var/folders/90/4fbnjdqx3f791xb65c02fm2m000bfy/T/Wolfram-LSPServer\n14:49:15.667 \n\n\n14:49:15.668 Starting server... (If this is the last line you see, then StartServer[] may have been called in an unexpected way and the server is hanging.)\n14:49:15.668 \n\n\n\nLibraryFunction::version: The version number 7 of the library is not consistent with the current or any previous WolframLibraryVersion.\n\nLibraryFunction::initerr: A nonzero error code 7 was returned during the initialization of the library /Users/user/Library/Mathematica/Paclets/Repository/LSPServer-1.6/LibraryResources/MacOSX-x86-64/LSPServer.dylib.\n\nLibraryFunction::libload: The function GetStartupError_LibraryLink was not loaded from the file /Users/user/Library/Mathematica/Paclets/Repository/LSPServer-1.6/LibraryResources/MacOSX-x86-64/LSPServer.dylib.\n14:49:16.129 \n\n\n14:49:16.129 Initialization failed: Failure[\"LibraryFunctionLoad\", \u003c|\"Result\" -\u003e $Failed|\u003e]\n14:49:16.484 \n\n\n14:49:16.485 Language Server kernel did not shutdown properly.\n14:49:16.485 \n14:49:16.487 This is the command that was used:\n14:49:16.488 {/Applications/Mathematica.app/Contents/MacOS/WolframKernel, -noinit, -noprompt, -nopaclet, -nostartuppaclets, -noicon, -run, Needs[\"LSPServer`\"];LSPServer`StartServer[\"/Users/user/logs/\"]}\n14:49:16.488 \n14:49:16.489 To help diagnose the problem, run this in a notebook:\n             Needs[\"LSPServer`\"]\n             LSPServer`RunServerDiagnostic[{\"/Applications/Mathematica.app/Contents/MacOS/WolframKernel\", \"-noinit\", \"-noprompt\", \"-nopaclet\", \"-nostartuppaclets\", \"-noicon\", \"-run\", \"Needs[\\\"LSPServer`\\\"];LSPServer`StartServer[\\\"/Users/user/logs/\\\"]\"}]\n14:49:16.490 \n14:49:16.490 Fix any problems then restart and try again.\n14:49:16.491 \n\n\n14:49:16.492 KERNEL IS EXITING HARD\n14:49:16.492 \n```\n\nThis means that LSPServer was built with a newer version of Wolfram System than your system supports.\n\nTo fix this, build LSPServer from source with the version of Wolfram System that you will use.\n\n\n### Server settings\n\nTurn on debug logging from the kernel.\n\nGive a string argument to StartServer[]. This is a directory that kernel logs will be written to.\n\n```\nNeeds[\"LSPServer`\"];LSPServer`StartServer[\"/path/to/log/directory/\"]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FWolframResearch%2FLSPServer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FWolframResearch%2FLSPServer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FWolframResearch%2FLSPServer/lists"}