From 5a1d24ae0daab8f9912532f9bef290ef4c736101 Mon Sep 17 00:00:00 2001 From: aleidk Date: Wed, 30 Jul 2025 15:35:09 -0400 Subject: [PATCH] update movement in nvim --- Configs/nvim/.config/nvim/lazy-lock.json | 1 + .../nvim/lua/aleidk/plugins/colorscheme.lua | 5 ++ .../.config/nvim/lua/aleidk/plugins/fzf.lua | 12 +++- .../.config/nvim/lua/aleidk/plugins/mini.lua | 19 +++++- .../nvim/lua/aleidk/plugins/treesitter.lua | 60 ++++++++++++++----- 5 files changed, 80 insertions(+), 17 deletions(-) diff --git a/Configs/nvim/.config/nvim/lazy-lock.json b/Configs/nvim/.config/nvim/lazy-lock.json index c3f7882..faa70a2 100644 --- a/Configs/nvim/.config/nvim/lazy-lock.json +++ b/Configs/nvim/.config/nvim/lazy-lock.json @@ -22,6 +22,7 @@ "nvim-lspconfig": { "branch": "master", "commit": "4d3b3bb8815fbe37bcaf3dbdb12a22382bc11ebe" }, "nvim-treesitter": { "branch": "master", "commit": "42fc28ba918343ebfd5565147a42a26580579482" }, "nvim-treesitter-context": { "branch": "master", "commit": "59f318a65d42a5c4037796886a8874fd57f774fc" }, + "nvim-treesitter-textobjects": { "branch": "master", "commit": "71385f191ec06ffc60e80e6b0c9a9d5daed4824c" }, "nvim-ts-context-commentstring": { "branch": "main", "commit": "1b212c2eee76d787bbea6aa5e92a2b534e7b4f8f" }, "nvim-web-devicons": { "branch": "master", "commit": "0422a19d9aa3aad2c7e5cca167e5407b13407a9d" }, "plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" }, diff --git a/Configs/nvim/.config/nvim/lua/aleidk/plugins/colorscheme.lua b/Configs/nvim/.config/nvim/lua/aleidk/plugins/colorscheme.lua index 2eef16c..2237d69 100644 --- a/Configs/nvim/.config/nvim/lua/aleidk/plugins/colorscheme.lua +++ b/Configs/nvim/.config/nvim/lua/aleidk/plugins/colorscheme.lua @@ -51,6 +51,11 @@ return { -- Change colors.none if not using a transparent background style = { "bold" }, }, GitSignsDeleteVirtLn = { bg = colors.none, fg = colors.red }, + + MiniJump2dDim = { fg = colors.surface1 }, + MiniJump2dSpot = { bg = colors.base, fg = colors.teal, style = { "bold", "underline" } }, + MiniJump2dSpotAhead = { bg = colors.base, fg = colors.teal, style = { "bold", "underline" } }, + MiniJump2dSpotUnique = { bg = colors.base, fg = colors.teal, style = { "bold", "underline" } }, } end, } diff --git a/Configs/nvim/.config/nvim/lua/aleidk/plugins/fzf.lua b/Configs/nvim/.config/nvim/lua/aleidk/plugins/fzf.lua index a5d3db3..c1549ed 100644 --- a/Configs/nvim/.config/nvim/lua/aleidk/plugins/fzf.lua +++ b/Configs/nvim/.config/nvim/lua/aleidk/plugins/fzf.lua @@ -3,7 +3,17 @@ return { lazy = false, -- Required to register vim.ui.select() wrapper dependencies = { "echasnovski/mini.nvim" }, config = function() - require("fzf-lua").setup() + require("fzf-lua").setup({ + winopts = { + height = 0.85, + width = 0.90, + }, + files = { + -- path_shorten = true, + cwd_prompt = false, + -- formatter = "path.filename_first", + }, + }) require("fzf-lua").register_ui_select() end, keys = { diff --git a/Configs/nvim/.config/nvim/lua/aleidk/plugins/mini.lua b/Configs/nvim/.config/nvim/lua/aleidk/plugins/mini.lua index 7c8dca1..9c3b80f 100644 --- a/Configs/nvim/.config/nvim/lua/aleidk/plugins/mini.lua +++ b/Configs/nvim/.config/nvim/lua/aleidk/plugins/mini.lua @@ -20,7 +20,24 @@ return { require("mini.ai").setup({}) require('mini.cursorword').setup() -- Highlight word under cursor require('mini.extra').setup() - require('mini.jump').setup() -- Extend f, F, t, T + require('mini.jump').setup({ + mappings = { + repeat_jump = "" + } + }) -- Extend f, F, t, T + require('mini.jump2d').setup( + { + spotter = require('mini.jump2d').gen_pattern_spotter('[^%s%p]+', 'start'), + view = { + dim = true, + n_steps_ahead = 2 + }, + allowed_lines = { + blank = false, + cursor_at = false + }, + } + ) require('mini.surround').setup() require('mini.operators').setup() require('mini.pairs').setup({ diff --git a/Configs/nvim/.config/nvim/lua/aleidk/plugins/treesitter.lua b/Configs/nvim/.config/nvim/lua/aleidk/plugins/treesitter.lua index fe93165..65a0450 100644 --- a/Configs/nvim/.config/nvim/lua/aleidk/plugins/treesitter.lua +++ b/Configs/nvim/.config/nvim/lua/aleidk/plugins/treesitter.lua @@ -1,20 +1,50 @@ return { - "nvim-treesitter/nvim-treesitter", - lazy = false, - branch = "master", - dependencies = { - { - "JoosepAlviste/nvim-ts-context-commentstring", - opts = { - enable_autocmd = false, + { + "nvim-treesitter/nvim-treesitter", + lazy = false, + branch = "master", + dependencies = { + { + "JoosepAlviste/nvim-ts-context-commentstring", + opts = { + enable_autocmd = false, + }, }, + { "nvim-treesitter/nvim-treesitter-context" }, + }, + build = ":TSUpdate", + opts = { + auto_install = true, + highlight = { enable = true }, + indent = { enable = true }, }, - { "nvim-treesitter/nvim-treesitter-context" }, - }, - build = ":TSUpdate", - opts = { - auto_install = true, - highlight = { enable = true }, - indent = { enable = true }, }, + { + "nvim-treesitter/nvim-treesitter-textobjects", + dependencies = { "nvim-treesitter", }, + config = function() + require 'nvim-treesitter.configs'.setup({ + textobjects = { + move = { + enable = true, + set_jumps = true, -- whether to set jumps in the jumplist + goto_next = { + ["]]"] = { query = { "@block.outer", "@function.outer", "@class.outer", } }, + }, + goto_previous = { + ["[["] = { query = { "@block.outer", "@function.outer", "@class.outer", } }, + } + }, + }, + }) + + local ts_repeat_move = require "nvim-treesitter.textobjects.repeatable_move" + + -- Repeat movement with ; and , + -- ensure ; goes forward and , goes backward regardless of the last direction + vim.keymap.set({ "n", "x", "o" }, ";", ts_repeat_move.repeat_last_move_previous) + vim.keymap.set({ "n", "x", "o" }, ",", ts_repeat_move.repeat_last_move_next) + end + } + }