codesnap.nvim icon indicating copy to clipboard operation
codesnap.nvim copied to clipboard

Treesitter for ease of theming languages

Open vinniefranco opened this issue 1 year ago • 3 comments

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?

vinniefranco avatar Apr 05 '24 15:04 vinniefranco

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?

mistricky avatar Apr 05 '24 17:04 mistricky

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

aegonz avatar Apr 05 '24 17:04 aegonz

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 :)

vinniefranco avatar Apr 05 '24 20:04 vinniefranco