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

Is it possible to highlight function docStrings? #28

Closed
scotts777 opened this issue Nov 4, 2022 · 2 comments
Closed

Is it possible to highlight function docStrings? #28

scotts777 opened this issue Nov 4, 2022 · 2 comments
Labels
highlighting Affects syntax highlighting

Comments

@scotts777
Copy link

Was wondering if it is possible to target the doc strings that are in a defn form separately from normal Strings?
(defn my-function "This is the doc string I am talking about. It would be great if this can be highlighted differently from regular Strings" [arg 1 arg2] ...
I probably need a syntax region, but I am lost with the syntax file format. Thanks

@axvr
Copy link
Member

axvr commented Nov 8, 2022

Hi @scotts777,

It is technically possible, however I wouldn't say it is worth the pain of adding it. There are several reasons I say this:

  1. For consistency, the same syntax highlighting of doc-strings should happen for def, defonce, defn, defn-, defmacro, defmulti, defprotocol, defrecord, defstruct, deftype and definline. Some of these have different rules for where doc-strings appear.
  2. The regular expressions to make it work would be very complex and difficult to write/maintain. Just differentiating between these two things with regular expressions, is far more difficult than you would initially think:
    (def foo
      "regular string")
    
    (def bar
      "doc-string"
      nil)
  3. For yet more consistency, I think there would need to be a way to configure the same highlighting on custom macros such as defrule in Clara rules. I have no idea how this could be accomplished.
  4. Doc-strings are actually just strings.

As far as I'm aware, for these reasons (and maybe others), no other editor supports this. However, you can of course add the syntax highlight rules for it to your personal Vim config overriding our defaults. Unfortunately I'm not entirely sure how you would go about writing those syntax rules.

@axvr axvr closed this as completed Nov 8, 2022
@scotts777
Copy link
Author

Yes, that makes good sense.

@axvr axvr closed this as not planned Won't fix, can't repro, duplicate, stale Nov 8, 2022
@axvr axvr added the highlighting Affects syntax highlighting label Jun 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
highlighting Affects syntax highlighting
Projects
None yet
Development

No branches or pull requests

2 participants