mirror of
https://github.com/unisonweb/unison.git
synced 2024-09-21 15:28:15 +03:00
Add namespace, term, type autocomplete
This commit is contained in:
parent
5e428a7701
commit
b0a8ac5e4e
@ -6,6 +6,7 @@ module Unison.CommandLine.InputPatterns where
|
||||
import Control.Lens (preview, (^.))
|
||||
import Control.Lens.Cons qualified as Cons
|
||||
import Data.List (intercalate)
|
||||
import Data.List.Extra qualified as List
|
||||
import Data.List.NonEmpty qualified as NE
|
||||
import Data.Map qualified as Map
|
||||
import Data.Maybe (fromJust)
|
||||
@ -452,7 +453,7 @@ ui =
|
||||
{ patternName = "ui",
|
||||
aliases = [],
|
||||
visibility = I.Visible,
|
||||
argTypes = [],
|
||||
argTypes = [(Optional, namespaceOrDefinitionArg)],
|
||||
help = P.wrap "`ui` opens the Local UI in the default browser.",
|
||||
parse = \case
|
||||
[] -> pure $ Input.UiI Path.relativeEmpty'
|
||||
@ -2963,6 +2964,17 @@ namespaceArg =
|
||||
globTargets = Set.fromList [Globbing.Namespace]
|
||||
}
|
||||
|
||||
namespaceOrDefinitionArg :: ArgumentType
|
||||
namespaceOrDefinitionArg =
|
||||
ArgumentType
|
||||
{ typeName = "term, type, or namespace",
|
||||
suggestions = \q cb _http p -> Codebase.runTransaction cb do
|
||||
namespaces <- prefixCompleteNamespace q p
|
||||
termsTypes <- prefixCompleteTermOrType q p
|
||||
pure (List.nubOrd $ namespaces <> termsTypes),
|
||||
globTargets = Set.fromList [Globbing.Namespace, Globbing.Term, Globbing.Type]
|
||||
}
|
||||
|
||||
-- | Names of child branches of the branch, only gives options for one 'layer' deeper at a time.
|
||||
childNamespaceNames :: Branch.Branch0 m -> [Text]
|
||||
childNamespaceNames b = NameSegment.toText <$> Map.keys (Branch.nonEmptyChildren b)
|
||||
|
Loading…
Reference in New Issue
Block a user