A custom LSP server written in 100% Go. It's purpose was learning about how LSP servers actually work at a deeper level, gaining understanding and implementing a minimal version of it.
Built with Go version 1.22.1
on darwin/arm64
, and tested on NEOVIM v0.9.5
(Release) - link. Should
work with other editors as well given proper config of lsp at the client end.
A sample config used for testing this LSP server is linked here
A huuuge thanks to @tjdevries for sparking the interest in LSPs : )
This functionality in general displays the function / method / class synopsis as a popup in usual editors. It is invoked when cursor is kept on a word for a while. Here I have implemented a simple version of it which handles state and dynamically tells the char count.
- LSP Spec: Hover
- Invocation:
:lua vim.lsp.buf.hover()
- Demo (vimeo link):
This takes to the definition of the function / method(it is different from
implementation). This is invoked usually in editors when you
Ctrl / Cmd + click
on a keyword. In this implementaion it takes you to a line
above where the cursor is at the moment.
- LSP Spec: Go To Definition
- Invocation:
:lua vim.lsp.buf.definition()
- Demo (vimeo link):
When there are errors in your project and editor shows options to fix them, these are the code actions. The server returns with the possible potential solutions to the problems in the current context. This implementation takes it quite seriously xD.
- LSP Spec: Code Actions
- Invocation:
:lua vim.lsp.buf.code_action()
or:Telescope diagnostics
- Demo (vimeo link):
These are simply the suggestions which appear as you type. This implementation provides a couple of suggestions based on typing.
- LSP Spec: Completion
- Invocation:
:lua vim.lsp.buf.completion()
- Demo (vimeo link):
These are simply the errors, warnings, hints along with some more info related to them that editor keeps generating async-ly and shows them in the top right section (usually). This implementation takes a few funny takes on editors.
- LSP Spec: Diagnostics
- Invocation:
:lua vim.lsp.diagnostic.get_line_diagnostics()
(these btw get generated in insert mode only) - Demo (vimeo link):