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

[syntax highlighting] functions highlighted as vars #2953

Closed
andreyorst opened this issue Dec 23, 2020 · 5 comments
Closed

[syntax highlighting] functions highlighted as vars #2953

andreyorst opened this issue Dec 23, 2020 · 5 comments
Labels

Comments

@andreyorst
Copy link
Contributor

I've disabled function highlighting, to bring color intensity a bit down by changing cider-font-lock-dynamically.
By default it is set to this:

'(macro core function var)

And I get the usual highlighting:

image

However if I remove core and function from this setting:

(setq cider-font-lock-dynamically '(macro var))

I get the following result after I load file:

image

Expected behavior

image

Steps to reproduce the problem

  1. Download bug.zip, extract and run Emacs with provided minimal init.el:
$ unzip bug.zip
$ cd bug
$ emacs -q -l repro-init.el bug.clj
  1. Jack in: Ctrl-cAlt-jy
  2. Load bug.clj file with Ctrl-cCtrl-k

This results into the following highlighting:

image

Environment & Version information

CIDER version information

;; CIDER 1.0.0snapshot (package: 20201216.1330), nREPL 0.8.3
;; Clojure 1.10.1, Java 11.0.9.1

Emacs version

GNU Emacs 27.1 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.13) of 2020-12-23

Operating system

Fedora 33

@bbatsov bbatsov added the bug label Dec 29, 2020
@bbatsov
Copy link
Member

bbatsov commented Dec 29, 2020

So, to summarize you don't want the var highlighting, right?

Does this disappear if you do (setq cider-font-lock-dynamically '(macro))? I have a feeling the fact that pretty much everything is a var might be messing things up.

@andreyorst
Copy link
Contributor Author

So, to summarize you don't want the var highlighting, right?

Umm, not quite. I do want dynamic vars to be highlighted, it is useful feature, I just don't want functions to be highlighted as vars. Removing var from cider-font-lock-dynamically surely removes highlighting, but that's not what I'm after.

I have a feeling the fact that pretty much everything is a var might be messing things up.

If CIDER can properly highlight functions, maybe this info can be used to unhighlight those? Or when highlighting a var check if it is a function var, if this even makes sense..

@bbatsov
Copy link
Member

bbatsov commented Dec 30, 2020

Yeah, my point was that probably the bug is related to the current definition of var. I don't remember this code well anymore, but I'll review it when I can. If you'd like to take a stab at this you can start here

(defun cider--compile-font-lock-keywords (symbols-plist core-plist)

@bbatsov
Copy link
Member

bbatsov commented Dec 30, 2020

In particular:

(cond ((and do-macro (nrepl-dict-get meta "macro"))
                              (push sym macros))
                             ((and do-function (or (nrepl-dict-get meta "fn")
                                                   (nrepl-dict-get meta "arglists")))
                              (push sym functions))
                             (do-var (push sym vars)))

I guess the bug is obvious here - if the function highlighting is not enabled everything becomes a var. Depending on your perspective this can be an issue or a feature. :-) I wonder why println didn't get the same treatment, though. Anyways, it seems that's going to be relatively simple to address.

@andreyorst
Copy link
Contributor Author

wonder why println didn't get the same treatment, though

Perhaps because it is handled by core highligting separately. I've pushed a naive solution, hope this is enough

@bbatsov bbatsov closed this as completed in 6f74518 Jan 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants