neovim / tree-sitter-vimdoc

Tree-sitter parser for Vim help files
Apache License 2.0
103 stars 13 forks source link

parse error: options.txt #51

Closed jdhao closed 1 year ago

jdhao commented 2 years ago

Found tree-sitter-vimdoc parse error at: https://neovim.io/doc/user/options.html

Context:

    to check what is following.  E.g. for Javascript, if a function is
    defined with "func_name = function(args)": >
        ^\s*\ze\i\+\s*=\s*function(
<   If the function is defined with "func_name : function() {...": >
            ^\s*\ze\i\+\s*[:]\s*(*function\s*(
<   When using the ":set" command, you need to double the backslashes!
    To avoid that use `:let` with a single quote string: >

The 3rd code block is not rendered correctly as code block.

justinmk commented 2 years ago

The 3rd code block is not rendered correctly as code block.

The unclosed { causes an error. Because {...} can contain spaces. For authoring Vim help, if syntax like {, *, and | are to mean anything at all (and give useful errors), then sometimes errors really need to be errors :)

So the fix here is to fix this help section, by changing the quotes to backticks. Alternatively, we could introduce a (quote) form (or specify that as a (word), but wouldn't handle multiline quotes) that captures things with quotes "...".