lsp
Version, currently 0.1.24 versions
github.com/elbywan/crystal-lsp
An implementation of the Language Server Protocol written in Crystal
20 stars
2 dependents
License: MIT
Installation
# Add this to your shard.yml
dependencies:
lsp:
github: elbywan/crystal-lsp
version: ~> 0.1.2Then run:
shards installshard.yml
- Crystal
1.6.1- License
- MIT
- Author
- Julien Elbaz
Dependencies
This version declares no dependencies.
README
This README is the one indexed from the repository at its latest ref, not from the tag for this version.
lsp
An implementation of the Language Server Protocol written in Crystal.
This shard is a partial implementation of the Language Server Protocol. It contains json mappings to the data structures and messages as well as a fully working server implementation.
The code has originally been written for the crystalline tool and is now extracted here.
Installation
-
Add the dependency to your
shard.yml:dependencies: lsp: github: elbywan/crystal-lsp -
Run
shards install
Usage
require "lsp/server"
# Declare the server capabilities
# See: https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#capabilities
server_capabilities = LSP::ServerCapabilities.new(
# ...
)
# STDIN and STDOUT are used by default, but you can pass any IO.
server = LSP::Server.new(STDIN, STDOUT, server_capabilities)
# A Controller is a class or struct that responds to client events.
# Example: https://github.com/elbywan/crystalline/blob/master/src/crystalline/controller.cr
server.start(Controller.new)
struct Controller
# Called just after receiving the "initialize" request
def on_init(init_params : LSP::InitializeParams) : Nil
# …
end
# Called after the handshake is complete and before listening for requests and notifications
def when_ready : Nil
# …
end
# Called when the client sends a request (https://microsoft.github.io/language-server-protocol/specifications/specification-3-16/#requestMessage)
def on_request(message : LSP::RequestMessage)
# …
end
# Called when the client sends a notification (https://microsoft.github.io/language-server-protocol/specifications/specification-3-16/#notificationMessage)
def on_notification(message : LSP::NotificationMessage) : Nil
# …
end
# Called when the client sends a response (https://microsoft.github.io/language-server-protocol/specifications/specification-3-16/#responseMessage)
def on_response(message : LSP::ResponseMessage, original_message : LSP::RequestMessage?) : Nil
# …
end
end
Contributing
- Fork it (https://github.com/elbywan/lsp/fork)
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create a new Pull Request
Contributors
- Julien Elbaz - creator and maintainer
Documentation
Built from the current release. The first visit to a release nobody has asked for starts its build.
Links
This release
- Version
0.1.2- Tagged
- Dec 5, 2022
- Commit
2ef630b1c0ba- Crystal
1.6.1- Indexed
- yes
Dependents
Repository
github.com/elbywan/crystal-lsp
Metadata
- Created
- Aug 12, 2026
- Updated
- Sep 23, 2026
- Synced
- Sep 23, 2026
- Versions
- 4