clojure-lsp / clojure-lsp/clojure-lsp

Enhance CodeLens to show defs that are private and external to the namespace.

Open
#508 8 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Clojure
Stars
1.3k
Forks
180
Avg merge
3d 18h
Merged PRs (30d)
5

Description

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

It's often quite difficult, in large namespaces, to know which functions (for example) are being used outside of that namespace, in other namespaces. Right now, with the help of clj-kondo, clojure-lsp would show me (as a codeLens feature), something like this:

![image](https://user-images.githubusercontent.com/427150/128516755-e4c7133a-55d1-47bb-9c5f-e0f27db0e5bd.png)

What is not clear to me, is whether that function is being used only within the scope of the namespace, or is really being used elsewhere (maybe both, once locally and once externally). Here is another example:

![image](https://user-images.githubusercontent.com/427150/128516935-322d9720-1328-433f-9669-41db6c2efdf2.png)

There are 9 references to that function. This function is only ever used in that namespace. The quickest way (at the moment), is to highlight references, i.e,

![image](https://user-images.githubusercontent.com/427150/128517381-0ec0ba33-c366-41c5-9b20-3548621ff4bc.png)

It would be far nicer if instead codeLens could show me as I'm browsing through the file.

**Describe the solution you'd like**

I think a nice addition to codeLens would be the ability to show whether any defs/defns are private to the namespace and thus allow for a quick and easy way to mark the defs/defns private (maybe a further enhancement migth be for a codeAction to do it all for me - but for now, doing that manually is okay).

It might do something like:

`(defn add-ontology-entity-name > 9 private references)`

or, in the case of a mix:

`(defn add-ontology-entity-name > 6 private references, 3 external references)`

or, in the case of them all being external:

`(defn add-ontology-entity-name > 9 external references)`

Whether or not the wording should change to be something other than `private` or `external` is fine with me (e.g., 9 local references; 5 local references, 4 external references etc...)

**Describe alternatives you've considered**

I can get the information from using `(coc-references)`, but it's something I have to do, and not that friendly, in the sense that it would be nicer if the inline reference information could be shown against the function.

Thank you for your consideration.

-=david=-

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.