Fork me on GitHub
#vim
<
2021-11-10
>
harryvederci16:11:30

Vimming Clojurians! Do you know a smooth way to copy the current namespace + currently hovered function name to the clipboard (/any register)? So if you've got:

(ns some.namespace
  (:require [...]))

(defn my-function [])
How do you put some.namespace/my-function in your clipboard, without polluting your location list etc? (I'm using neovim, so Lua / Fennel suggestions are welcome too 🙂)

nbardiuk19:11:52

I've tried in conjure :ConjureEval (symbol (var my-fuction)) evals to full name of function with namespace. Then conjure stores result of last evaluation in some register (by default c).

nbardiuk19:11:48

you can create a mapping to grab symbol name of word under cursor like this :nmap ts :execute "ConjureEval (symbol (var " . expand("<cword>") . "))"<cr>

👍 1
👏 1
harryvederci19:11:25

Dude, awesome! I opened my laptop to check if someone had answered, and a few seconds later you post the solution. Thanks!

Ngoc Khuat02:11:17

Hi @U076FM90B, great solution there. Do you have a mapping for pasting the result at the end of the evaluation? I’m currently paste it to the next line but it’ll break the code if the eval is more than 1 line.

nbardiuk07:11:13

I don't have a mapping. The result of evaluation is in a register (by default c), you can paste it whenever you need. "cp pastes content of register c in normal mode and <C-R>c in insert mode. You can compose one of those with movement to the position you want to paste, like $ to end of line or o to the next line.

🙌 1
mynomoto20:11:43

Just dropping by to thank @U076FM90B, this <C-R>c is amazing. TIL that conjure puts results on the c register.