tree-sitter-python icon indicating copy to clipboard operation
tree-sitter-python copied to clipboard

Regular expressions in raw strings aren't formatted

Open ambv opened this issue 7 years ago • 2 comments
trafficstars

Example formatted by MagicPython:

ambv avatar Apr 12 '18 21:04 ambv

/cc @queerviolet - Now we can handle this by injecting tree-sitter-regex into raw strings. We'll have to identify the strings' raw-ness from the text, by checking if the string starts with an r, fr, or br.

I'm not sure how specific we want to be about our injection. Maybe we just start by doing it in all raw strings?

maxbrunsfeld avatar Aug 07 '18 22:08 maxbrunsfeld

You can write a query like https://github.com/nvim-treesitter/nvim-treesitter/blob/9e147d23566f58f2da6682242ffb89cb0de426b5/queries/python/injections.scm#L1-L6 to match nodes that contain a regex

stsewd avatar Jul 26 '21 19:07 stsewd