This commit is contained in:
@@ -38,7 +38,8 @@ function CodeWriter.from_line(line, bufnr)
|
||||
local expandtab = vim.api.nvim_get_option_value('expandtab', { buf = bufnr })
|
||||
local shiftwidth = vim.api.nvim_get_option_value('shiftwidth', { buf = bufnr })
|
||||
|
||||
local indent_level = 0
|
||||
--- @type number
|
||||
local indent_level
|
||||
local indent_str = ''
|
||||
if expandtab then
|
||||
while #indent_str < shiftwidth do
|
||||
|
||||
@@ -8,7 +8,7 @@ local __U__OpKeymapOpFunc_rhs = nil
|
||||
--- @type nil|fun(range: u.Range): fun():any|nil
|
||||
--- @param ty 'line'|'char'|'block'
|
||||
-- selene: allow(unused_variable)
|
||||
function __U__OpKeymapOpFunc(ty)
|
||||
function _G.__U__OpKeymapOpFunc(ty)
|
||||
if __U__OpKeymapOpFunc_rhs ~= nil then
|
||||
local range = Range.from_op_func(ty)
|
||||
__U__OpKeymapOpFunc_rhs(range)
|
||||
|
||||
@@ -459,6 +459,7 @@ end
|
||||
function Range:text() return vim.fn.join(self:lines(), '\n') end
|
||||
|
||||
--- @param l number
|
||||
-- luacheck: ignore
|
||||
--- @return { line: string; idx0: { start: number; stop: number; }; lnum: number; range: fun():u.Range; text: fun():string }|nil
|
||||
function Range:line(l)
|
||||
if l < 0 then l = self:line_count() + l + 1 end
|
||||
|
||||
@@ -5,6 +5,7 @@ local H = {}
|
||||
--- @alias u.renderer.Node nil | boolean | string | u.renderer.Tag
|
||||
--- @alias u.renderer.Tree u.renderer.Node | u.renderer.Node[]
|
||||
|
||||
-- luacheck: ignore
|
||||
--- @type table<string, fun(attributes: table<string, any>, children: u.renderer.Tree): u.renderer.Tag> & fun(name: string, attributes: table<string, any>, children: u.renderer.Tree): u.renderer.Tag>
|
||||
M.h = setmetatable({}, {
|
||||
__call = function(_, name, attributes, children)
|
||||
@@ -108,7 +109,7 @@ function Renderer.markup_to_lines(opts) -- {{{
|
||||
-- newlines are not controlled by array entries, do NOT output a line here:
|
||||
visit(child)
|
||||
end
|
||||
else
|
||||
else -- luacheck: ignore
|
||||
visit(node.children)
|
||||
end
|
||||
|
||||
@@ -178,13 +179,13 @@ function Renderer.patch_lines(bufnr, old_lines, new_lines)
|
||||
_set_text(lnum0, cnum0, lnum0, cnum0 + 1, { col_change.to })
|
||||
elseif col_change.kind == 'delete' then
|
||||
_set_text(lnum0, cnum0, lnum0, cnum0 + 1, {})
|
||||
else
|
||||
else -- luacheck: ignore
|
||||
-- No change
|
||||
end
|
||||
end
|
||||
elseif line_change.kind == 'delete' then
|
||||
_set_lines(lnum0, lnum0 + 1, true, {})
|
||||
else
|
||||
else -- luacheck: ignore
|
||||
-- No change
|
||||
end
|
||||
end
|
||||
@@ -464,6 +465,7 @@ function TreeBuilder:tree() return self.nodes end
|
||||
-- }}}
|
||||
|
||||
-- Levenshtein utility {{{
|
||||
-- luacheck: ignore
|
||||
--- @alias LevenshteinChange<T> ({ kind: 'add'; item: T; index: number; } | { kind: 'delete'; item: T; index: number; } | { kind: 'change'; from: T; to: T; index: number; })
|
||||
--- @private
|
||||
--- @generic T
|
||||
|
||||
@@ -202,7 +202,7 @@ end
|
||||
-- class ExecutionContext
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
CURRENT_CONTEXT = nil
|
||||
local CURRENT_CONTEXT = nil
|
||||
|
||||
--- @class u.ExecutionContext
|
||||
--- @field signals table<u.Signal, boolean>
|
||||
@@ -211,7 +211,7 @@ M.ExecutionContext = ExecutionContext
|
||||
ExecutionContext.__index = ExecutionContext
|
||||
|
||||
--- @return u.ExecutionContext
|
||||
function ExecutionContext:new()
|
||||
function ExecutionContext.new()
|
||||
return setmetatable({
|
||||
signals = {},
|
||||
subscribers = {},
|
||||
@@ -222,7 +222,7 @@ function ExecutionContext.current() return CURRENT_CONTEXT end
|
||||
|
||||
--- @param fn function
|
||||
--- @param ctx u.ExecutionContext
|
||||
function ExecutionContext:run(fn, ctx)
|
||||
function ExecutionContext.run(fn, ctx)
|
||||
local oldCtx = CURRENT_CONTEXT
|
||||
CURRENT_CONTEXT = ctx
|
||||
local result
|
||||
@@ -289,8 +289,8 @@ end
|
||||
--- @param fn function
|
||||
--- @param name? string
|
||||
function M.create_effect(fn, name)
|
||||
local ctx = M.ExecutionContext:new()
|
||||
M.ExecutionContext:run(fn, ctx)
|
||||
local ctx = M.ExecutionContext.new()
|
||||
M.ExecutionContext.run(fn, ctx)
|
||||
return ctx:subscribe(function()
|
||||
if name and M.debug then
|
||||
local deps = vim
|
||||
|
||||
@@ -6,6 +6,7 @@ local M = {}
|
||||
|
||||
--- @alias QfItem { col: number, filename: string, kind: string, lnum: number, text: string }
|
||||
--- @alias KeyMaps table<string, fun(): any | string> }
|
||||
-- luacheck: ignore
|
||||
--- @alias CmdArgs { args: string; bang: boolean; count: number; fargs: string[]; line1: number; line2: number; mods: string; name: string; range: 0|1|2; reg: string; smods: any; info: u.Range|nil }
|
||||
|
||||
--- @generic T
|
||||
@@ -34,6 +35,7 @@ end
|
||||
--- ```
|
||||
--- @param name string
|
||||
--- @param cmd string | fun(args: CmdArgs): any
|
||||
-- luacheck: ignore
|
||||
--- @param opts? { nargs?: 0|1|'*'|'?'|'+'; range?: boolean|'%'|number; count?: boolean|number, addr?: string; completion?: string }
|
||||
function M.ucmd(name, cmd, opts)
|
||||
local Range = require 'u.range'
|
||||
|
||||
Reference in New Issue
Block a user