mirror of
https://github.com/Myzel394/config-lsp.git
synced 2025-06-18 23:15:26 +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,
|
||||
) []protocol.Diagnostic {
|
||||
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
|
||||
|
||||
|
@ -10,7 +10,7 @@ import (
|
||||
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) {
|
||||
line := params.Position.Line
|
||||
@ -28,11 +28,12 @@ func TextDocumentCompletion(context *glsp.Context, params *protocol.CompletionPa
|
||||
entry.Separator == nil ||
|
||||
entry.Key == nil ||
|
||||
(common.CursorToCharacterIndex(cursor)) <= entry.Key.End.Character {
|
||||
// Empty line
|
||||
|
||||
return handlers.GetRootCompletions(
|
||||
d,
|
||||
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