Sublime Forum

Show number of references of a function beside its name

#1

In VSCode there’s an indication of the number of references found.

Is there something similar in sublime text with the use of a plugin?

image

0 Likes

#2

I guess only LSP could offer that, not sure if it does though…

0 Likes

#3

These things are called “code lenses”. It’s somewhat specific to VSCode. They’re possible in LSP, but you need to write custom python code around it to handle the custom responses. They are rendered as annotations in ST.

Having said that, if it’s just “find references” you’re after, there’s already a builtin find-references, and LSP also provides a find-references.

0 Likes

#4

I tried LSP and there’s no visual indicator with it.

See References is handy but it would be nice to see if a function is not used by seeing the 0 references beside it.

0 Likes

#5

Is it really that much of a time-saver though?

In any case, if you want something like that, like I mentioned the language server needs to support code lenses and you’d have to write python glue code. Looking at your screenshot, you seem to be using JS. LSP-typescript does not offer code lenses.

0 Likes

#6

Would be a little bit of a timesaver to notice any functions that are no longer used in the scripts I’m writing.

I’m writing JScript.

0 Likes

Seeking Recommendations: Identifying Python Functions/Classes with Single References for Code Refactoring
#7

There’s no langserver for JScript so it looks like it goes directly through the VSCode extension. https://microsoft.github.io/language-server-protocol/implementors/servers/

1 Like

#8

I barely remember a plugin adding such info via phantoms, but it caused text reflow and too much noise. I finally removed that as non-useful.

0 Likes

#9

Visual Studio has it.

I don’t really find it intrusive.

image

0 Likes