From 7a79998d1bf91323b67b140433cda8c7f5aa83e9 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 eefa2a67..c99a51da 100644 --- a/internal/lsp/general.go +++ b/internal/lsp/general.go @@ -72,6 +72,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{ CodeActionProvider: false, @@ -106,7 +111,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) }