mistricky / codesnap.nvim

📸 Snapshot plugin with rich features that can make pretty code snapshots for Neovim
MIT License
473 stars 15 forks source link

Treesitter for ease of theming languages #71

Open vinniefranco opened 2 months ago

vinniefranco commented 2 months ago

Hello!

Awesome project! I'm wondering if we could remove some build steps, reduce deps and leverage some of the features that exist in most peoples nvim setups.

For example: https://tree-sitter.github.io/tree-sitter/syntax-highlighting have you considered treesitter for handling the syntax highlighting duties?

mistricky commented 2 months ago

Hi there, thx for your advice.

The Syntax highlighting is implemented by syntect, AFAIUI the tree-sitter is a lower-level lib compared to syntect. For generating an image, need to calculate the color byte vector of the image, would there be a significant amount of work involved in using tree-sitter than using syntect?

aegonz commented 2 months ago

I am not sure if this is related but while testing the latest change for Dockerfile/Pipfile support the syntax highlight only works if you select from the top of the file not in the middle of the file on a random line

vinniefranco commented 2 months ago

image

@mistricky I was thinking that treesitter is already there. It knows when it's an expression/keyword/etc regardless of file type (assuming you have the grammar installed) or where you select from a file. All the highlighting definition work has been done: https://github.com/nvim-treesitter/nvim-treesitter/blob/master/queries/forth/highlights.scm

Additionally, python+rust+lua+linked libs+shell scripts might be hurt your portability/plugin adoption...

Anyways, while I'm not aware of the LOE for tearing out syntect/Rust. It might be a boon for formatting/theming work. As ts could provide the heavy lifting and, if needed, nvim's lua API could provide the tab rules and file type.

Food for thought :)