Home Explore Blog CI



neovim

24th chunk of `runtime/doc/api.txt`
00e564f24c332ed4b3817a49b9b9c85ac3b5cbd0ca77a2da0000000100000fe2
 not allowed (determines whether
                       they will stop parsing process or be recognized as an
                       operator/space, though also yielding an error).
                     • "l" when needing to start parsing with lvalues for
                       ":let" or ":for". Common flag sets:
                     • "m" to parse like for `":echo"`.
                     • "E" to parse like for `"<C-r>="`.
                     • empty string for ":call".
                     • "lm" to parse for ":let".
      • {highlight}  If true, return value will also include "highlight" key
                     containing array of 4-tuples (arrays) (Integer, Integer,
                     Integer, String), where first three numbers define the
                     highlighted region and represent line, starting column
                     and ending column (latter exclusive: one should highlight
                     region [start_col, end_col)).

    Return: ~
        • AST: top-level dict with these keys:
          • "error": Dict with error, present only if parser saw some error.
            Contains the following keys:
            • "message": String, error message in printf format, translated.
              Must contain exactly one "%.*s".
            • "arg": String, error message argument.
          • "len": Amount of bytes successfully parsed. With flags equal to ""
            that should be equal to the length of expr string. ("Successfully
            parsed" here means "participated in AST creation", not "till the
            first error".)
          • "ast": AST, either nil or a dict with these keys:
            • "type": node type, one of the value names from ExprASTNodeType
              stringified without "kExprNode" prefix.
            • "start": a pair `[line, column]` describing where node is
              "started" where "line" is always 0 (will not be 0 if you will be
              using this API on e.g. ":let", but that is not present yet).
              Both elements are Integers.
            • "len": “length” of the node. This and "start" are there for
              debugging purposes primary (debugging parser and providing debug
              information).
            • "children": a list of nodes described in top/"ast". There always
              is zero, one or two children, key will not be present if node
              has no children. Maximum number of children may be found in
              node_maxchildren array.
        • Local values (present only for certain nodes):
          • "scope": a single Integer, specifies scope for "Option" and
            "PlainIdentifier" nodes. For "Option" it is one of ExprOptScope
            values, for "PlainIdentifier" it is one of ExprVarScope values.
          • "ident": identifier (without scope, if any), present for "Option",
            "PlainIdentifier", "PlainKey" and "Environment" nodes.
          • "name": Integer, register name (one character) or -1. Only present
            for "Register" nodes.
          • "cmp_type": String, comparison type, one of the value names from
            ExprComparisonType, stringified without "kExprCmp" prefix. Only
            present for "Comparison" nodes.
          • "ccs_strategy": String, case comparison strategy, one of the value
            names from ExprCaseCompareStrategy, stringified without
            "kCCStrategy" prefix. Only present for "Comparison" nodes.
          • "augmentation": String, augmentation type for "Assignment" nodes.
            Is either an empty string, "Add", "Subtract" or "Concat" for "=",
            "+=", "-=" or ".=" respectively.
          • "invert": Boolean, true if result of comparison needs to be
            inverted. Only present for "Comparison" nodes.
          • "ivalue": Integer, integer value for "Integer" nodes.
          • "fvalue": Float, floating-point value for "Float" nodes.
          • "svalue": String, value for "SingleQuotedString" and
            "DoubleQuotedString"

Title: Detailed Explanation of nvim_parse_expression Return Values
Summary
This section provides a detailed explanation of the return values of the `nvim_parse_expression` function. It describes the structure of the returned dictionary, including the 'error', 'len', and 'ast' keys. The 'ast' key contains the abstract syntax tree, with information on node types, start position, length, and children. It also details local values that may be present for certain nodes, such as scope, identifier, register name, comparison type, case comparison strategy, augmentation type, and various value types (integer, float, string).