46734e3

Branches > main > 46734e3 > files / nvim / lua / lsp.lua

Update jump to work in operator pending mode

Grahp, 2026-02-01

Commit: 46734e361936c819806f2ce6ba6d89d9ff39028a
Parent: b41bd23

2 changed files:

nvim/lua/jump.lua modified (view file)

@@ -117,8 +117,12 @@   return acc end -local function paint_labels(matches)+local function clear_labels()   vim.api.nvim_buf_clear_namespace(0, ns, 0, -1)+end++local function paint_labels(matches)+  clear_labels()   for _, m in ipairs(matches) do     vim.api.nvim_buf_set_extmark(0, ns, m.row - 1, m.col,                                  {virt_text = {{m.char, "Jump"},@@ -129,21 +133,6 @@   vim.cmd("redraw") end -local function clear_labels()-  vim.api.nvim_buf_clear_namespace(0, ns, 0, -1)-end----- Adds the current pos to the jump list---- See :h jumplist-local function add_to_jump_list()-  vim.cmd("normal! m'")-end--local function jump_to(pos)-  add_to_jump_list()-  vim.api.nvim_win_set_cursor(0, {pos.row, pos.col - 1})-end- --- Returns as many matches as it can (bounded by disambiguators) local function get_jump_targets(char, disambiguators)   local matches = find_matches(char)@@ -171,6 +160,7 @@                       }  --- Reads the 2 or 3 inputted characters+--- Returns a pos to jump to or nil local function jump()   local char = read_char()   if not char then return end@@ -198,16 +188,13 @@     end   end +  clear_labels()   if #char2_matches == 0 then-    clear_labels()     return   elseif #char2_matches == 1 and not char2_matches[1].disambiguator then-    jump_to(char2_matches[1])-    clear_labels()-    return+    return char2_matches[1]   end -  clear_labels()   paint_labels(char2_matches)    local char3 = read_char()@@ -218,8 +205,8 @@    for _, m in ipairs(char2_matches) do     if m.disambiguator == char3 then-      jump_to(m)-      break+      clear_labels()+      return m     end   end 

nvim/lua/keybindings.lua modified (view file)

@@ -38,7 +38,13 @@  keymap("n", "<Space>f", function() require("fuzzy").fuzzy_find() end) -keymap("n", ";", function() require("jump").jump() end)+keymap({"n", "v", "o"}, ";", function()+  local pos = require("jump").jump()+  if pos then+    vim.api.nvim_win_set_cursor(0, {pos.row, pos.col - 1})+  end+  return ""+end)  --- Either nil, "f/t", or "space" --- TODO should probably be per-buffer :p