Skip to content
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

Bump fix to include latest upstream commits #1

Open
wants to merge 7 commits into
base: fix_nvim_lsp
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2021 Cristian Maglie. All rights reserved.
// Copyright 2024 Cristian Maglie. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//
Expand Down
8 changes: 8 additions & 0 deletions doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//
// Copyright 2024 Cristian Maglie. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//

// Package lsp is an implementation of a Language Server Protocol handler.
package lsp
8 changes: 7 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
module go.bug.st/lsp

go 1.15
go 1.22

require (
github.com/arduino/go-paths-helper v1.6.1
github.com/davecgh/go-spew v1.1.0
github.com/stretchr/testify v1.6.1
go.bug.st/json v1.15.6
)

require (
github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c // indirect
)
8 changes: 8 additions & 0 deletions jsonrpc/doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//
// Copyright 2024 Cristian Maglie. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//

// Package jsonrpc is an implementation of a Language Server Protocol JSON-RPC protocol.
package jsonrpc
8 changes: 4 additions & 4 deletions jsonrpc/jsonrpc_connection.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2021 Cristian Maglie. All rights reserved.
// Copyright 2024 Cristian Maglie. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//
Expand Down Expand Up @@ -236,14 +236,14 @@ func (c *Connection) Close() {

func (c *Connection) SendRequest(ctx context.Context, method string, params json.RawMessage) (json.RawMessage, *ResponseError, error) {
id := fmt.Sprintf("%d", atomic.AddUint64(&c.lastOutRequestsIndex, 1))
encodedId, err := json.Marshal(id)
encodedID, err := json.Marshal(id)
if err != nil {
// should never happen...
panic("internal error creating RequestMessage")
}
req := RequestMessage{
JSONRPC: "2.0",
ID: encodedId,
ID: encodedID,
Method: method,
Params: params,
}
Expand Down Expand Up @@ -277,7 +277,7 @@ func (c *Connection) SendRequest(ctx context.Context, method string, params json
_, active := c.activeOutRequests[id]
c.activeOutRequestsMutex.Unlock()
if active {
if notif, err := json.Marshal(CancelParams{ID: encodedId}); err != nil {
if notif, err := json.Marshal(CancelParams{ID: encodedID}); err != nil {
// should never happen
panic("internal error: failed json encoding")
} else {
Expand Down
2 changes: 1 addition & 1 deletion jsonrpc/jsonrpc_protocol.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2021 Cristian Maglie. All rights reserved.
// Copyright 2024 Cristian Maglie. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//
Expand Down
2 changes: 1 addition & 1 deletion jsonrpc/jsonrpc_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2021 Cristian Maglie. All rights reserved.
// Copyright 2024 Cristian Maglie. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//
Expand Down
2 changes: 1 addition & 1 deletion jsonrpc/logger.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2021 Cristian Maglie. All rights reserved.
// Copyright 2024 Cristian Maglie. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//
Expand Down
6 changes: 3 additions & 3 deletions lsp_basic.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2021 Cristian Maglie. All rights reserved.
// Copyright 2024 Cristian Maglie. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//
Expand Down Expand Up @@ -260,7 +260,7 @@ func (p WorkDoneProgressEnd) String() string {
return res
}

// General parameters to register for a capability.
// Registration General parameters to register for a capability.
type Registration struct {
// The id used to register the request. The id can be used to deregister
// the request again.
Expand All @@ -277,7 +277,7 @@ type RegistrationParams struct {
Registrations []Registration `json:"registrations,required"`
}

// General parameters to unregister a capability.
// Unregistration General parameters to unregister a capability.
type Unregistration struct {
// The id used to unregister the request or notification. Usually an id
// provided during the register request.
Expand Down
32 changes: 16 additions & 16 deletions lsp_basic_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// Copyright 2021 Cristian Maglie. All rights reserved.
// Copyright 2024 Cristian Maglie. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
//
Expand All @@ -23,7 +23,7 @@ func TestDecodingProgressReports(t *testing.T) {
Percentage: &perc,
}

beginJson := `{
beginJSON := `{
"cancellable" : true,
"kind" : "begin",
"message" : "mesg",
Expand All @@ -32,21 +32,21 @@ func TestDecodingProgressReports(t *testing.T) {
}`
beginData, err := json.Marshal(beginParam)
require.NoError(t, err)
require.JSONEq(t, beginJson, string(beginData))
require.JSONEq(t, beginJSON, string(beginData))

err = json.Unmarshal([]byte(beginJson), &beginParam)
err = json.Unmarshal([]byte(beginJSON), &beginParam)
require.NoError(t, err)
}
{
begin_json := `{
beginJSON := `{
"token": "aaaa10292992929287172",
"value": {
"kind": "begin",
"title": "hello",
"cancellable": true
}
}`
r, err := DecodeServerNotificationParams("$/progress", json.RawMessage([]byte(begin_json)))
r, err := DecodeServerNotificationParams("$/progress", json.RawMessage([]byte(beginJSON)))
require.NoError(t, err)
require.IsType(t, &ProgressParams{}, r)
pp := r.(*ProgressParams)
Expand All @@ -62,29 +62,29 @@ func TestDecodingProgressReports(t *testing.T) {
Percentage: &perc,
}

reportJson := `{
reportJSON := `{
"cancellable" : true,
"kind" : "report",
"message" : "mesg",
"percentage" : 15
}`
reportData, err := json.Marshal(reportParam)
require.NoError(t, err)
require.JSONEq(t, reportJson, string(reportData))
require.JSONEq(t, reportJSON, string(reportData))

err = json.Unmarshal([]byte(reportJson), &reportParam)
err = json.Unmarshal([]byte(reportJSON), &reportParam)
require.NoError(t, err)
}
{
report_json := `{
reportJSON := `{
"token": "aaaa10292992929287172",
"value": {
"kind": "report",
"message": "hello",
"cancellable": true
}
}`
r, err := DecodeServerNotificationParams("$/progress", json.RawMessage([]byte(report_json)))
r, err := DecodeServerNotificationParams("$/progress", json.RawMessage([]byte(reportJSON)))
require.NoError(t, err)
require.IsType(t, &ProgressParams{}, r)
pp := r.(*ProgressParams)
Expand All @@ -97,26 +97,26 @@ func TestDecodingProgressReports(t *testing.T) {
Message: "mesg",
}

endJson := `{
endJSON := `{
"kind" : "end",
"message" : "mesg"
}`
endData, err := json.Marshal(endParam)
require.NoError(t, err)
require.JSONEq(t, endJson, string(endData))
require.JSONEq(t, endJSON, string(endData))

err = json.Unmarshal([]byte(endJson), &endParam)
err = json.Unmarshal([]byte(endJSON), &endParam)
require.NoError(t, err)
}
{
end_json := `{
endJSON := `{
"token": "aaaa10292992929287172",
"value": {
"kind": "end",
"message": "bye"
}
}`
r, err := DecodeServerNotificationParams("$/progress", json.RawMessage([]byte(end_json)))
r, err := DecodeServerNotificationParams("$/progress", json.RawMessage([]byte(endJSON)))
require.NoError(t, err)
require.IsType(t, &ProgressParams{}, r)
pp := r.(*ProgressParams)
Expand Down
Loading