From 1bda1f76e0cca18358c518203ec9f3dedd617cb2 Mon Sep 17 00:00:00 2001 From: Myzel394 <50424412+Myzel394@users.noreply.github.com> Date: Sun, 15 Sep 2024 15:53:16 +0200 Subject: [PATCH] fix(sshd_config): Fix hover for match blocks --- handlers/sshd_config/handlers/hover.go | 4 +++- .../sshd_config/lsp/text-document-code-action.go | 14 -------------- handlers/sshd_config/lsp/text-document-hover.go | 7 ++++++- .../sshd_config/lsp/workspace-execute-command.go | 10 ---------- root-handler/text-document-code-action.go | 3 +-- 5 files changed, 10 insertions(+), 28 deletions(-) delete mode 100644 handlers/sshd_config/lsp/text-document-code-action.go delete mode 100644 handlers/sshd_config/lsp/workspace-execute-command.go diff --git a/handlers/sshd_config/handlers/hover.go b/handlers/sshd_config/handlers/hover.go index b18efa5..56a033a 100644 --- a/handlers/sshd_config/handlers/hover.go +++ b/handlers/sshd_config/handlers/hover.go @@ -12,11 +12,13 @@ import ( func GetHoverInfoForOption( option *ast.SSHOption, matchBlock *ast.SSHMatchBlock, + line uint32, cursor uint32, ) (*protocol.Hover, error) { var docValue *docvalues.DocumentationValue - if matchBlock == nil { + // Either root level or in the line of a match block + if matchBlock == nil || matchBlock.Start.Line == line { val := fields.Options[option.Key.Value] docValue = &val } else { diff --git a/handlers/sshd_config/lsp/text-document-code-action.go b/handlers/sshd_config/lsp/text-document-code-action.go deleted file mode 100644 index 37950bd..0000000 --- a/handlers/sshd_config/lsp/text-document-code-action.go +++ /dev/null @@ -1,14 +0,0 @@ -package lsp - -import ( - "github.com/tliron/glsp" - protocol "github.com/tliron/glsp/protocol_3_16" -) - -func TextDocumentCodeAction(context *glsp.Context, params *protocol.CodeActionParams) ([]protocol.CodeAction, error) { - // document := hosts.DocumentParserMap[params.TextDocument.URI] - // - // actions := make([]protocol.CodeAction, 0, 1) - - return nil, nil -} diff --git a/handlers/sshd_config/lsp/text-document-hover.go b/handlers/sshd_config/lsp/text-document-hover.go index f6b5d96..1782116 100644 --- a/handlers/sshd_config/lsp/text-document-hover.go +++ b/handlers/sshd_config/lsp/text-document-hover.go @@ -24,5 +24,10 @@ func TextDocumentHover( return nil, nil } - return handlers.GetHoverInfoForOption(option, matchBlock, cursor) + return handlers.GetHoverInfoForOption( + option, + matchBlock, + line, + cursor, + ) } diff --git a/handlers/sshd_config/lsp/workspace-execute-command.go b/handlers/sshd_config/lsp/workspace-execute-command.go deleted file mode 100644 index f2f39d0..0000000 --- a/handlers/sshd_config/lsp/workspace-execute-command.go +++ /dev/null @@ -1,10 +0,0 @@ -package lsp - -import ( - "github.com/tliron/glsp" - protocol "github.com/tliron/glsp/protocol_3_16" -) - -func WorkspaceExecuteCommand(context *glsp.Context, params *protocol.ExecuteCommandParams) (*protocol.ApplyWorkspaceEditParams, error) { - return nil, nil -} diff --git a/root-handler/text-document-code-action.go b/root-handler/text-document-code-action.go index a9d3d33..f1da029 100644 --- a/root-handler/text-document-code-action.go +++ b/root-handler/text-document-code-action.go @@ -3,7 +3,6 @@ package roothandler import ( aliases "config-lsp/handlers/aliases/lsp" hosts "config-lsp/handlers/hosts/lsp" - sshdconfig "config-lsp/handlers/sshd_config/lsp" wireguard "config-lsp/handlers/wireguard/lsp" "github.com/tliron/glsp" @@ -29,7 +28,7 @@ func TextDocumentCodeAction(context *glsp.Context, params *protocol.CodeActionPa case LanguageHosts: return hosts.TextDocumentCodeAction(context, params) case LanguageSSHDConfig: - return sshdconfig.TextDocumentCodeAction(context, params) + return nil, nil case LanguageWireguard: return wireguard.TextDocumentCodeAction(context, params) case LanguageAliases: