diff --git a/completers/go-tool-doc_completer/cmd/root.go b/completers/go-tool-doc_completer/cmd/root.go index 46f444fe02..4c3cbe0251 100644 --- a/completers/go-tool-doc_completer/cmd/root.go +++ b/completers/go-tool-doc_completer/cmd/root.go @@ -3,6 +3,7 @@ package cmd import ( "github.com/rsteube/carapace" "github.com/rsteube/carapace-bin/pkg/actions/tools/golang" + "github.com/rsteube/carapace/pkg/util" "github.com/spf13/cobra" "github.com/spf13/pflag" ) @@ -35,7 +36,12 @@ func init() { }) carapace.Gen(rootCmd).PositionalCompletion( - golang.ActionPackages(), + carapace.ActionCallback(func(c carapace.Context) carapace.Action { + if util.HasPathPrefix(c.Value) { + return carapace.ActionDirectories() + } + return golang.ActionPackages() + }), carapace.ActionMultiParts(".", func(c carapace.Context) carapace.Action { switch len(c.Parts) { case 0: