Option for CODEX to ignore certain comments (or code)#21
Draft
clotodex wants to merge 1 commit intotom-doerr:mainfrom
Draft
Option for CODEX to ignore certain comments (or code)#21clotodex wants to merge 1 commit intotom-doerr:mainfrom
clotodex wants to merge 1 commit intotom-doerr:mainfrom
Conversation
Author
|
After a discussion with @tom-doerr I will take an opinionated approach to this implementation
|
Author
|
Thoughts to tree-sitter (might give performance hit - dont know) def search_comments():
# Get the buffer's content as a string
buffer_content = vim.current.buffer[:]
# Get the tree-sitter parser for the buffer's language
language = vim.eval("tree_sitter_language#get_parser().language")
parser = vim.eval("tree_sitter_language#get_parser().parser")
# Parse the buffer's content
tree = parser.parse(buffer_content)
# Query the tree for comment nodes
comments = tree.root.query("//comment")
# Print the line number and text content of each comment node
for comment in comments:
start_byte = comment.start_byte
end_byte = comment.end_byte
comment_text = buffer_content[start_byte:end_byte]
line_number = buffer_content.count('\n', 0, start_byte) + 1
print(f"Line {line_number}: {comment_text}")Checking if installed: if vim.eval("exists('g:loaded_tree_sitter')") == '1':
# Tree-sitter is installed
else:
# Tree-sitter is not installed |
Owner
|
Can the existing code already be merged to the project? It's still displayed for me as a draft |
Author
In theory it is ready to merge, however I did not even test it yet - If you test it, feel free to merge. Sadly I don't have much time right now and only will get to it in the upcoming weeks. |
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.
I took a stab at implementing this.
How it works:
# codex-ignorewill ignore this and the next line# codex-on/offwill toggle and ignore everything inbetweenskip_list, currentlytodoandfixme, will be skippedA few open questions:
skip_listadjustable, should it be a vim variable or part of the function, or do we need it at all?#codex-ignore [n]take an optionalnparameter to skip not just the next, but the nextnlines#, is there a way to get comments language-independant or is there a smarter way to parse thisFeel free to check it out, add your comments and thoughts and then let's go from there.