Fork me on GitHub

Does anyone know of a plugin like vim-sexp that can deal with key-value pairs in maps as single text objects? I often want to use something like >e to swap k-v pairs in a map or change them with cie , but of course keys and values are regarded separately.


I have wanted this for a long time as well. Recently the clojure-lsp project has enabled moving up and down these kinds of pairs. With it, you can also move let bindings up and down as well.

👀 1

See #lsp for more.


I use it via coc.nvim, but I hear the built-in neovim lsp stuff works too.


Very nice! I also use clojure-lsp on coc, but never really looked into actions there (I only recently began using it). Drag backward/forward does the trick for me with k-v pairs stacked vertically, but not if they are horizontally arranged. But they can even be sorted by key with Sort map, even with non-keyword keys, which is awesome!

clojure-lsp 1
🚀 1

both works in nvim lsp


The function also shows up in coc when I am inside a “horizontal map”, but it doesn’t seem to do anything compared to the “vertical map”.


You can also move a kv using just vim-sexp by selecting both the k and the v in visual mode and using You can even select multiple neighbouring kvs and move them this way.

👍 2

I have a pseudo text object which I call a pair - it is a pair of SEXP elements. There are 2 variants forward and backward, depending which element I need to be a pair to the one under my cursor. Another insight is that SEXP's operation to move element works on any number of elements, meaning that I just need a way to select two elements, the movement of the pair is done by SEXP <Plug>(sexp_swap_element_forward)

👍 2

Thanks for sharing, this works very nicely! Too bad the operations cannot be repeated using . , like vim-sexp does with tpope/vim-repeat .


There is also things (like in Conjure, and I would bet others) where you can do a evaluate code, and swap in the result with the code you just ran