| IndentAnnotation
| DedentAnnotation
| CommandsAnnotation
- -- TODO: may need more here, command name, for example
- -- :Ack {blah} *:Ack*
- | CommandAnnotation Usage
+ | CommandAnnotation Name (Maybe Parameters)
| FooterAnnotation
| MappingsAnnotation
-- TODO: need more here, like default value?
type Description = String
type Name = String
type Type = String
-type Usage = String
+type Parameters = String
-- | Walks an AST node calling the supplied visitor function.
--
, plugin
]
- command = string "command" >> ws >> CommandAnnotation <$> ((:) <$> char ':' <*> many1 (noneOf "\n"))
+ command = string "command" >> ws >> CommandAnnotation <$> commandName <*> commandParameters
+ commandName = char ':' *> many1 alphaNum <* optional ws
+ commandParameters = optionMaybe $ many1 (noneOf "\n")
function = string "function" >> ws >> FunctionAnnotation <$> word <* optional ws
Blockquote b -> blockquote b >>= nl >>= nl
BreakTag -> breaktag
Code c -> append $ "`" ++ c ++ "`"
+ CommandAnnotation {} -> command n
CommandsAnnotation -> heading "commands"
DocBlock d -> nodes d
Fenced f -> fenced f
-- TODO: if there is no OptionsAnnotation but there are OptionAnnotations, we
-- need to insert a `heading "options"` before the first option (ditto for
-- functions, mappings, commands)
- OptionsAnnotation -> heading "options"
OptionAnnotation {} -> option n
+ OptionsAnnotation -> heading "options"
Paragraph p -> nodes p >>= nl >>= nl
Plaintext p -> plaintext p
-- TODO: this should be order-independent and always appear at the top.
where
customLineBreak = "\n "
+command :: Node -> Env
+command (CommandAnnotation name params) = do
+ lhs <- append $ concat [":", name, " ", fromMaybe "" params]
+ ws <- append " "
+ target <- linkTargets [":" ++ name] False
+ trailing <- append "\n"
+ return $ concat [lhs, ws, target, trailing]
+-- TODO indent what follows until next annotation...
+-- will require us to hoist it up inside CommandAnnotation
+-- (and do similar for other sections)
+-- once that is done, drop the extra newline above
+
option :: Node -> Env
option (OptionAnnotation n t d) = do
targets <- linkTargets [n] True
-- | Returns True if a node marks the end of a region/block/section.
endSection :: Node -> Bool
endSection = \case
- CommandAnnotation _ -> True
+ CommandAnnotation {} -> True
CommandsAnnotation -> True
FooterAnnotation -> True
FunctionAnnotation _ -> True
extractCommand = extractBlocks f
where
f = \case
- CommandAnnotation _ -> Just endSection
- _ -> Nothing
+ CommandAnnotation {} -> Just endSection
+ _ -> Nothing
--- /dev/null
+Project
+ [ Project [ Unit [ DocBlock [] ] ]
+ , CommandAnnotation "Ack" (Just "{pattern} {options}")
+ , Paragraph [ Plaintext "Info." ]
+ , CommandAnnotation "Qargs" Nothing
+ , Paragraph
+ [ Plaintext "No"
+ , Whitespace
+ , Plaintext "params"
+ , Whitespace
+ , Plaintext "on"
+ , Whitespace
+ , Plaintext "that"
+ , Whitespace
+ , Plaintext "one."
+ ]
+ , Paragraph
+ [ Plaintext "TODO:"
+ , Whitespace
+ , Plaintext "Infer"
+ , Whitespace
+ , Plaintext "info"
+ , Whitespace
+ , Plaintext "based"
+ , Whitespace
+ , Plaintext "on"
+ , Whitespace
+ , Plaintext "following"
+ , Whitespace
+ , Plaintext "VimL"
+ , Whitespace
+ , Plaintext "nodes."
+ ]
+ ]
--- /dev/null
+""
+" @command :Ack {pattern} {options}
+"
+" Info.
+"
+" @command :Qargs
+"
+" No params on that one.
+"
+" TODO: Infer info based on following VimL nodes.
, UnletStatement { unletBang = False , unletBody = "s:cpoptions" }
]
]
- , CommandAnnotation ":Ack {pattern} {options}"
+ , CommandAnnotation "Ack" (Just "{pattern} {options}")
, Paragraph
[ Plaintext "Searches"
, Whitespace
, Whitespace
, Plaintext "cursor."
]
- , CommandAnnotation ":Lack {pattern} {options}"
+ , CommandAnnotation "Lack" (Just "{pattern} {options}")
, Paragraph
[ Plaintext "Just"
, Whitespace
, Link "location-list"
, Plaintext "."
]
- , CommandAnnotation ":Acks /{pattern}/{replacement}/"
+ , CommandAnnotation "Acks" (Just "/{pattern}/{replacement}/")
, Paragraph
[ Plaintext "Takes"
, Whitespace
, Plaintext "directory:"
]
, Fenced [ ":Ack foo" , ":Acks /foo/bar/" ]
- , CommandAnnotation ":Qargs"
+ , CommandAnnotation "Qargs" Nothing
, Paragraph
[ Plaintext "This"
, Whitespace
>
:call pathogen#helptags()
<
+:Ack {pattern} {options} *:Ack*
+
Searches for {pattern} in all the files under the current directory (see
|:pwd|), unless otherwise overridden via {options}, and displays the results
in the |quickfix| listing.
(|<Plug>(FerretAckWord)|) is a shortcut for running |:Ack| with the word
currently under the cursor.
+:Lack {pattern} {options} *:Lack*
+
Just like |:Ack|, but instead of using the |quickfix| listing, which is global
across an entire Vim instance, it uses the |location-list|, which is a
per-window construct.
Note that |:Lack| always runs synchronously via |:cexpr|, because dispatch.vim
doesn't currently support the |location-list|.
+:Acks /{pattern}/{replacement}/ *:Acks*
+
Takes all of the files currently in the |quickfix| listing and performs a
substitution of all instances of {pattern} (a standard Vim search |pattern|)
by {replacement}.
:Ack foo
:Acks /foo/bar/
<
+:Qargs *:Qargs*
+
This is a utility function that is used by the |:Acks| command but is also
generally useful enough to warrant being exposed publicly.