diff options
| author | Stephan Seitz <stephan.seitz@fau.de> | 2020-05-01 16:25:06 +0200 |
|---|---|---|
| committer | Stephan Seitz <stephan.seitz@fau.de> | 2020-05-03 10:51:15 +0200 |
| commit | d0b84dd89fb1cb4fc637cd3deec427745ba3145b (patch) | |
| tree | a2920ca37e02ce22f3a46d6e876cb3feb9486d96 /lua | |
| parent | Merge pull request #39 from vigoux/incremental_selection (diff) | |
| download | nvim-treesitter-d0b84dd89fb1cb4fc637cd3deec427745ba3145b.tar nvim-treesitter-d0b84dd89fb1cb4fc637cd3deec427745ba3145b.tar.gz nvim-treesitter-d0b84dd89fb1cb4fc637cd3deec427745ba3145b.tar.bz2 nvim-treesitter-d0b84dd89fb1cb4fc637cd3deec427745ba3145b.tar.lz nvim-treesitter-d0b84dd89fb1cb4fc637cd3deec427745ba3145b.tar.xz nvim-treesitter-d0b84dd89fb1cb4fc637cd3deec427745ba3145b.tar.zst nvim-treesitter-d0b84dd89fb1cb4fc637cd3deec427745ba3145b.zip | |
Add 'nvim-treesitter/node-movement'
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/nvim-treesitter/configs.lua | 11 | ||||
| -rw-r--r-- | lua/nvim-treesitter/node_movement.lua | 91 | ||||
| -rw-r--r-- | lua/nvim-treesitter/utils.lua | 59 |
3 files changed, 161 insertions, 0 deletions
diff --git a/lua/nvim-treesitter/configs.lua b/lua/nvim-treesitter/configs.lua index 10dcc9605..9695da5af 100644 --- a/lua/nvim-treesitter/configs.lua +++ b/lua/nvim-treesitter/configs.lua @@ -223,6 +223,17 @@ local config = { }, is_supported = function() return true end }, + node_movement = { + enable = false, + disable = {}, + is_supported = function() return true end, + keymaps = { + move_up = "<a-k>", + move_down = "<a-j>", + move_left = "<a-h>", + move_right = "<a-l>", + }, + }, -- folding = { -- enable = false, -- disable = {}, diff --git a/lua/nvim-treesitter/node_movement.lua b/lua/nvim-treesitter/node_movement.lua new file mode 100644 index 000000000..5d4813bc4 --- /dev/null +++ b/lua/nvim-treesitter/node_movement.lua @@ -0,0 +1,91 @@ +local api = vim.api +local parsers = require'nvim-treesitter.parsers' +local utils = require'nvim-treesitter.utils' +local M = {} + + +M.NodeMovementKind = { + up = 'up', + down = 'down', + left = 'left', + right = 'right', +} + +M.current_node = {} + +local function node_start_to_vim(node) + if not node then return end + + local row, col = node:start() + local exec_command = string.format('call cursor(%d, %d)', row+1, col+1) + api.nvim_exec(exec_command, false) +end + +M.do_node_movement = function(kind) + local buf, line, col = unpack(vim.fn.getpos(".")) + + local current_node = M.current_node[buf] + + if current_node then + local node_line, node_col = current_node:start() |
