Say I want to write a custom function / keyboard shortcut to jump to the next sibling node in Neovim/Lua. In theory, I can get that with TSNode:next_sibling(). But I'm lost as to how I would put the parts together here:

    // get node currently under cursor and/or visually selected
    // pass this to treesitter and get the next sibling
    // jump to the result  
    { nargs = 0 }
vim.keymap.set('n', '<leader>ns', vim.cmd.NextSibling)

There is some guidance here but it's a little out-of-date -- looking for the current simplest way to achieve this.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.