Skip to content

An implemntation of Language Server Protocol Written In Go

Notifications You must be signed in to change notification settings

WizardOfOz-1/Golang-LSP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Minimal Implementation Of Langauge Server Protocol in Go

This is a barebones implementation of a Language Server Protocol (LSP) in Go, built to get familiar with LSP development. It supports fundamental features like hover information, go-to definitions, code actions, and autocomplete. The project is aimed at learning LSP concepts and basic Go development."

How To Install:

To install, just clone the repo and run go build main.go.

Command to clone the repo

How To Use:

Personally I Use Neovim, and I do not know the implementation process in other editors. So I will just lay out the steps for Neovim.

Creating The LSP Definition (**note the cmd field should point to combiled binary **)

-> And an autocommand to trigger the LSP whenever a markdown file is opened:

Triggering The LSP

Here I've added some keybindings just so its easier to do things such as codeactions,Hovers and Goto Definitions. For Autocomplete, CTRL + XCTRL+O triggers Neovim's built in auto complete so we can use that. This will happen automatically if you're using a completion engine like say nvim-cmp.

Screenshots:

Hover:

SPACE gd will trigger hover definition. (assuming leader is mapped to spacebar) textDocument/hover

Diagnostics:

Upon an instance of the word "VS Code" in the current buffer, the LSP will send out an ERROR diagnostic. (lol) textDocument/hover

Code Actions:

Upon a diagnostic error (in our case the word "VS Code") we can perform code actions, with SPACE ca (assuming leader is mapped to spacebar) textDocument/hover The user can pick any one of the above to either censor the word "VS Code" or to replace it with a superior editor (NEOVIM BTW)

Case Picking 1:


Code Action To Replace Neovim With Superior Editor
If user chooses 1, "VS Code" is replaced with Neovim, and the LSP affirms your decision. (lol)

Case Picking 2:


Code Action To censor VS Code
If user chooses 2, "VS Code" is censored to "VS C*de) (lol)


In case there are no diagnostics, codeactions wont trigger, and the editor will let the user know.
No Code Actions

Autocomplete:

Using CTRL XCTRL O will trigger autocomplete in Neovim, upon which the editor will receive autocomplete suggestion from the LSP. AutoComplete ( This happens automatically if you're using a completion engine as nvim-cmp )

About

An implemntation of Language Server Protocol Written In Go

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages