Skip to content

fix: argument in "vim.foo({bar})" #108

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 25, 2023
Merged

fix: argument in "vim.foo({bar})" #108

merged 3 commits into from
Jun 25, 2023

Conversation

justinmk
Copy link
Member

@justinmk justinmk commented Jun 25, 2023

(Continues #103 )

Problem:
In "vim.foo({bar})", {bar} is not recognized as (argument).

Solution:
Add more special-cases for plain (word).

Closes #102

Notes

@clason
Copy link
Member

clason commented Jun 25, 2023

There's still a parse error (but not wrong highlighting) in

  • :h v_aB (haven't tested whether that error fails the help_spec test, but that's of course what I'm worried about)

(but not in map.txt on |,| anymore 🎉 ).

@justinmk
Copy link
Member Author

There's still a parse error in :h v_aB

Looks like the { in "[count] [{" is causing an error. Could be fixed by changing the " to backticks.

@clason
Copy link
Member

clason commented Jun 25, 2023

Ah, I had assumed that the ERROR node would be rooted at the misparsed node, but you are right. This file (and map.txt) has a bunch of careless quotes that merit cleaning up.

(I have hesitated to touch upstream docs so far, but if it's open season now...)

@justinmk
Copy link
Member Author

This definitely improves things, but also causes a few errors. Will see if those can be avoided with some tweaks.

justinmk added a commit to justinmk/neovim that referenced this pull request Jun 25, 2023
Prepare for neovim/tree-sitter-vimdoc#108 which improves
`{arg}` highlighting in many common cases:

    vim.foo({bar})
    vim.foo( {bar})
    nvim_foo({bar})
    nvim_foo({bar},{baz})
    nvim_foo({bar}, {baz})
    foo[{buf}]

The tradeoff is that things like `"[{"` are flagged as parse errors.
We could avoid if we drop support for `foo[{buf}]`, but that is rather common
(see `builtin.txt`).
Problem:
In "vim.foo({bar})", {bar} is not recognized as (argument).

Solution:
Add more special-cases for plain (word).

Closes #102
justinmk added 2 commits June 26, 2023 00:10
- Dropping ")" and "]" special-cases avoids 10 (out of ~30) new errors in a full
  `gen_help_html.validate()` run.
- The /\w+\(/ special is no longer needed since "(" was added.
- Other cases appear redundant, they don't affect test results nor
  `gen_help_html.validate()` results.
@justinmk justinmk merged commit 8c0469d into master Jun 25, 2023
@justinmk justinmk deleted the argument branch June 25, 2023 22:12
justinmk added a commit to justinmk/neovim that referenced this pull request Jun 26, 2023
Prepare for neovim/tree-sitter-vimdoc#108 which improves
`{arg}` highlighting in many common cases:

    vim.foo({bar})
    vim.foo( {bar})
    nvim_foo({bar})
    nvim_foo({bar},{baz})
    nvim_foo({bar}, {baz})
    foo[{buf}]

The tradeoff is that things like `"[{"` are flagged as parse errors.
We could avoid if we drop support for `foo[{buf}]`, but that is rather common
(see `builtin.txt`).
justinmk added a commit to justinmk/neovim that referenced this pull request Jun 26, 2023
Prepare for neovim/tree-sitter-vimdoc#108 which improves
`{arg}` highlighting in many common cases:

    vim.foo({bar})
    vim.foo( {bar})
    nvim_foo({bar})
    nvim_foo({bar},{baz})
    nvim_foo({bar}, {baz})
    foo[{buf}]

The tradeoff is that things like `"[{"` are flagged as parse errors.
We could avoid if we drop support for `foo[{buf}]`, but that is rather common
(see `builtin.txt`).
justinmk added a commit to justinmk/neovim that referenced this pull request Jun 26, 2023
Prepare for neovim/tree-sitter-vimdoc#108 which improves
`{arg}` highlighting in many common cases:

    vim.foo({bar})
    vim.foo( {bar})
    nvim_foo({bar})
    nvim_foo({bar},{baz})
    nvim_foo({bar}, {baz})
    foo[{buf}]

The tradeoff is that things like `"[{"` are flagged as parse errors.
We could avoid if we drop support for `foo[{buf}]`, but that is rather common
(see `builtin.txt`).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Argument in some functions is not recognized if not preceded by whitespace
3 participants