lsp 2024-08-13

Idea for a code action: copy symbol with namespace

(ns my.app)
(defn f [x] 3)
Place cursor on f, run "copy symbol with namespace", then my.app/f is on the clipboard. Not sure if this is possible from inside an LSP process, perhaps somebody can correct me if it won't work? Use case: "I'm looking at a symbol and want to discuss the code with other people"

2

it's possible from java process, not sure if graalvm supports it, even so looks like a quite specific code action

👍 1

This seems like a thing that any editor could support without lsp, copy the current token to the clipboard...

I think no editor will know/have a logic that copying f will result in copying

now I understand your question, my bad

I use the repl for this (symbol #'f)

👍 1

yeah, that's something more suitable for REPL

could also shell out to pbcopy for the clipboard part or build a variant of cider-eval that copies the result to the clipboard (or just copy the normal eval output 🙃 )

I mean, it's something clojure-lsp/kondo could easily do, but it's the copy/paste thing that is gnarly in the JVM ;)

or just hand-write the symbol... ;)

or use the sharp quote. Nice thing about the var is autocompletion and errors on typos though

👍 1

I think that's something that the editor should handle. You could easily write an Emacs command that runs (symbol (var ,,,)) on the current form and put it on the kill ring / native clipboard

maybe there's an LSP command to return the fully qualified symbol?