Skip to content

Neovim: Update tree-sitter support for CSS #289

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions after/plugin/dracula.vim
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ if exists('g:loaded_nvim_treesitter')
" HTML and JSX tag attributes. By default, this group is linked to TSProperty,
" which in turn links to Identifer (white).
hi! link TSTagAttribute DraculaGreenItalic
" CSS
hi! link TSPunctDelimiter DraculaPink
hi! link TSType DraculaPink
hi! link TSProperty DraculaCyan
hi! link TSError DraculaOrange
Comment on lines +101 to +104
Copy link
Member

@dsifford dsifford Aug 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this is going to be the proper way to go about this. TSType, for example, is the token used for all types, in every language. That for the most part should be DraculaCyan..

The way we need to go about this is be specific to these changes just for css languages. There's a way to target those languages specifically, but you'll have to look into the docs for the tree sitter plugin to find that out because I can't recall off the top of my head how to do that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seconded

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yea, you might make some queries for that.

For example, create queries/css/highlights.scm in the plugin's directory like this:

; inherits: css

[
 "#"
 ","
 "."
 ":"
 "::"
 ";"
 ] @keyword

(class_name) @type
(property_name) @type
(nesting_selector) @keyword

This will partially do the thing you did w/out linking any highlight groups 👽
image

p.s. you might find helpful :TSPlaygroundToggle, :TSNodeUnderCursor and TSHighlightCapturesUnderCursor commands of the nvim-treesitter/playground addon on your way.

endif
" }}}
" nvim-cmp: {{{
Expand Down