Compare commits
3 Commits
adcfe5640f
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 44a97b5baa | |||
| 7fb60add94 | |||
| 79499e898c |
@@ -1,5 +1,9 @@
|
||||
# u.nvim
|
||||
|
||||
🚨🚨 **BRANCH NOTICE: further development is happening on the `v2` branch. In the future, `v2` will be merged into `master`. If you want to pin to an older version of this library, please refer to a specific commit, or the `v1` branch.** 🚨🚨
|
||||
|
||||
🚨🚨[CLICK HERE FOR v2](https://github.com/jrop/u.nvim/tree/v2)🚨🚨
|
||||
|
||||
Welcome to **u.nvim** – a powerful Lua library designed to enhance your text manipulation experience in NeoVim, focusing primarily on a context-aware "Range" utility. This utility allows you to work efficiently with text selections based on various conditions, in a variety of contexts, making coding and editing more intuitive and productive.
|
||||
|
||||
This is meant to be used as a **library**, not a plugin. On its own, `u.nvim` does nothing. It is meant to be used by plugin authors, to make their lives easier based on the variety of utilities I found I needed while growing my NeoVim config.
|
||||
|
||||
@@ -127,7 +127,7 @@ function Range.from_text_object(text_obj, opts)
|
||||
|
||||
local prev_on_yank_enabled = on_yank_enabled
|
||||
on_yank_enabled = false
|
||||
vim.cmd.normal {
|
||||
vim.cmd {
|
||||
cmd = 'normal',
|
||||
bang = not opts.user_defined,
|
||||
args = { '""y' .. text_obj },
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
local M = {}
|
||||
|
||||
local function _normal(cmd) vim.cmd.normal { cmd = 'normal', args = { cmd }, bang = true } end
|
||||
local function _normal(cmd) vim.cmd { cmd = 'normal', args = { cmd }, bang = true } end
|
||||
|
||||
M.native_repeat = function() _normal '.' end
|
||||
M.native_undo = function() _normal 'u' end
|
||||
|
||||
@@ -64,7 +64,7 @@ function State:track_mark(mark) self.marks[mark] = vim.api.nvim_buf_get_mark(sel
|
||||
function State:track_pos(pos) self.positions[pos] = vim.fn.getpos(pos) end
|
||||
|
||||
---@param nm string
|
||||
function State:track_global_option(nm) self.global_options[nm] = vim.g[nm] end
|
||||
function State:track_global_option(nm) self.global_options[nm] = vim.go[nm] end
|
||||
|
||||
function State:track_winview() self.win_view = vim.fn.winsaveview() end
|
||||
|
||||
@@ -82,7 +82,7 @@ function State:restore()
|
||||
vim.keymap.set(map.mode, map.lhs, map.rhs, { buffer = map.buffer })
|
||||
end
|
||||
for nm, val in pairs(self.global_options) do
|
||||
vim.g[nm] = val
|
||||
vim.go[nm] = val
|
||||
end
|
||||
if self.win_view ~= nil then vim.fn.winrestview(self.win_view) end
|
||||
end
|
||||
|
||||
@@ -76,7 +76,7 @@ function M.define_text_object(key_seq, fn, opts)
|
||||
local p = range_or_pos --[[@as Pos]]
|
||||
State.run(0, function(s)
|
||||
s:track_global_option 'eventignore'
|
||||
vim.opt_global.eventignore = 'all'
|
||||
vim.go.eventignore = 'all'
|
||||
|
||||
-- insert a single space, so we can select it:
|
||||
vim.api.nvim_buf_set_text(0, p.lnum, p.col, p.lnum, p.col, { ' ' })
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
local function withbuf(lines, f)
|
||||
vim.opt_global.swapfile = false
|
||||
vim.go.swapfile = false
|
||||
|
||||
vim.cmd.new()
|
||||
vim.api.nvim_buf_set_lines(0, 0, -1, false, lines)
|
||||
|
||||
Reference in New Issue
Block a user