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

Ignore un-indented preprocessing commands in C/C++ #142

Open
shogo-sugihara opened this issue Sep 2, 2024 · 3 comments
Open

Ignore un-indented preprocessing commands in C/C++ #142

shogo-sugihara opened this issue Sep 2, 2024 · 3 comments

Comments

@shogo-sugihara
Copy link

I'm really grateful for Bookman. Thank you for the great plugin !
I have one problem.

I'm using your tool in C/C++ language.
If the #if/#endif codes are at the beginning of a line,, all block enclosures are left-justified.
Is it possible to ignore those un-indented preprocessing commands beginning with # and have The left edge of the enclosure start at the indent position?

image

Sorry if there's a similar comment before, I missed it.

@shogo-sugihara
Copy link
Author

It would be great if commented out lines were included in the ignore.

image

@leodevbro
Copy link
Owner

Thanks for the feedback, such advanced cases is also interesting for me. Right now Blockman has basic detection of code blocks. When I have time, I'm going to try to implement advanced parsing/tokenization of many languages, so Blockman maybe will be able to manipulate rendering based on advanced logic chosen by user.

The main problem is that it is not an easy thing to implement advanced parsing/tokenization, because VS Code does not expose it's native parsed/tokenized AST, so I have to find third party libraries, and they are not many, especially there are probably only one or two high quality parser libraries which work in JS environment and support parsing many languages, and they have their technical difficulties and performance issues, so I need to do some experiments to make sure they will work fine with Blockman.

So far, I have found shiki and tree-sitter (or web-tree-sitter), and I hope I will be able to do some experiments with them soon.

@shogo-sugihara
Copy link
Author

shogo-sugihara commented Sep 5, 2024

Thank you for your response and consideration !

Considering the cost-effectiveness, switching the syntax analysis parser seems like a big deal.
You may end up with new many problems after switching.

I checked the scope of the #if/#endif tokens
image

If the Blockman can obtain the token's scope information, it can exclude those lines to include the tokens with the "punctuation.definition.directive.c" and "keyword.control.directive.conditional.c" scope from the enclosure process.

I will have to wait for the Visual studio code extension API to be updated.

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

No branches or pull requests

2 participants