Any Astrovim users know how to jump from function to function or form to form? 👀 I'm used to vim-sexp and vim-sexp-mappings-for-regular-people, I can't seem to figure out the equivalent or perhaps replacement?
I havent seen specifics for navigating between expressions in a file, Mostly I use / search to move around or 10 j to jump lines. However, I also use some LSP magic...
g d will jump to definitions, including let and function args
SPC l s shows symbols in telescope popup
SPC l S shows symbols in a new buffer
Otherwise try adding the vim-sexp mappings package or investigate some more neovim navigation options, e.g some hints in this stack exchange post https://vi.stackexchange.com/a/35201
I would also find it useful to learn more about neovim built-in tools for navigating code and any lua plugins that help with Clojure
there is also shift+[ and shift+] for traversing code blocks
% is useful to jump between matching parens (open close parens). I use this with visual select to cut and move expressions around
I know it's not what you asked, but any reason not to use Astrovim + sexp?
Thanks for the tips, very useful! I think I might go down that route @fran.fhb, astrovim is quite different to what I'm used to so wasn't sure if there was a key sequence already in place that I hadn't discovered.
I use neovim + coc + clojure-lsp. For me I can gd to go to definition, then pop the stack using ctrl+t
https://github.com/PaterJason/nvim-treesitter-sexp looks an interesting lua plug for navigating sexpressions using treesitter (so it should be very quick and accurate) I'll try find some time to give it a test and if it works well I'll consider adding it to the https://github.com/AstroNvim/astrocommunity/tree/main/lua/astrocommunity/pack/clojure.
I created a plugins/clojure.lua file in my Astronvim user config and added the nvim-treesitter-sexp plugin using the following code (changing a couple of default key bindings under the localleader)
It seems to work okay, although I haven't given it a full test.
The default key bindings are in the project readme - https://github.com/PaterJason/nvim-treesitter-sexp#configuration and I find ]] and [[ to navigate top-level forms quite useful.
return {
{
"PaterJason/nvim-treesitter-sexp",
ft = { "clojure", "fennel", "janet" },
opts = {
-- configuration:
--
enabled = true,
set_cursor = true,
keymaps = {
commands = {
promote_elem = "kO",
promote_form = "ko",
splice = "k@",
},
motions = {},
textobjects = {},
},
},
},
} It's working great so far. Slurping and barfing don't play nice with parinfer as you might expect but haven't come across any surprises yet.
Thanks for the feedback Sam. I'll hopefully do some coding myself and see if I can make some useful tweaks to the AstroNvim Clojure pack (or add docs & examples to override parinfer)
Perfect, this plugin is exactly what I'm looking for! Thanks @jr0cket!
@ssjoleary746 let me know how you get on with the plugin and I'll add a configuration to the Astronvim community Clojure pack. I am interested in knowing if there are any key binding conflicts with existing Astronvim keys