mirror of
https://github.com/Myzel394/config-lsp.git
synced 2025-06-18 23:15:26 +02:00
feat(ssh_config): Add completions support
This commit is contained in:
parent
92b2f12e3f
commit
a9e58a7f50
@ -1,6 +1,7 @@
|
|||||||
package handlers
|
package handlers
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"config-lsp/common"
|
||||||
docvalues "config-lsp/doc-values"
|
docvalues "config-lsp/doc-values"
|
||||||
sshconfig "config-lsp/handlers/ssh_config"
|
sshconfig "config-lsp/handlers/ssh_config"
|
||||||
"config-lsp/handlers/ssh_config/ast"
|
"config-lsp/handlers/ssh_config/ast"
|
||||||
@ -57,3 +58,41 @@ func GetRootCompletions(
|
|||||||
},
|
},
|
||||||
), nil
|
), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetOptionCompletions(
|
||||||
|
d *sshconfig.SSHDocument,
|
||||||
|
entry *ast.SSHOption,
|
||||||
|
block ast.SSHBlock,
|
||||||
|
cursor common.CursorPosition,
|
||||||
|
) ([]protocol.CompletionItem, error) {
|
||||||
|
option, found := fields.Options[entry.Key.Key]
|
||||||
|
|
||||||
|
if !found {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if entry.Key.Key == "Match" {
|
||||||
|
return nil, nil
|
||||||
|
// return getMatchCompletions(
|
||||||
|
// d,
|
||||||
|
// cursor,
|
||||||
|
// matchBlock.MatchValue,
|
||||||
|
// )
|
||||||
|
}
|
||||||
|
|
||||||
|
if entry.OptionValue == nil {
|
||||||
|
return option.FetchCompletions("", 0), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hello wo|rld
|
||||||
|
line := entry.OptionValue.Value.Raw
|
||||||
|
// NEW: docvalues index
|
||||||
|
return option.FetchCompletions(
|
||||||
|
line,
|
||||||
|
common.DeprecatedImprovedCursorToIndex(
|
||||||
|
cursor,
|
||||||
|
line,
|
||||||
|
entry.OptionValue.Start.Character,
|
||||||
|
),
|
||||||
|
), nil
|
||||||
|
}
|
||||||
|
@ -37,14 +37,14 @@ func TextDocumentCompletion(context *glsp.Context, params *protocol.CompletionPa
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// if option.Separator != nil && option.OptionValue.IsPositionAfterStart(cursor) {
|
if option.Separator != nil && option.OptionValue.IsPositionAfterStart(cursor) {
|
||||||
// return handlers.GetOptionCompletions(
|
return handlers.GetOptionCompletions(
|
||||||
// d,
|
d,
|
||||||
// entry,
|
option,
|
||||||
// matchBlock,
|
block,
|
||||||
// cursor,
|
cursor,
|
||||||
// )
|
)
|
||||||
// }
|
}
|
||||||
|
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user