patstockwell / vim-monokai-tasty

VIM Colour scheme
390 stars 51 forks source link

Treat Python triple quotes as comments not string #40

Closed andrewjlock closed 2 years ago

andrewjlock commented 2 years ago

Love this theme, and use it a lot for Python code.

One issue I've found is that it treats commenting bound by triple quotations (""" or ''') as strings, highlighting in yellow rather than grey, which is widely used for multi-line docstrings. I've checked with Sublime Text, and it treats triple quotations as standard comment colour.

Would it possible to replace the Sublime Text theme and display triple quotations in Python as comment formatting?

Thanks!

patstockwell commented 2 years ago

Hi @andrewjlock, sorry for my very late reply on this one. I've had a look at triple quoted comments in Python and unfortunately, the built in syntax file for python doesn't parse that part of the text as a comment. Highlighting can only be applied to syntax groups, and there isn't a syntax group that I can target to highlight triple quoted text. If you find any other colorschemes that do appear to highlight triple quoted text as a comment, please let me know and I'll work out how they manage it! Thanks for reaching out and taking the time to write.

polirritmico commented 1 year ago

Hi. In nvim using treesitter to obtain the groups with :TSCaptureUnderCursor from nvim-treesitter/playground is relatively straightforward. In this particular case, this should do the trick:

" In colors/vim-monokai-tasty.vim
hi link @string.documentation.python Comment

or

call Highlight('@string.documentation.python', {'fg': s:grey, 'bg': s:none, 'style': s:italic })