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

How to enable colors in typescript #32

Closed
it6 opened this issue Mar 29, 2017 · 7 comments
Closed

How to enable colors in typescript #32

it6 opened this issue Mar 29, 2017 · 7 comments

Comments

@it6
Copy link

it6 commented Mar 29, 2017

Hi, in js2-mode I see defface variables

(defface js2-function-call
  '((t :inherit default))
  "Face used to highlight function name in calls."
  :group 'js2-mode)

and in my themes file I added
(js2-function-call (:foreground ,green))
to make the function call green.

Is there any similar way to add my theme specific colors for typescript. Thanks.

@it6 it6 changed the title How to enable colors in my typescript How to enable colors in typescript Mar 29, 2017
@josteink
Copy link
Member

Currently we just re-use the default Emacs faces for pretty much everything. You can see it here:

https://github.com/ananthakumaran/typescript.el/blob/master/typescript-mode.el#L306-L317

I'm sure you'll find similar definitions if you scroll through the code.

So in order to get the functionality you want, typescript.el will need some patches which:

  1. creates mode-specific defface-statements with appropriate defaults.
  2. replaces hard-coded usage of Emacs default-faces with the face-types created in 1.

Nobody is actively working towards this, but if you feel like putting in some work, PRs are very much welcome.

@it6
Copy link
Author

it6 commented Apr 6, 2017

I can help with this effort but not sure where to start can you guide me @josteink.

@josteink
Copy link
Member

josteink commented Apr 6, 2017

Great! Any help and all contributions are very much appreciated!

Basically you need to do a few things:

  • Identify all the faces currently used by typescript-mode (i.e. font-lock-function-name-face). See my previous comment for an example of such usage.
  • Create corresponding mode-specific face using defface (i.e. typescript-function-name-face), with appropriate defaults matching the original Emacs-faces. I tried to locate some examples for this, and it seems js2-mode does exactly this. Take a peek at its code to see how it works.
  • Rewire all the existing code which makes use of pre-defined Emacs font-lock faces to use your newly defined mode-specific custom faces.

If you're new to this, it'll probably take a bit of time and effort, but all in all it shouldn't at any point involve anything fundamentally complex.

@it6
Copy link
Author

it6 commented Apr 12, 2017

Instead of reinventing the wheel, is there any way we can port the official syntax highlights from Typescript to emacs.

https://github.com/Microsoft/TypeScript-TmLanguage

@josteink
Copy link
Member

That would be awesome. But given that we mostly have something which works right now though, I'm not going to put in the effort myself though.

If anyone gets it done though, I would be all for it.

This was referenced Jul 29, 2018
@josteink
Copy link
Member

josteink commented Aug 1, 2018

This comment here is relevant to this issue: #78 (comment)

Basically there seems there is a generalized solution to this problem which can be applied to all major-modes, instead of having every major-mode reimplement the same font-lock inheritance layering.

As such, I'm inclined to close this issue as "won't fix" unless anyone can convince me otherwise.

@josteink
Copy link
Member

josteink commented Aug 1, 2018

Based on closing #78, I've decided to close this issue too as "won't fix".

Disagreement is OK, but then I'll need some really convincing arguments :)

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

Successfully merging a pull request may close this issue.

2 participants