-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Features status #2
Comments
Thank you! I think the README mentions the supported features. The main difference between this and go-lsp is also mentioned in the README: much more comprehensive coverage. Also, the code is documented with links to every struct and message in the LSP specification, so you can double-check as well as get instruction on how to use each message. What else do you think should be listed? I started this project because go-lsp was insufficient. |
Ha I assumed it was more a goal than the actual state of the project, because of the disclaimer. Then that sounds great!
The code is well documented and clear. Maybe a minimal implementation example could help to get started. I played a bit with First, I got the following crash: _ "github.com/tliron/kutil/logging/simple" But it is not very obvious how to actually get the log messages. At the moment my test LSP server seems to be stuck in the "starting" phase of coc.nvim. I couldn't figure out how to make it run despite checking your Puccini LS. Do you have any idea what could be missing? package cmd
import (
"fmt"
"log"
"github.com/tliron/glsp"
protocol "github.com/tliron/glsp/protocol_3_16"
"github.com/tliron/glsp/server"
_ "github.com/tliron/kutil/logging/simple"
)
// LSP starts a server implementing the Language Server Protocol.
type LSP struct{}
var handler = protocol.Handler{}
var logger *log.Logger
func (cmd *LSP) Run() error {
handler.Initialize = initialize
handler.Initialized = initialized
handler.Shutdown = shutdown
handler.LogTrace = logTrace
handler.SetTrace = setTrace
handler.TextDocumentCompletion = textDocumentCompletion
debug := true
server := server.NewServer(&handler, "zk-lsp", debug)
fmt.Println("STARTING")
return server.RunTCP(":4230")
}
// initialize implements protocol.InitializeFunc
// Returns: InitializeResult | InitializeError
func initialize(context *glsp.Context, params *protocol.InitializeParams) (interface{}, error) {
log.Println("INITIALIZE")
// clientCapabilities = ¶ms.Capabilities
if params.Trace != nil {
protocol.SetTraceValue(*params.Trace)
}
resolveProvider := true
serverCapabilities := handler.CreateServerCapabilities()
serverCapabilities.TextDocumentSync = protocol.TextDocumentSyncKindIncremental
serverCapabilities.CompletionProvider = &protocol.CompletionOptions{
ResolveProvider: &resolveProvider,
TriggerCharacters: []string{"#"},
}
version := "1.0"
return &protocol.InitializeResult{
Capabilities: serverCapabilities,
ServerInfo: &protocol.InitializeResultServerInfo{
Name: "zk-lsp",
Version: &version,
},
}, nil
}
// protocol.TextDocumentCompletionFunc signature
// Returns: []CompletionItem | CompletionList | nil
func textDocumentCompletion(context *glsp.Context, params *protocol.CompletionParams) (interface{}, error) {
var completionItems []protocol.CompletionItem
completionItems = append(completionItems, protocol.CompletionItem{
Label: "server",
})
log.Println("COMPLETION")
return completionItems, nil
}
// protocol.InitializedFunc signature
func initialized(context *glsp.Context, params *protocol.InitializedParams) error {
log.Println("INITIALIZED")
return nil
}
// protocol.ShutdownFunc signature
func shutdown(context *glsp.Context) error {
protocol.SetTraceValue(protocol.TraceValueOff)
return nil
}
// protocol.LogTraceFunc signature
func logTrace(context *glsp.Context, params *protocol.LogTraceParams) error {
return nil
}
// protocol.SetTraceFunc signature
func setTrace(context *glsp.Context, params *protocol.SetTraceParams) error {
protocol.SetTraceValue(params.Value)
return nil
} |
Some of the pain points you are experiencing are why I put a "early release" warning. The problem is that indeed I did not do testing in many environments, for example no testing with coc.vim. Also I'm not sure how correct my TCP code is. Any help in debugging this would be very appreciated! I will assist in whatever way I can. Logging can help a lot, of course. :) To enable logging you need to call |
Thanks, that did the trick for the logging 👍 There's some progress! I figured that using stdio might be simpler than TCP, however I get the following error from Vim:
And here are the logs from glsp, the connection seems to have been successful:
|
It might be that coc.nvim is more demanding, because I managed to run my LS with Sublime Text:
Is there a way to debug the actual JSON-RPC messages sent with glsp, to see if the I was able to run a similar LS made with go-lsp, so I think my coc.nvim setup is fine. |
So, it was really dumb... I figured out a way to print the output from glsp, and it seemed correct:
The issue was that I added some stdout log in my cli app, which of course was messing up the protocol communication when using the stdio mode. After removing it, it's working properly and I get some basic completion 👍 Closing this issue, thanks and keep up the good work! |
Ha, that might have happened to me once or twice, too... By the way, one quirk of GLSP is that it absolutely requires the Content-Length header. It is not optional. |
Albeit in early stage, your project is looking very promising!
It would be helpful to have a list of supported features to know if
glsp
could be a good fit for a given project. I'm trying to figure out if I should go withglsp
or https://github.com/sourcegraph/go-lsp.I would be willing to contribute as well if something I need is missing.
The text was updated successfully, but these errors were encountered: