Skip to content
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

codeblock adjacent to list item is not recognized #118

Open
echasnovski opened this issue Jan 23, 2024 · 5 comments
Open

codeblock adjacent to list item is not recognized #118

echasnovski opened this issue Jan 23, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@echasnovski
Copy link
Member

Example:

- Line starts with dash:
>
 This is not recognized as code block
<

This seems to be a known problem, but there is no issue to track it and for users to consult with.

I tried to fix this, but the assumption that code block is not contiguous to list item seems to be too much entangled in the grammar itself. So looks like it would at least require serious refactor if at all possible.

The current workaround is to have a blank link after list item text block (contiguous lines without blank lines with first starting with list prefix). So this will work:

- Line starts with dash:

>
 This is recognized as code block
<
@justinmk justinmk added the bug Something isn't working label Jan 23, 2024
@justinmk
Copy link
Member

justinmk commented Jan 23, 2024

Looks like Vim's help syntax "supports" this (but it has no concept of list-items, which is a major feature of tree-sitter-vimdoc).

The general idea in tree-sitter-vimdoc is that "blocks" are separated by a blank line. In the given example, the > immediately follows the list-item thus it would be part of the list-item (if this bug didn't exist), not a separate block. But it looks like you expect it to be a separate block?

Note that this does work (in both Vim-syntax and tree-sitter-vimdoc):

- Line starts with dash: >
  code line1
  code line2
<

@echasnovski
Copy link
Member Author

But it looks like you expect it to be a separate block?

I would expect that codeblock formatting would take precedence over list items, yes. Mostly because it is supported in Vim's help and in Markdown.

Note that this does work (in both Vim-syntax and tree-sitter-vimdoc):

Yes, this is a better solution as it allows to add only single blank line at the top of code block (similar to the one in the initial comment). I thought I tried it before and it did not work. Apparently, missed something.

This feels like a decent workaround, though. Now the original example only looks like inconsistency and not like a big issue.

@justinmk justinmk changed the title Code block is not recognized inside list item codeblock adjacent to list item is not recognized Jan 23, 2024
echasnovski added a commit to echasnovski/mini.cursorword that referenced this issue Jan 29, 2024
echasnovski added a commit to echasnovski/mini.indentscope that referenced this issue Jan 29, 2024
echasnovski added a commit to echasnovski/mini.surround that referenced this issue Jan 29, 2024
@clason
Copy link
Member

clason commented Jun 9, 2024

Related: ft_sql.txt has stuff like

These are maps which use populate the completion list using Vim's syntax
highlighting rules. >
    <C-C>a
<       - Displays all SQL syntax items. >

(note the inline list item) that is not recognized as codeblock.

I seriously think that we need to significantly tighten up the spec, write the parser for that and only that, and fix the bundled help files once and for all (and make clear to plugins that if they want to have proper rendering in Neovim, they have to follow suit).

@justinmk
Copy link
Member

justinmk commented Jun 9, 2024

tighten up the spec

meaning that the sample you gave would not be supported? what would the acceptable forms look like?

@clason
Copy link
Member

clason commented Jun 10, 2024

We tend to put such descriptions in comments in the codeblock itself. We could also rewrite this as a proper list or table (which seems more reasonable):

- <C-C>a   Displays all SQL syntax items

(I don't see the point of using a codeblock here.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants