Skip to content

Provide keyword analysis for keywords in the ns form #1609

Closed

Description

@PEZ

To upvote this issue, give it a thumbs up. See this list for the most upvoted issues.

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

Keywords in the ns form doesn't get the same treatment as other keywords from the analysis. This results in clojure-lsp being unable to apply things like semantic tokens to these, making them render differently in clients that have semantic tokens enabled.

Here are two screenshots from Calva, showing the difference:

image (1)

image (2)

Describe the solution you'd like

If clj-kondo provides the keyword analysis for the ns form, that's be great!

Describe alternatives you've considered / Additional context

Semantic tokens for keywords help the users since more themes will highlight them in a special way. Previously Calva solved this by giving them a non-standard TextMate grammar scope, but that causes other problems, so we have changed to use proper TM grammar scopes for keywords.

Activity

  1. PEZ commented on Mar 9, 2022

    @PEZ
    ContributorAuthor

    Having a look at test/clj_kondo/analysis_test.clj I realize there are some related questions that should be sorted out.

    top level require

    (require '[bar :as b]) :kw :x/xkwa ::x/xkwb ::fookwa :foo/fookwb ::foo/fookwc :bar/barkwa ::b/barkwb ::bar/barkwc

    :as is not analyzed as a keyword. It probably should?

    destructuring keywords

    (let [{::keys [a :b]
           ::b/keys [c :d]
           :bar/keys [e :f]
           :keys [g :h ::i :foo/j :bar/k ::b/l ::bar/m :x/n ::y/o foo/j]
           p :p q ::q r ::b/r s :bar/s t :x/t} {}])

    Kaywords in the binding boxes are analysed as variables. Maybe they should... I didn't even know you could do this.

  2. borkdude commented on Mar 9, 2022

    @borkdude
    Member

    We didn't analyze those keywords since keyword analysis initially was more about being able to consistently rename (user-defined) keywords. Renaming :require in an ns form almost never makes sense. But I'm open to do that.

  3. borkdude commented on Mar 9, 2022

    @borkdude
    Member

    I didn't even know you could do this.

    Yes, this is supported by Clojure, although maybe not idiomatic, lots of people use it.

  4. ericdallo commented on Apr 8, 2022

    @ericdallo
    Member

    @PEZ fixed on clj-kondo and clojure-lsp!

  5. PEZ commented on Apr 8, 2022

    @PEZ
    ContributorAuthor

    Thanks!

  6. added a commit that references this issue on May 21, 2024
    9495193
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions