Skip to content
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

Decorators highlighting in python #52

Open
sivakov512 opened this issue Oct 12, 2017 · 9 comments
Open

Decorators highlighting in python #52

sivakov512 opened this issue Oct 12, 2017 · 9 comments

Comments

@sivakov512
Copy link

sivakov512 commented Oct 12, 2017

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)

image
image

@arcticicestudio
Copy link
Contributor

arcticicestudio commented Oct 12, 2017

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.

@egnha
Copy link

egnha commented Oct 1, 2018

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

screen shot 2018-10-01 at 12 26 18

@arcticicestudio
Copy link
Contributor

arcticicestudio commented Oct 1, 2018

@egnha Thanks for your explanation and examples, this looks like a really promising solution 🚀
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 😄 (and you can get a swaggy t-shirt 👕 as recognition for free 😆 )

@egnha
Copy link

egnha commented Oct 1, 2018

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

@arcticicestudio
Copy link
Contributor

@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 😄

@egnha
Copy link

egnha commented Oct 17, 2018

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

@egnha
Copy link

egnha commented Nov 16, 2018

@arcticicestudio, unfortunately, I won't have time to submit a PR. Sorry.

@arcticicestudio
Copy link
Contributor

@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.

@svengreb
Copy link
Member

svengreb commented Mar 2, 2025

Thank you for your patience! 🙏🏼
It's been a while since I had free time to focus more on Nord, and my open source projects in general, and invest time in this issue due to work-life balance. Please keep in mind that maintainers must maintain (pun intended 😁) balance for their open source work and life to avoid burnouts so this gap in time has nothing to do with you or your contribution.

I recently published the first "Northern Post — The state and roadmap of Nord" announcement which includes all details about the plans and future of the Nord project, including the goal of catching up with the backlog. This issue is part of the backlog and therefore I want to triage and process it to get one step closer to a "clean state". Read the announcement about reaching the "clean" contribution triage state in Nord's discussions for more details about the goal.

Therefore it has been added for triage in the central and single-source-of-truth project board that is also described in more detail in the roadmap announcement.


@sivakov512 Thanks again for your contribution 🚀
The pull request has been added for triage to be scheduled for the next iterations!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: triage
Development

No branches or pull requests

4 participants