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.

nvim-treeclimber's People

Contributors

dkendal avatar perrin4869 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

nvim-treeclimber's Issues

Error when the background is null

I just upgraded to the latest HEAD where lush is removed and ran require('nvim-treeclimber').setup(). This results in an error:

Error detected while processing /home/perrin4869/dotfiles/home/.config/nvim/plugin/treeclimber.lua:
E5113: Error while calling lua chunk: ...fault/start/nvim-treeclimber/lua/nvim-treeclimber/hi.lua:18: bad argument #2 to 'hex' (number expected, got nil)
stack traceback:
        [C]: in function 'hex'
        ...fault/start/nvim-treeclimber/lua/nvim-treeclimber/hi.lua:18: in function 'bg_hsluv'
        .../default/start/nvim-treeclimber/lua/nvim-treeclimber.lua:12: in function 'setup'
        ...in4869/dotfiles/home/.config/nvim/plugin/treeclimber.lua:1: in main chunk

The root cause is that I have this inside my vimrc: hi Normal guibg=NONE, which results in vim.api.nvim_get_hl_by_name("Normal", true) returning:

{
  foreground = 15457202
}

I think maybe there should be a case handling for background = null?

Suggestion: remove lush dependancy

It very convenient to use

local normal_background = vim.api.nvim_get_hl_by_name("Normal", true).background
local blend_color = normal_background ~= nil and string.format("#%06x", normal_background) or "#000000"

to get the hex of certain highlight group, no need extra plugin to do that.

I understood you had already said it will be remove eventually, but I think a little help would do not harm.

Feature Requests

Hi all,

I haven't added new functionality to this plugin for a while as I have found that it meets my needs. I'd like to put an open call to see if there is any functionality that people would really like to see added. Thanks!

Immediate error (hsl)

For any users here encountering this error I'm looking into this as an alternative: https://github.com/ziontee113/syntax-tree-surfer

This error occurs with lush when setup is called

Would love to see a working treesitter plugin (ASTs rock). This plugin looks rad, hopefully it can be polished up

E5113: Error while calling lua chunk: ...cal/nvim-data/lazy/lush.nvim/lua/lush/vivid/hsl_like.lua:284: hsl() expects (number, number, number) or (string)
stack traceback:
        [C]: in function 'assert'
        ...cal/nvim-data/lazy/lush.nvim/lua/lush/vivid/hsl_like.lua:284: in function 'hsl'
        ...m-data/lazy/nvim-treeclimber/lua/nvim-treeclimber/hi.lua:57: in main chunk
        [C]: in function 'require'
        ...nvim-data/lazy/nvim-treeclimber/lua/nvim-treeclimber.lua:11: in function 'setup'
        C:\Users\Bryce\AppData\Local\nvim\init.lua:382: in main chunk
Press ENTER or type command to continue
:version                                                                                                                NVIM v0.9.1                                                                                                             Build type: RelWithDebInfo                                                                                              LuaJIT 2.1.0-beta3                                                                                                      Compilation: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe /MD /Zi /O2 /Ob1  -W3 -wd4311 -wd4146 -DUNIT_TESTING -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -D_WIN32_WINNT=0x0602 -DMSWIN -DINCLUDE_GENERATED_DECLARATIONS -ID:/a/neovim/neovim/.deps/usr/include/luajit-2.1 -ID:/a/neovim/neovim/.deps/usr/include -ID:/a/neovim/neovim/.deps/usr/include -ID:/a/neovim/neovim/build/src/nvim/auto -ID:/a/neovim/neovim/build/include -ID:/a/neovim/neovim/build/cmake.config -ID:/a/neovim/neovim/src -ID:/a/neovim/neovim/.deps/usr/include -ID:/a/neovim/neovim/.deps/usr/include -ID:/a/neovim/neovim/.deps/usr/include -ID:/a/neovim/neovim/.deps/usr/include -ID:/a/neovim/neovim/.deps/usr/include -ID:/a/neovim/neovim/.deps/usr/include -ID:/a/neovim/neovim/.deps/usr/include                                                                                                                               system vimrc file: "$VIM\sysinit.vim"                                                                                  fall-back for $VIM: "C:/Program Files (x86)/nvim/share/nvim"                                                                                                                                                                                  Run :checkhealth for more info

the installation instructions arent clear

where do I add all of this?

here is my file structure:

  nvim/
  | .git/                                                                         
  | after/                                                                        
  | | ftplugin/                                                                   
  | | | netrw.lua                                                                 
  | | plugin/                                                                     
  | | | fugitive.lua                                                              
  | | | harpoon.lua                                                               
  | | | lightline.lua                                                             
  | | | lsp.lua                                                                   
  | | | telescope.lua                                                             
  | | | treesitter.lua                                                            
  | | | undotree.lua                                                              
  | | | winbar.lua.bak                                                            
  | lua/                                                                          
  | | donjikong/                                                                  
  | | | init.lua                                                                  
  | | | packer.lua                                                                
  | | | python.lua                                                                
  | | | remap.lua                                                                 
  | | | set.lua                                                                   
  | | | test.py                                                                   
  | | | win.lua                                                                   
  | plugin/                                                                       
  | | packer_compiled.lua                                                         
  | init.lua 

do I not put it in my packer.lua?

Doc images

Drop zone for documentation images and videos.


tc-show-control-flow.mp4

grow-selection-next

grow-selection-next.mp4

grow-selection-prev

grow-selection-prev.mp4

select-expand

select-expand.mp4

select-first-sibling

select-first-sibling.mp4

select-last-sibling

select-last-sibling.mp4

select-next

select-next.mp4

select-prev

select-prev.mp4

select-shrink

select-shrink.mp4

select-top-level

select-top-level.mp4
tc-diff-this.mp4
tc-diff-this.webm

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.