{"id":20683179,"url":"https://github.com/chimehq/languageserverscripts","last_synced_at":"2025-04-22T12:23:36.552Z","repository":{"id":219932199,"uuid":"750303705","full_name":"ChimeHQ/LanguageServerScripts","owner":"ChimeHQ","description":"A collection of standardized scripts for managing LSP language servers with a Swift API","archived":false,"fork":false,"pushed_at":"2024-09-17T13:20:48.000Z","size":24,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-09-17T16:38:12.538Z","etag":null,"topics":["language-server-protocol","script","swift"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ChimeHQ.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["mattmassicotte"]}},"created_at":"2024-01-30T11:41:11.000Z","updated_at":"2024-09-17T13:20:52.000Z","dependencies_parsed_at":"2024-02-02T23:46:31.898Z","dependency_job_id":null,"html_url":"https://github.com/ChimeHQ/LanguageServerScripts","commit_stats":null,"previous_names":["chimehq/languageserverscripts"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChimeHQ%2FLanguageServerScripts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChimeHQ%2FLanguageServerScripts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChimeHQ%2FLanguageServerScripts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ChimeHQ%2FLanguageServerScripts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ChimeHQ","download_url":"https://codeload.github.com/ChimeHQ/LanguageServerScripts/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224974662,"owners_count":17401108,"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":["language-server-protocol","script","swift"],"created_at":"2024-11-16T22:15:39.585Z","updated_at":"2024-11-16T22:15:40.131Z","avatar_url":"https://github.com/ChimeHQ.png","language":"Shell","funding_links":["https://github.com/sponsors/mattmassicotte"],"categories":[],"sub_categories":[],"readme":"# LanguageServerScripts\nA collection of standardized scripts for managing [LSP][languageserverprotocol] language servers with a Swift API\n\nInstalling, updating, and running language servers is tricky. It can be complex, and is almost always very server-specific. The idea here is to establish a standarized script API so applications can use the servers while sharing common infrastructure for managing them.\n\nThis repo is also a Swift package that includes facilities for installation, should you be in control of a non-sandboxed app. Otherwise, the scripts themselves are available to be used directly for other installation mechanisms, including manual.\n\n\u003e [!WARNING]\n\u003e This is currenty very WIP. Layout and API still preliminary.\n\n## Sandboxing\n\nIn general, language servers will not work when run inside a sandbox. A secondary benefit of standarized scripts is use with the [NSUserUnixTask](https://developer.apple.com/documentation/foundation/nsuserunixtask) API on macOS. This is a facility that allows out-of-sandbox process execution, which is perfect for this use. However, for this to work, the scripts need to be installed somehow, and that cannot be done by a sandboxed process.\n\nThis repo also includes a **global** registry of applications that would like to participate in the shared script model. The idea is any one application will install the necessary components to **all** targets in the registry. This way, once a users machine is set up for one app, it will also be prepared for all.\n\n## The API\n\nFor this abstraction to actually work, there needs to be a uniform API for all server scripts:\n\n```\nUsage: script.sh [-w path] [-e KEY=VALUE] command\n\nSupported commands: install, update, version, run\n\n  -e: set an environment variable. Can be set multiple times.\n  -w: change the working directory for the command.\n```\n\nRemember that this scripts are designed to be compatible with `NSUserUnixTask`. This means they cannot change working directory or set environment variables externally. This all must be handled from within the script.\n\n## Example\n\n```sh\n# sh gopls.sh -e GOPATH=/Users/me/go -w /Project/Directory run\n```\n\n## Common Directory\n\nServer scripts are named after the server, included in single a known location.\n\n```\n~/Library/Application Support/com.chimehq.LanguageServerScripts/gopls.sh\n```\n\n## Global Client List\n\nIf you choose, your process's bundle id can be added to a global list. Clients can then automatically create a symlink within your `Application Scripts` directory to `com.chimehq.LanguageServerScripts` so that the common directory will be accessible to you from within the sandbox. \n\n```\n~/Library/Application Scripts/com.chimehq.Edit\n~/Library/Application Scripts/com.chimehq.Edit.Clojure\n~/Library/Application Scripts/com.chimehq.Edit.Elixir\n~/Library/Application Scripts/com.chimehq.Edit.Go\n~/Library/Application Scripts/com.chimehq.Edit.Python\n~/Library/Application Scripts/com.chimehq.Edit.Ruby\n~/Library/Application Scripts/com.chimehq.Edit.Rust\n~/Library/Application Scripts/com.chimehq.Edit.Swift\n```\n\n## Shared command line interface\n\nBash is hard to use, but the API needs to be standardized. I thought it would be handy to try to have some core logic in a shared script too:\n\n```\n/Library/Application Support/com.chimehq.LanguageServerScripts/cli.sh\n```\n\nThis script:\n\n- parses flags\n- determines and excutes the supplied action\n- optionally captures the user's shell environment\n\n\u003e [!WARNING]\n\u003e Flags are parsed, but currently they have no effect.\n\nHere's an example of how to use this. Note that the `source` command must come after the functions are defined.\n\n```bash\n#!/bin/bash\n\nset -euo pipefail\n\nfunction version() {\n\techo \"print a server-specific version string\"\n}\n\nfunction install() {\n\techo \"install the server\"\n\techo \"this should not do updates, to make the already-installed case fast\"\n}\n\nfunction update() {\n\techo \"update to the latest version of the server\"\n}\n\nfunction run() {\n\techo \"start and run the server\"\n\techo \"must use supplied environment variables\"\n\techo \"and an optional working directory\"\n}\n\nsource \"$(dirname \"$0\")/cli.sh\"\n```\n\n## Versioning\n\nThis scripts will change. How should clients know if they have the latest versions?\n\n```\n/Library/Application Support/com.chimehq.LanguageServerScripts/VERSIONS\n```\n\nThis file will contain a sorted list of name/integer pairs corresponding to the versions of everything inside of this directory except for the VERSIONS file itself.\n\n```\ncli.sh 12\ngopls.sh 5\nimaginary_server.sh 4564\n```\n\nClients are permitted to upgrade any script to a newer version.\n\n## Contributing and Collaboration\n\nI would love to hear from you! Issues or pull requests work great. Both a [Matrix space][matrix] and [Discord][discord] are available for live help, but I have a strong bias towards answering in the form of documentation. You can also find me on [mastodon](https://mastodon.social/@mattiem).\n\nI prefer collaboration, and would love to find ways to work together if you have a similar project.\n\nI prefer indentation with tabs for improved accessibility. But, I'd rather you use the system you want and make a PR than hesitate because of whitespace.\n\nBy participating in this project you agree to abide by the [Contributor Code of Conduct](CODE_OF_CONDUCT.md).\n\n[matrix]: https://matrix.to/#/%23chimehq%3Amatrix.org\n[matrix badge]: https://img.shields.io/matrix/chimehq%3Amatrix.org?label=Matrix\n[discord]: https://discord.gg/esFpX6sErJ\n[languageserverprotocol]: https://github.com/ChimeHQ/LanguageServerProtocol\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchimehq%2Flanguageserverscripts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchimehq%2Flanguageserverscripts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchimehq%2Flanguageserverscripts/lists"}