mirror of
https://github.com/Myzel394/config-lsp.git
synced 2025-06-19 07:25:27 +02:00
fix(sshd_config): Improve completions
This commit is contained in:
parent
998c0740d1
commit
22cbfb711c
@ -13,16 +13,6 @@ func Analyze(
|
|||||||
d *sshdconfig.SSHDocument,
|
d *sshdconfig.SSHDocument,
|
||||||
) []protocol.Diagnostic {
|
) []protocol.Diagnostic {
|
||||||
errors := analyzeOptionsAreValid(d)
|
errors := analyzeOptionsAreValid(d)
|
||||||
|
|
||||||
if len(errors) > 0 {
|
|
||||||
return utils.Map(
|
|
||||||
errors,
|
|
||||||
func(err common.LSPError) protocol.Diagnostic {
|
|
||||||
return err.ToDiagnostic()
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
indexes, indexErrors := indexes.CreateIndexes(*d.Config)
|
indexes, indexErrors := indexes.CreateIndexes(*d.Config)
|
||||||
_ = indexes
|
_ = indexes
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ import (
|
|||||||
protocol "github.com/tliron/glsp/protocol_3_16"
|
protocol "github.com/tliron/glsp/protocol_3_16"
|
||||||
)
|
)
|
||||||
|
|
||||||
var containsSeparatorPattern = regexp.MustCompile(`\s+$`)
|
var isEmptyPattern = regexp.MustCompile(`^\s*$`)
|
||||||
|
|
||||||
func TextDocumentCompletion(context *glsp.Context, params *protocol.CompletionParams) (any, error) {
|
func TextDocumentCompletion(context *glsp.Context, params *protocol.CompletionParams) (any, error) {
|
||||||
line := params.Position.Line
|
line := params.Position.Line
|
||||||
@ -28,11 +28,12 @@ func TextDocumentCompletion(context *glsp.Context, params *protocol.CompletionPa
|
|||||||
entry.Separator == nil ||
|
entry.Separator == nil ||
|
||||||
entry.Key == nil ||
|
entry.Key == nil ||
|
||||||
(common.CursorToCharacterIndex(cursor)) <= entry.Key.End.Character {
|
(common.CursorToCharacterIndex(cursor)) <= entry.Key.End.Character {
|
||||||
// Empty line
|
|
||||||
return handlers.GetRootCompletions(
|
return handlers.GetRootCompletions(
|
||||||
d,
|
d,
|
||||||
matchBlock,
|
matchBlock,
|
||||||
entry == nil || containsSeparatorPattern.Match([]byte(entry.Value)),
|
// Empty line, or currently typing a new key
|
||||||
|
entry == nil || isEmptyPattern.Match([]byte(entry.Value[cursor:])),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user