rename Range.from_txtobj => from_motion
Some checks failed
NeoVim tests / plenary-tests (push) Failing after 7s
Some checks failed
NeoVim tests / plenary-tests (push) Failing after 7s
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
local Range = require 'u.range'
|
||||
local Renderer = require 'u.renderer'.Renderer
|
||||
local Renderer = require('u.renderer').Renderer
|
||||
|
||||
--- @class u.Buffer
|
||||
--- @field bufnr number
|
||||
@@ -71,7 +71,7 @@ function Buffer:lines(start, stop) return Range.from_lines(self.bufnr, start, st
|
||||
--- @param opts? { contains_cursor?: boolean; pos?: u.Pos }
|
||||
function Buffer:txtobj(txt_obj, opts)
|
||||
opts = vim.tbl_extend('force', opts or {}, { bufnr = self.bufnr })
|
||||
return Range.from_txtobj(txt_obj, opts)
|
||||
return Range.from_motion(txt_obj, opts)
|
||||
end
|
||||
|
||||
--- @param event string|string[]
|
||||
|
||||
@@ -95,7 +95,7 @@ end
|
||||
--- @param text_obj string
|
||||
--- @param opts? { bufnr?: number; contains_cursor?: boolean; pos?: u.Pos, user_defined?: boolean }
|
||||
--- @return u.Range|nil
|
||||
function Range.from_txtobj(text_obj, opts)
|
||||
function Range.from_motion(text_obj, opts)
|
||||
opts = opts or {}
|
||||
if opts.bufnr == nil then opts.bufnr = vim.api.nvim_get_current_buf() end
|
||||
if opts.contains_cursor == nil then opts.contains_cursor = false end
|
||||
@@ -214,18 +214,18 @@ end
|
||||
---
|
||||
function Range.find_nearest_brackets()
|
||||
return Range.smallest {
|
||||
Range.from_txtobj('a<', { contains_cursor = true }),
|
||||
Range.from_txtobj('a[', { contains_cursor = true }),
|
||||
Range.from_txtobj('a(', { contains_cursor = true }),
|
||||
Range.from_txtobj('a{', { contains_cursor = true }),
|
||||
Range.from_motion('a<', { contains_cursor = true }),
|
||||
Range.from_motion('a[', { contains_cursor = true }),
|
||||
Range.from_motion('a(', { contains_cursor = true }),
|
||||
Range.from_motion('a{', { contains_cursor = true }),
|
||||
}
|
||||
end
|
||||
|
||||
function Range.find_nearest_quotes()
|
||||
return Range.smallest {
|
||||
Range.from_txtobj([[a']], { contains_cursor = true }),
|
||||
Range.from_txtobj([[a"]], { contains_cursor = true }),
|
||||
Range.from_txtobj([[a`]], { contains_cursor = true }),
|
||||
Range.from_motion([[a']], { contains_cursor = true }),
|
||||
Range.from_motion([[a"]], { contains_cursor = true }),
|
||||
Range.from_motion([[a`]], { contains_cursor = true }),
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ local Range = require 'u.range'
|
||||
|
||||
local M = {}
|
||||
|
||||
local ESC = vim.api.nvim_replace_termcodes("<Esc>", true, false, true)
|
||||
local ESC = vim.api.nvim_replace_termcodes('<Esc>', true, false, true)
|
||||
|
||||
--- @param key_seq string
|
||||
--- @param fn fun(key_seq: string):u.Range|nil
|
||||
|
||||
Reference in New Issue
Block a user