Coder Social home page Coder Social logo

nvim-treeclimber's Introduction

Nvim-Treeclimber

Neovim plugin for treesitter based navigation and selection. Takes inspiration from ParEdit.

Requires neovim >= 0.10.

Usage

Navigation

Key binding Action Demo
alt-h Select the previous sibling node. select-prev
alt-j Shrink selection. The video also shows growing the selection first. Shrinking selects a child node from the current node, or will undo the action of a previous expand operation. select-shrink
alt-k Expand selection by selecting the parent of the current node or node under the cursor. select-expand
alt-l Select the next sibling node. select-next
alt-shift-l Add the next sibling to the selection. grow-selection-next
alt-shift-h Add the previous sibling to the selection. grow-selection-prev
alt-[ Select the first sibling relative to the current node. select-first-sibling
alt-] Select the last sibling relative to the current node . select-last-sibling
alt-g Select the top level node relative to the cursor or selection. select-top-level

Inspection

Key binding Action Demo
leader-k Populate the quick fix with all branches required to reach the current node :TCShowControlFlow

Commands

:TCDiffThis

Diff two visual selections based on their AST difference. Requires that difft is available in your path.

To use, make your first selection and call :TCDiffThis, then make your second selection and call :TCDiffThis again.

tc-diff-this.webm

:TCShowControlFlow

Populate the quick fix with all branches required to reach the current node.

tc-show-control-flow.mp4

Installation

Use your preferred package manager, or the built-in package system (:help packages).

mkdir -p ~/.config/nvim/pack/dkendal/opt
cd ~/.config/nvim/pack/dkendal/opt
git clone https://github.com/dkendal/nvim-treeclimber.git
-- ~/.config/nvim/init.lua
vim.cmd.packadd('nvim-treeclimber')

require('nvim-treeclimber').setup()

If you want to change the default keybindings, call require('nvim-treeclimber') rather than calling setup. See configuration.

Configuration

To use default highlight, keymaps, and commands call require('nvim-treeclimber').setup().

To manually specify the configuration options, take a look at the contents of lua/nvim-treeclimber.lua and import or modify the portions that you need.

For example, if you just want the built in user commands and highlights but you want your own keybindings, you can do the following:

local tc = require('nvim-treeclimber')

tc.setup_augroups()
tc.setup_user_commands()

-- Copied from setup_keymaps
vim.keymap.set("n", "<leader>k", tc.show_control_flow, {})
vim.keymap.set({ "x", "o" }, "i.", tc.select_current_node, { desc = "select current node" })
vim.keymap.set({ "x", "o" }, "a.", tc.select_expand, { desc = "select parent node" })
...

Copyright Dylan Kendal 2022.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.