reddit / emacs
how can i get better syntax highlighting? because this is...
wolfakix · 2022-04-27 12:10
Scary_Lion5299 · 2022-04-27 12:13
try treesitter
wolfakix · 2022-04-27 12:18
i cant get it to highlight the syntax
Scary_Lion5299 · 2022-04-27 12:19
Did you turn on treesitter-mode? (I'm asking this coz I forgot to the first time I used it)
wolfakix · 2022-04-27 12:21
i did, it said that i have to install tree-sitter-langs, i did that too and when i enable it nothing happens (i installed them via package-installed, i didnt put anything on my config) i use doom emacs
Scary_Lion5299 · 2022-04-27 12:23
Did you turn on treesitter-hl-mode?
wolfakix · 2022-04-27 12:25
no
Scary_Lion5299 · 2022-04-27 12:26
turn it on and then see if it works.
TheDamnGondolaMan · 2022-04-27 12:26
Which python mode package are you using? Built-in `python` or `python-mode`?
wolfakix · 2022-04-27 12:32
yep, it now works! thank you!
Scary_Lion5299 · 2022-04-27 12:33
Your welcome!
wolfakix · 2022-04-27 12:33
but how can i enable this to run on all files at startup?
[deleted] · 2022-04-27 12:39
[deleted]
wolfakix · 2022-04-27 12:40
built in
TheDamnGondolaMan · 2022-04-27 12:46
I don't know if this will make a difference, but perhaps try `python-mode`. I've also had a good experience with `elpy` but it conflicted somehow with some other package I had and it started freezing things up.
wolfakix · 2022-04-27 12:50
nope, no difference at all, but tree-sitter makes a HUGE difference, but i dont know how to enable tree-sitter-hl at startup so it displays on all files
klikklakvege · 2022-04-27 12:51
Offtopic:
Is this herbstluftwm what you have there? With 18 desktops?
TheDamnGondolaMan · 2022-04-27 12:54
(add-hook 'python-mode-hook #'tree-sitter-hl)
I'm not yet familiar with tree-sitter, if it's language-agnostic, you might even replace `python-mode-hook` with `prog-mode-hook`.
wolfakix · 2022-04-27 12:54
That is yabai running on macOS
SafeSweet715 · 2022-04-27 13:01
`(global-tree-sitter-mode)`
`(add-hook 'tree-sitter-after-on 'tree-sitter-hl-mode)`
try to add this codes to your config file.
Scary_Lion5299 · 2022-04-27 13:01
You don't really want that because some buffers like dashboard and emacs-lisp aren't supported and it will throw an error. Just add treesitter-hl-mode to the hook of the language you want to use it for and it will be fine.
wolfakix · 2022-04-27 13:05
oh ok, also, when i install tree-sitter while i am running emacs with the emacsdaemon it runs fine but when i stop the daemon and launch a new session the commands (tree-sitter-hl-mode) do not work and i have to reinstall them, what is the cause?
wolfakix · 2022-04-27 13:05
prog-mode-hook works the best!
TeMPOraL_PL · 2022-04-27 13:07
> because this is...
This is... what? Looks perfectly normal to me. I don't understand what you're asking.
wolfakix · 2022-04-27 13:08
this is plain
takutekato · 2022-04-27 13:14
No just `global-tree-sitter-mode` is totally fine.
It has been configured by the author to not throw errors for irrelevant buffers.
TheDamnGondolaMan · 2022-04-27 13:42
Glad to hear it!
patrick_thomson · 2022-04-27 13:56
Then use a different theme.
by_wicker · 2022-04-27 15:03
There is much more highlighting by default - you've chosen a theme that is plain, and now you're complaining that your theme is plain.
Scary_Lion5299 · 2022-04-27 15:03
But the treesitter-hl-mode will. Or at least that's what I remember happening.
Scary_Lion5299 · 2022-04-27 15:07
You'll need to add it to your config.
Gangsir · 2022-04-27 15:13
Methinks OP might not know that themes can remove some highlighting.
takutekato · 2022-04-27 15:25
Yes that's right, highlighting is currently opt-in, I just wanted to note that intentionally hooking `tree-sitter-hl-mode` to some language hooks isn't necessary. As the other comment points out, you only need this as the bare minimum as the manual suggests:
```lisp
(global-tree-sitter-mode)
(add-hook 'tree-sitter-after-on-hook #'tree-sitter-hl-mode)
```
nnreddit-user · 2022-04-27 15:45
Just putting in my requisite plug for Commercial Emacs, which gets you tree-sitter highlighting with an order of magnitude fewer moving parts.
void_linux · 2022-04-27 16:01
This is generally just how python is syntax highlighted, sure you can change the colours but if you look at vscode or any other ide that are all highlighting the same stuff, maybe in a different colours but it's all the same stuff being highlighted.
Rotatop · 2022-04-27 16:09
Having emacs + doom + tree-sitter+ tree-sitter-lang I have seen a better syntax highlight in my python code.
crawsphi · 2022-04-27 18:15
There's a globalized mode function for it, so just
(add-hook 'after-init-hook #'global-tree-sitter-mode)
or with `use-package`
…
:hook (after-init . global-tree-sitter-mode)
…
Or even just call that function during startup if you prefer.
ojuicius · 2022-04-27 20:19
/u/wolfakix could you post an updated shot with treesitter? I'm curious how much better it looks.
FrozenOnPluto · 2022-04-27 22:06
Show a realistic piece of code for one. Not much to chew on there.
Try various themes or tweak the theme you have.
Try some nice fonts too .. I have a nicely customized theme, and Consolas .. gorgeous
Also more packages help .. rainbow parens, modes to brighten or darken the active and more recent buffers (windows), number highlighting, etc
But I think you have a theme that chooses not to highlight much
Crafty-Cranberry9808 · 2022-04-27 23:13
How do you reply to a section of the question?
dpoggio · 2022-04-28 00:48
Define better, try and end the sentence. What do you expect to get?
Gilgamesh762 · 2022-04-28 03:24
Atom with Dracula 🧛♂️ theme🤫🤫
Gilgamesh762 · 2022-04-28 03:24
Atom with Dracula 🧛♂️ theme🤫🤫
TeMPOraL_PL · 2022-04-28 10:01
By copy-pasting the part I wanted to quote, and prefixing it with `>`.
For example:
`> How do you reply to a section of the question?`
Renders as:
> How do you reply to a section of the question?
See also: [Reddit commenting help](https://old.reddit.com/wiki/commenting#wiki_quotes).
Crafty-Cranberry9808 · 2022-04-28 10:02
Oo thanks!
exclaim_bot · 2022-04-28 10:02
>Oo thanks!
You're welcome!
TeMPOraL_PL · 2022-04-28 10:09
Check what's the value of `font-lock-maximum-decoration` variable in your case; try setting it to `t` and seeing if it helps.
Also, others have a good point about themes: perhaps the one you use reduces syntax highlighting?
Beyond that, it would be best if you could elaborate what kind of syntax highlighting would you like to have; perhaps provide an example from another editor?
wolfakix · 2022-04-30 22:48
(require 'tree-sitter)
(require 'tree-sitter-langs)
doesnt work for some reason, it throws me errors
Scary_Lion5299 · 2022-05-01 02:15
Try using use-package
wolfakix · 2022-05-01 15:34
yep now it works