doc: use the correct way to check comment block#1354
Open
Kaiser-Yang wants to merge 3 commits intosaghen:mainfrom
Open
doc: use the correct way to check comment block#1354Kaiser-Yang wants to merge 3 commits intosaghen:mainfrom
Kaiser-Yang wants to merge 3 commits intosaghen:mainfrom
Conversation
Using node:type() do not work as expected, sometimes, the type will go with a "chunk" or even empty string, we must iterate the node of current line to check if current line is inside a comment block. Besides, in the code, there is no `ctx` passed to the default function, just remove the parameter in the doc.
Contributor
Author
Owner
|
Sorry for the delay! I haven't gotten around to this one yet because it's quite a big recipe, to the point that I think we should include a utility function for it in the core. I'd also like to look into ways we can simplify this, if that's possible |
Collaborator
|
You can replace the large You might also consider searching for an injected local function inside_comment_block()
local ok, parser = pcall(vim.treesitter.get_parser)
if not ok or not parser then return end
local cursor = vim.api.nvim_win_get_cursor(0)
local row, col = cursor[1] - 1, cursor[2]
return parser:language_for_range({ row, col, row, col }):lang()
endthought this only works for languages whose queries support |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Using node:type() do not work as expected, sometimes, the type will go with a "chunk" or even empty string, we must iterate the node of current line to check if current line is inside a comment block. Besides, in the code, there is no
ctxpassed to the default function, just remove the parameter in the doc.