{"id":15713647,"url":"https://github.com/elbywan/crystal-lsp","last_synced_at":"2025-05-07T01:45:46.306Z","repository":{"id":152587960,"uuid":"573851920","full_name":"elbywan/crystal-lsp","owner":"elbywan","description":"An implementation of the Language Server Protocol written in Crystal","archived":false,"fork":false,"pushed_at":"2024-10-04T05:19:32.000Z","size":305,"stargazers_count":16,"open_issues_count":1,"forks_count":3,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-31T05:04:19.113Z","etag":null,"topics":["crystal","crystal-lang","lsp","lsp-server"],"latest_commit_sha":null,"homepage":"","language":"Crystal","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/elbywan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"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}},"created_at":"2022-12-03T16:29:35.000Z","updated_at":"2025-03-10T10:09:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"1443e174-faa6-492f-a565-81541a33b90a","html_url":"https://github.com/elbywan/crystal-lsp","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elbywan%2Fcrystal-lsp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elbywan%2Fcrystal-lsp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elbywan%2Fcrystal-lsp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elbywan%2Fcrystal-lsp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elbywan","download_url":"https://codeload.github.com/elbywan/crystal-lsp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252798770,"owners_count":21805879,"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":["crystal","crystal-lang","lsp","lsp-server"],"created_at":"2024-10-03T21:32:37.279Z","updated_at":"2025-05-07T01:45:46.286Z","avatar_url":"https://github.com/elbywan.png","language":"Crystal","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `lsp`\n\n[![ci](https://github.com/elbywan/crystal-lsp/actions/workflows/ci.yml/badge.svg)](https://github.com/elbywan/crystal-lsp/actions/workflows/ci.yml)\n[![docs](https://img.shields.io/badge/%F0%9F%93%9A-Crystal%20docs-blueviolet)](https://elbywan.github.io/crystal-lsp/)\n\n### An implementation of the Language Server Protocol written in Crystal.\n\nThis shard is a **partial** implementation of the [Language Server Protocol](https://microsoft.github.io/language-server-protocol/).\nIt contains json mappings to the data structures and messages as well as a fully working server implementation.\n\n_The code has originally been written for the [crystalline](https://github.com/elbywan/crystalline) tool and is now extracted here._\n\n## Installation\n\n1. Add the dependency to your `shard.yml`:\n\n   ```yaml\n   dependencies:\n     lsp:\n       github: elbywan/crystal-lsp\n   ```\n\n2. Run `shards install`\n\n## Usage\n\n```crystal\nrequire \"lsp/server\"\n\n# Declare the server capabilities\n# See: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#capabilities\nserver_capabilities = LSP::ServerCapabilities.new(\n  # ...\n)\n\n# STDIN and STDOUT are used by default, but you can pass any IO.\nserver = LSP::Server.new(STDIN, STDOUT, server_capabilities)\n# A Controller is a class or struct that responds to client events.\n# Example: https://github.com/elbywan/crystalline/blob/master/src/crystalline/controller.cr\nserver.start(Controller.new)\n\nstruct Controller\n  # Called just after receiving the \"initialize\" request\n  def on_init(init_params : LSP::InitializeParams) : Nil\n    # …\n  end\n\n  # Called after the handshake is complete and before listening for requests and notifications\n  def when_ready : Nil\n    # …\n  end\n\n  # Called when the client sends a request (https://microsoft.github.io/language-server-protocol/specifications/specification-3-16/#requestMessage)\n  def on_request(message : LSP::RequestMessage)\n    # …\n  end\n\n  # Called when the client sends a notification (https://microsoft.github.io/language-server-protocol/specifications/specification-3-16/#notificationMessage)\n  def on_notification(message : LSP::NotificationMessage) : Nil\n    # …\n  end\n\n  # Called when the client sends a response (https://microsoft.github.io/language-server-protocol/specifications/specification-3-16/#responseMessage)\n  def on_response(message : LSP::ResponseMessage, original_message : LSP::RequestMessage?) : Nil\n    # …\n  end\nend\n```\n\n## Contributing\n\n1. Fork it (\u003chttps://github.com/elbywan/lsp/fork\u003e)\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n\n## Contributors\n\n- [Julien Elbaz](https://github.com/elbywan) - creator and maintainer\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felbywan%2Fcrystal-lsp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felbywan%2Fcrystal-lsp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felbywan%2Fcrystal-lsp/lists"}