-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(lsp): use lsp server and client interfaces
- Loading branch information
Showing
24 changed files
with
533 additions
and
366 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package yamlls | ||
|
||
import ( | ||
"context" | ||
|
||
"go.lsp.dev/protocol" | ||
) | ||
|
||
// ApplyEdit implements protocol.Client. | ||
func (y Connector) ApplyEdit(ctx context.Context, params *protocol.ApplyWorkspaceEditParams) (result bool, err error) { | ||
return true, nil | ||
} | ||
|
||
// LogMessage implements protocol.Client. | ||
func (y Connector) LogMessage(ctx context.Context, params *protocol.LogMessageParams) (err error) { | ||
return nil | ||
} | ||
|
||
// Progress implements protocol.Client. | ||
func (y Connector) Progress(ctx context.Context, params *protocol.ProgressParams) (err error) { | ||
return nil | ||
} | ||
|
||
// RegisterCapability implements protocol.Client. | ||
func (y Connector) RegisterCapability(ctx context.Context, params *protocol.RegistrationParams) (err error) { | ||
return nil | ||
} | ||
|
||
// ShowMessage implements protocol.Client. | ||
func (y Connector) ShowMessage(ctx context.Context, params *protocol.ShowMessageParams) (err error) { | ||
return y.client.ShowMessage(ctx, params) | ||
} | ||
|
||
// ShowMessageRequest implements protocol.Client. | ||
func (y Connector) ShowMessageRequest(ctx context.Context, params *protocol.ShowMessageRequestParams) (result *protocol.MessageActionItem, err error) { | ||
return nil, nil | ||
} | ||
|
||
// Telemetry implements protocol.Client. | ||
func (y Connector) Telemetry(ctx context.Context, params interface{}) (err error) { | ||
return nil | ||
} | ||
|
||
// UnregisterCapability implements protocol.Client. | ||
func (y Connector) UnregisterCapability(ctx context.Context, params *protocol.UnregistrationParams) (err error) { | ||
return nil | ||
} | ||
|
||
// WorkDoneProgressCreate implements protocol.Client. | ||
func (y Connector) WorkDoneProgressCreate(ctx context.Context, params *protocol.WorkDoneProgressCreateParams) (err error) { | ||
return nil | ||
} | ||
|
||
// WorkspaceFolders implements protocol.Client. | ||
func (y Connector) WorkspaceFolders(ctx context.Context) (result []protocol.WorkspaceFolder, err error) { | ||
return nil, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,22 @@ | ||
package yamlls | ||
|
||
import ( | ||
"encoding/json" | ||
"context" | ||
|
||
"go.lsp.dev/jsonrpc2" | ||
lsp "go.lsp.dev/protocol" | ||
"go.lsp.dev/protocol" | ||
) | ||
|
||
func (yamllsConnector Connector) handleConfiguration(req jsonrpc2.Request) []interface{} { | ||
var params lsp.ConfigurationParams | ||
if err := json.Unmarshal(req.Params(), ¶ms); err != nil { | ||
logger.Error("Error parsing configuration request from yamlls", err) | ||
} | ||
logger.Debug("Yamlls ConfigurationParams", params) | ||
settings := []interface{}{yamllsConnector.config.YamllsSettings} | ||
return settings | ||
// Configuration implements protocol.Client. | ||
func (y Connector) Configuration(ctx context.Context, params *protocol.ConfigurationParams) (result []interface{}, err error) { | ||
settings := []interface{}{y.config.YamllsSettings} | ||
return settings, nil | ||
} | ||
|
||
func (y Connector) DidChangeConfiguration() (err error) { | ||
ctx := context.Background() | ||
return y.server.DidChangeConfiguration(ctx, &protocol.DidChangeConfigurationParams{ | ||
Settings: map[string]interface{}{ | ||
"yaml": y.config.YamllsSettings, | ||
}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1 @@ | ||
package yamlls | ||
|
||
import ( | ||
"context" | ||
|
||
lsplocal "github.com/mrjosh/helm-ls/internal/lsp" | ||
"go.lsp.dev/jsonrpc2" | ||
lsp "go.lsp.dev/protocol" | ||
) | ||
|
||
func (yamllsConnector *Connector) yamllsHandler(clientConn jsonrpc2.Conn, documents *lsplocal.DocumentStore) jsonrpc2.Handler { | ||
return func(ctx context.Context, reply jsonrpc2.Replier, req jsonrpc2.Request) error { | ||
|
||
switch req.Method() { | ||
case lsp.MethodTextDocumentPublishDiagnostics: | ||
yamllsConnector.handleDiagnostics(req, clientConn, documents) | ||
case lsp.MethodWorkspaceConfiguration: | ||
settings := yamllsConnector.handleConfiguration(req) | ||
return reply(ctx, settings, nil) | ||
default: | ||
logger.Debug("Method not handled by yamlls handler: ", req.Method()) | ||
} | ||
|
||
return reply(ctx, true, nil) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.