vim

samoleary 2023-11-22T11:07:28.926689Z

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?

practicalli-johnny 2023-11-22T12:56:11.885189Z

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

timo 2023-11-22T13:00:56.704259Z

there is also shift+[ and shift+] for traversing code blocks

practicalli-johnny 2023-11-22T13:30:21.605169Z

% is useful to jump between matching parens (open close parens). I use this with visual select to cut and move expressions around

chico 2023-11-22T15:17:53.649269Z

I know it's not what you asked, but any reason not to use Astrovim + sexp?

samoleary 2023-11-22T16:01:40.740259Z

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.

dharrigan 2023-11-22T17:31:09.271319Z

I use neovim + coc + clojure-lsp. For me I can gd to go to definition, then pop the stack using ctrl+t

practicalli-johnny 2023-11-22T23:20:57.615969Z

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.

practicalli-johnny 2023-11-22T23:55:53.090739Z

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 = {},
      },
    },
  },
}

👍 2
3
samoleary 2023-11-27T11:11:52.570629Z

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.

practicalli-johnny 2023-11-27T11:22:59.753239Z

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)

samoleary 2023-11-23T10:18:36.554659Z

Perfect, this plugin is exactly what I'm looking for! Thanks @jr0cket!

practicalli-johnny 2023-11-23T13:04:38.157129Z

@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