Fork me on GitHub
#vim
<
2022-04-03
>
sheluchin11:04:38

Any vim-iced users? Does anyone know how I could create mappings that roughly map to the existing https://liquidz.github.io/vim-iced/vim-iced.html#%3CPlug%3E%28iced_eval%29 but let me wrap arbitrary Clojure code around the eval'd code? For example, I want to be able to create a mapping that will do the normal Evaluate outer list (mapped to <Leader>ee by default), but wrap it in a time call, like (time <outer list>). And as an aside, I wonder if using Fennel for my config would help with doing things like this.

mars0i08:04:05

sheluchin, I don't have an answer, but yes, there are vim-iced users here. Sounds like a cool idea. It must be possible, because it seems simpler than other things that vim-iced does to code. But I think most of those are done by external programs. I don't know much about it, but it seems as if you could make nrepl do that, and vim-iced uses nrepl to evaluate code. People do amazing things with Lua, so maybe the Fennel strategy is good. Dunno. (Maybe all of that just tells you less than you already know.)

sheluchin10:04:17

Thanks @U4HSMRQQJ. I'm slowly hacking my way towards it 🙂 I found that vim-iced has these paredit functions: https://github.com/liquidz/vim-iced/blob/e48b3e62ba2781f9144097bfe6c1e47029485f8a/autoload/iced/paredit.vim#L161= So I can make a function similar to this one: https://github.com/liquidz/vim-iced/blob/main/autoload/iced/nrepl/document.vim#L474-L475= Except the function should take some argument to make wrapping the current_top_list easy so composing its value into new calls becomes trivial. I can see adding temporary wrapper mappings being pretty useful. Something like (time <current_top_list>) may be useful only on occasion, but I think it generally opens up a lot of meta-programming flexibility.

mars0i02:04:38

That sounds like a reasonable strategy. I wonder if vim-iced IcedToggleTraceVAr might be another useful model.