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

Inspector: (feature request) Syntax highlighting for the java methods #3546

Closed
anonimitoraf opened this issue Oct 20, 2023 · 5 comments · Fixed by #3547
Closed

Inspector: (feature request) Syntax highlighting for the java methods #3546

anonimitoraf opened this issue Oct 20, 2023 · 5 comments · Fixed by #3547

Comments

@anonimitoraf
Copy link

First of all, I want to say that the CIDER inspector is awesome! Can't live without it.

Is your feature request related to a problem? Please describe.

I find it hard to grok the methods list when they are long, have a lot of arguments and/or there are a lot of them.

For example:

image

Describe the solution you'd like

It would be nice to have Java syntax highlighting for the method names, arguments, etc.

Describe alternatives you've considered

I currently have a very (very) hacky solution that adds highlighting via overlays

(defvar ++ov-cider-inspector-keywords)
(defvar ++ov-cider-inspector-method-names)
(defvar ++ov-cider-inspector-method-param-lists)
(defun ++ov-cider-inspector ()
  (ov-clear)
  (let ((case-fold-search nil))
    (setq ++ov-cider-inspector-keywords (ov-regexp "^public\\|private\\|protected\\|final\\|native\\|static$")
     ++ov-cider-inspector-method-names (ov-regexp "\\([a-zA-Z0-9.$]\\)+(")
      ++ov-cider-inspector-method-param-lists (ov-regexp "(\\([][<>a-zA-Z0-9.$,]*\\))?")))
  (ov-set ++ov-cider-inspector-keywords 'face `(:foreground ,(doom-color 'magenta)))
  (ov-set ++ov-cider-inspector-method-names 'face `(:foreground ,(doom-color 'red)))
  (ov-set ++ov-cider-inspector-method-param-lists 'face `(:foreground "white")))

but even this gives me something very basic:

image
@vemv
Copy link
Member

vemv commented Oct 21, 2023

This is the snippet I use for similar use cases:

(defun vemv/to-java-string (s)
  "Returns a propertized string with Java syntax coloring"
  (with-temp-buffer
    (insert s)
    (java-mode)
    (font-lock-ensure)
    (buffer-string)))

Feel free to give it a try.

Besides, I noticed in your screenshot another point of improvement. Created clojure-emacs/orchard#198

@anonimitoraf
Copy link
Author

Thanks for sharing. What does your workflow look like with that snippet?

@vemv
Copy link
Member

vemv commented Oct 21, 2023

Mmm, if you don't have it easy to plug that function somewhere, let's just wait till a PR lands.

Should be soon enough.

@anonimitoraf
Copy link
Author

Awesome, thanks!

@vemv
Copy link
Member

vemv commented Oct 23, 2023

Cheers, the Melpa snapshot should be available later tonight.

We will also cut a stable release with other Inspector goodies 🔎

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