Open sivakov512 opened 7 years ago
I've tried to add the py-decorator-face
face, but it seems to have no effect because the decorator inherits from the font-lock-type-face
.
@sivakov512: You can "fontify" decorators by adding a regular expression for them to the keyword list for font locking. (This has nothing to do with Nord theme, specifically, cf. docs on font locking.)
For example, try adding the following to your Emacs config:
(add-hook 'python-mode-hook
(lambda ()
(font-lock-add-keywords
nil
'(("\\(^@[^(]*\\)" 1 'font-lock-preprocessor-face)))))
With an optional customization of the preprocessor face
(set-face-attribute 'font-lock-preprocessor-face nil
:weight 'normal
:foreground "#B48EAD")
you should get something like this (aside from further custom coloring of constant and keyword faces):
@egnha Thanks for your explanation and examples, this looks like a really promising solution :rocket:
Would you like to submit a PR for this? Nord uses nord12
for annotations/decorators if you'd like to go for it.
Also Hacktoberfest started to today, I'd really appreciate some contributions to get some things done during this month :smile: (and you can get a swaggy t-shirt :shirt: as recognition for free :laughing: )
I’d be glad to submit a PR (though I won’t be able to get around to that until the weekend). Thanks for the 👕 offer :)
@egnha Take your time, there's no time pressure. You can register on their site by simply logging in with your GitHub account (via OAuth) and as soon as you submited 5 PRs in october to any open source project on GitHub they'll send you a T-Shirt and some other swag like a certificate of participation :smile:
In the meantime, a more robust regex to identify decorators:
(add-hook 'python-mode-hook
(lambda ()
(font-lock-add-keywords
nil
'(("^[[:space:]]*\\(@[^(#[:space:]\n]*\\)" 1 'font-lock-preprocessor-face)))))
@arcticicestudio, unfortunately, I won't have time to submit a PR. Sorry.
@egnha No problem, I'm also busy with other urgent tasks and projects, but I'll try to test and put your code into a PR as soon as there is some time.
What about the highlighting of Python decorators with color different from classes and methods? For example screenshots from Emacs (first) and Visual Studio Code (second)