From 8e43c3a7746d5b8d44026f464652e7247d5d3c4d Mon Sep 17 00:00:00 2001 From: Matthias Simon Date: Mon, 11 Nov 2024 11:21:47 +0100 Subject: [PATCH] Add proper version --- internal/lsp/general.go | 7 ++++++- langserver.go | 5 +++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/internal/lsp/general.go b/internal/lsp/general.go index 3db9facc..6d1288c8 100644 --- a/internal/lsp/general.go +++ b/internal/lsp/general.go @@ -98,6 +98,11 @@ func (s *Server) initialize(ctx context.Context, params *protocol.ParamInitializ setTrace(params.Trace) + version := "devel" + if v, ok := ctx.Value("version").(string); ok { + version = v + } + return &protocol.InitializeResult{ Capabilities: protocol.ServerCapabilities{ InlayHintProvider: s.registerInlayHintIfNoDynReg(), @@ -133,7 +138,7 @@ func (s *Server) initialize(ctx context.Context, params *protocol.ParamInitializ ServerInfo: struct { Name string `json:"name"` Version string `json:"version,omitempty"` - }{Name: "ntt", Version: "0.12.0"}, + }{Name: "ntt", Version: version}, }, nil } diff --git a/langserver.go b/langserver.go index a82f8e53..4281310a 100644 --- a/langserver.go +++ b/langserver.go @@ -4,8 +4,8 @@ import ( "context" "os" - "github.com/nokia/ntt/internal/lsp/fakenet" "github.com/nokia/ntt/internal/lsp" + "github.com/nokia/ntt/internal/lsp/fakenet" "github.com/nokia/ntt/internal/lsp/jsonrpc2" "github.com/spf13/cobra" ) @@ -21,5 +21,6 @@ var ( func langserver(cmd *cobra.Command, args []string) error { stream := jsonrpc2.NewHeaderStream(fakenet.NewConn("stdio", os.Stdin, os.Stdout)) - return lsp.NewServer(stream).Serve(context.TODO()) + ctx := context.WithValue(context.Background(), "version", version) + return lsp.NewServer(stream).Serve(ctx) }