(stylua) lower max line length to 100
Some checks failed
NeoVim tests / plenary-tests (push) Failing after 8s
Some checks failed
NeoVim tests / plenary-tests (push) Failing after 8s
This commit is contained in:
parent
3fe84197c1
commit
362d9e905d
@ -24,7 +24,9 @@ function Buffer.current() return Buffer.from_nr(0) end
|
|||||||
--- @param listed boolean
|
--- @param listed boolean
|
||||||
--- @param scratch boolean
|
--- @param scratch boolean
|
||||||
--- @return u.Buffer
|
--- @return u.Buffer
|
||||||
function Buffer.create(listed, scratch) return Buffer.from_nr(vim.api.nvim_create_buf(listed, scratch)) end
|
function Buffer.create(listed, scratch)
|
||||||
|
return Buffer.from_nr(vim.api.nvim_create_buf(listed, scratch))
|
||||||
|
end
|
||||||
|
|
||||||
function Buffer:set_tmp_options()
|
function Buffer:set_tmp_options()
|
||||||
self:set_option('bufhidden', 'delete')
|
self:set_option('bufhidden', 'delete')
|
||||||
@ -36,7 +38,9 @@ end
|
|||||||
function Buffer:get_option(nm) return vim.api.nvim_get_option_value(nm, { buf = self.bufnr }) end
|
function Buffer:get_option(nm) return vim.api.nvim_get_option_value(nm, { buf = self.bufnr }) end
|
||||||
|
|
||||||
--- @param nm string
|
--- @param nm string
|
||||||
function Buffer:set_option(nm, val) return vim.api.nvim_set_option_value(nm, val, { buf = self.bufnr }) end
|
function Buffer:set_option(nm, val)
|
||||||
|
return vim.api.nvim_set_option_value(nm, val, { buf = self.bufnr })
|
||||||
|
end
|
||||||
|
|
||||||
--- @param nm string
|
--- @param nm string
|
||||||
function Buffer:get_var(nm) return vim.api.nvim_buf_get_var(self.bufnr, nm) end
|
function Buffer:get_var(nm) return vim.api.nvim_buf_get_var(self.bufnr, nm) end
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
--- @params name string
|
--- @params name string
|
||||||
function M.file_for_name(name) return vim.fs.joinpath(vim.fn.stdpath 'cache', 'u.log', name .. '.log.jsonl') end
|
function M.file_for_name(name)
|
||||||
|
return vim.fs.joinpath(vim.fn.stdpath 'cache', 'u.log', name .. '.log.jsonl')
|
||||||
|
end
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
-- Logger class
|
-- Logger class
|
||||||
@ -30,7 +32,10 @@ end
|
|||||||
function Logger:write(level, ...)
|
function Logger:write(level, ...)
|
||||||
local data = { ... }
|
local data = { ... }
|
||||||
if #data == 1 then data = data[1] end
|
if #data == 1 then data = data[1] end
|
||||||
(vim.uv or vim.loop).fs_write(self.fd, vim.json.encode { ts = os.date(), level = level, data = data } .. '\n')
|
(vim.uv or vim.loop).fs_write(
|
||||||
|
self.fd,
|
||||||
|
vim.json.encode { ts = os.date(), level = level, data = data } .. '\n'
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Logger:trace(...) self:write('INFO', ...) end
|
function Logger:trace(...) self:write('INFO', ...) end
|
||||||
|
@ -2,7 +2,9 @@ local MAX_COL = vim.v.maxcol
|
|||||||
|
|
||||||
--- @param bufnr number
|
--- @param bufnr number
|
||||||
--- @param lnum number 1-based
|
--- @param lnum number 1-based
|
||||||
local function line_text(bufnr, lnum) return vim.api.nvim_buf_get_lines(bufnr, lnum - 1, lnum, false)[1] end
|
local function line_text(bufnr, lnum)
|
||||||
|
return vim.api.nvim_buf_get_lines(bufnr, lnum - 1, lnum, false)[1]
|
||||||
|
end
|
||||||
|
|
||||||
--- @class u.Pos
|
--- @class u.Pos
|
||||||
--- @field bufnr number buffer number
|
--- @field bufnr number buffer number
|
||||||
@ -54,7 +56,9 @@ end
|
|||||||
|
|
||||||
function Pos.__lt(a, b) return a.lnum < b.lnum or (a.lnum == b.lnum and a.col < b.col) end
|
function Pos.__lt(a, b) return a.lnum < b.lnum or (a.lnum == b.lnum and a.col < b.col) end
|
||||||
function Pos.__le(a, b) return a < b or a == b end
|
function Pos.__le(a, b) return a < b or a == b end
|
||||||
function Pos.__eq(a, b) return Pos.is(a) and Pos.is(b) and a.bufnr == b.bufnr and a.lnum == b.lnum and a.col == b.col end
|
function Pos.__eq(a, b)
|
||||||
|
return Pos.is(a) and Pos.is(b) and a.bufnr == b.bufnr and a.lnum == b.lnum and a.col == b.col
|
||||||
|
end
|
||||||
function Pos.__add(x, y)
|
function Pos.__add(x, y)
|
||||||
if type(x) == 'number' then
|
if type(x) == 'number' then
|
||||||
x, y = y, x
|
x, y = y, x
|
||||||
@ -202,7 +206,9 @@ end
|
|||||||
--- @return u.Pos|nil
|
--- @return u.Pos|nil
|
||||||
function Pos:find_match(max_chars, invocations)
|
function Pos:find_match(max_chars, invocations)
|
||||||
if invocations == nil then invocations = {} end
|
if invocations == nil then invocations = {} end
|
||||||
if vim.tbl_contains(invocations, function(p) return self == p end, { predicate = true }) then return nil end
|
if vim.tbl_contains(invocations, function(p) return self == p end, { predicate = true }) then
|
||||||
|
return nil
|
||||||
|
end
|
||||||
table.insert(invocations, self)
|
table.insert(invocations, self)
|
||||||
|
|
||||||
local openers = { '{', '[', '(', '<' }
|
local openers = { '{', '[', '(', '<' }
|
||||||
@ -212,7 +218,10 @@ function Pos:find_match(max_chars, invocations)
|
|||||||
local is_closer = vim.tbl_contains(closers, c)
|
local is_closer = vim.tbl_contains(closers, c)
|
||||||
if not is_opener and not is_closer then return nil end
|
if not is_opener and not is_closer then return nil end
|
||||||
|
|
||||||
local i, _ = vim.iter(is_opener and openers or closers):enumerate():find(function(_, c2) return c == c2 end)
|
local i, _ = vim
|
||||||
|
.iter(is_opener and openers or closers)
|
||||||
|
:enumerate()
|
||||||
|
:find(function(_, c2) return c == c2 end)
|
||||||
-- Store the character we will be looking for:
|
-- Store the character we will be looking for:
|
||||||
local c_match = (is_opener and closers or openers)[i]
|
local c_match = (is_opener and closers or openers)[i]
|
||||||
|
|
||||||
@ -255,7 +264,14 @@ end
|
|||||||
--- @param lines string|string[]
|
--- @param lines string|string[]
|
||||||
function Pos:insert_before(lines)
|
function Pos:insert_before(lines)
|
||||||
if type(lines) == 'string' then lines = vim.split(lines, '\n') end
|
if type(lines) == 'string' then lines = vim.split(lines, '\n') end
|
||||||
vim.api.nvim_buf_set_text(self.bufnr, self.lnum - 1, self.col - 1, self.lnum - 1, self.col - 1, lines)
|
vim.api.nvim_buf_set_text(
|
||||||
|
self.bufnr,
|
||||||
|
self.lnum - 1,
|
||||||
|
self.col - 1,
|
||||||
|
self.lnum - 1,
|
||||||
|
self.col - 1,
|
||||||
|
lines
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
return Pos
|
return Pos
|
||||||
|
@ -37,7 +37,13 @@ function Range.new(start, stop, mode)
|
|||||||
|
|
||||||
local _1 = posstr(r.start)
|
local _1 = posstr(r.start)
|
||||||
local _2 = posstr(r.stop)
|
local _2 = posstr(r.stop)
|
||||||
return string.format('Range{bufnr=%d, mode=%s, start=%s, stop=%s}', r.start.bufnr, r.mode, _1, _2)
|
return string.format(
|
||||||
|
'Range{bufnr=%d, mode=%s, start=%s, stop=%s}',
|
||||||
|
r.start.bufnr,
|
||||||
|
r.mode,
|
||||||
|
_1,
|
||||||
|
_2
|
||||||
|
)
|
||||||
end
|
end
|
||||||
setmetatable(r, { __index = Range, __tostring = str })
|
setmetatable(r, { __index = Range, __tostring = str })
|
||||||
return r
|
return r
|
||||||
@ -164,7 +170,10 @@ function Range.from_motion(motion, opts)
|
|||||||
stop = stop:find_next(-1, motion_rest) or stop
|
stop = stop:find_next(-1, motion_rest) or stop
|
||||||
end
|
end
|
||||||
|
|
||||||
if opts.contains_cursor and not Range.new(start, stop):contains(Pos.new(unpack(original_state.cursor))) then
|
if
|
||||||
|
opts.contains_cursor
|
||||||
|
and not Range.new(start, stop):contains(Pos.new(unpack(original_state.cursor)))
|
||||||
|
then
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -246,7 +255,9 @@ function Range.smallest(ranges)
|
|||||||
return smallest
|
return smallest
|
||||||
end
|
end
|
||||||
|
|
||||||
function Range:clone() return Range.new(self.start:clone(), self.stop ~= nil and self.stop:clone() or nil, self.mode) end
|
function Range:clone()
|
||||||
|
return Range.new(self.start:clone(), self.stop ~= nil and self.stop:clone() or nil, self.mode)
|
||||||
|
end
|
||||||
function Range:line_count()
|
function Range:line_count()
|
||||||
if self:is_empty() then return 0 end
|
if self:is_empty() then return 0 end
|
||||||
return self.stop.lnum - self.start.lnum + 1
|
return self.stop.lnum - self.start.lnum + 1
|
||||||
@ -310,7 +321,8 @@ function Range:line(l)
|
|||||||
if l < 0 then l = self:line_count() + l + 1 end
|
if l < 0 then l = self:line_count() + l + 1 end
|
||||||
if l > self:line_count() then return end
|
if l > self:line_count() then return end
|
||||||
|
|
||||||
local line_indices = vim.fn.getregionpos(self.start:as_vim(), self.stop:as_vim(), { type = self.mode })
|
local line_indices =
|
||||||
|
vim.fn.getregionpos(self.start:as_vim(), self.stop:as_vim(), { type = self.mode })
|
||||||
local line_bounds = line_indices[l]
|
local line_bounds = line_indices[l]
|
||||||
|
|
||||||
local start = Pos.new(unpack(line_bounds[1]))
|
local start = Pos.new(unpack(line_bounds[1]))
|
||||||
@ -329,7 +341,9 @@ function Range:replace(replacement)
|
|||||||
local function update_stop_non_linewise()
|
local function update_stop_non_linewise()
|
||||||
local new_last_line_num = self.start.lnum + #replacement - 1
|
local new_last_line_num = self.start.lnum + #replacement - 1
|
||||||
local new_last_col = #(replacement[#replacement] or '')
|
local new_last_col = #(replacement[#replacement] or '')
|
||||||
if new_last_line_num == self.start.lnum then new_last_col = new_last_col + self.start.col - 1 end
|
if new_last_line_num == self.start.lnum then
|
||||||
|
new_last_col = new_last_col + self.start.col - 1
|
||||||
|
end
|
||||||
self.stop = Pos.new(bufnr, new_last_line_num, new_last_col)
|
self.stop = Pos.new(bufnr, new_last_line_num, new_last_col)
|
||||||
end
|
end
|
||||||
local function update_stop_linewise()
|
local function update_stop_linewise()
|
||||||
@ -399,7 +413,9 @@ end
|
|||||||
--- @param amount number
|
--- @param amount number
|
||||||
function Range:must_shrink(amount)
|
function Range:must_shrink(amount)
|
||||||
local shrunk = self:shrink(amount)
|
local shrunk = self:shrink(amount)
|
||||||
if shrunk == nil or shrunk:is_empty() then error 'error in Range:must_shrink: Range:shrink() returned nil' end
|
if shrunk == nil or shrunk:is_empty() then
|
||||||
|
error 'error in Range:must_shrink: Range:shrink() returned nil'
|
||||||
|
end
|
||||||
return shrunk
|
return shrunk
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -218,7 +218,8 @@ function Renderer:_reconcile() -- {{{
|
|||||||
self:_set_lines(lnum0, lnum0, true, { line_change.item })
|
self:_set_lines(lnum0, lnum0, true, { line_change.item })
|
||||||
elseif line_change.kind == 'change' then
|
elseif line_change.kind == 'change' then
|
||||||
-- Compute inter-line diff, and apply:
|
-- Compute inter-line diff, and apply:
|
||||||
local col_changes = H.levenshtein(vim.split(line_change.from, ''), vim.split(line_change.to, ''))
|
local col_changes =
|
||||||
|
H.levenshtein(vim.split(line_change.from, ''), vim.split(line_change.to, ''))
|
||||||
|
|
||||||
for _, col_change in ipairs(col_changes) do
|
for _, col_change in ipairs(col_changes) do
|
||||||
local cnum0 = col_change.index - 1
|
local cnum0 = col_change.index - 1
|
||||||
@ -310,7 +311,15 @@ function Renderer:get_pos_infos(pos0) -- {{{
|
|||||||
-- because the NeoVim API is over-inclusive in what it returns:
|
-- because the NeoVim API is over-inclusive in what it returns:
|
||||||
--- @type RendererExtmark[]
|
--- @type RendererExtmark[]
|
||||||
local intersecting_extmarks = vim
|
local intersecting_extmarks = vim
|
||||||
.iter(vim.api.nvim_buf_get_extmarks(self.bufnr, self.ns, pos0, pos0, { details = true, overlap = true }))
|
.iter(
|
||||||
|
vim.api.nvim_buf_get_extmarks(
|
||||||
|
self.bufnr,
|
||||||
|
self.ns,
|
||||||
|
pos0,
|
||||||
|
pos0,
|
||||||
|
{ details = true, overlap = true }
|
||||||
|
)
|
||||||
|
)
|
||||||
--- @return RendererExtmark
|
--- @return RendererExtmark
|
||||||
:map(function(ext)
|
:map(function(ext)
|
||||||
--- @type number, number, number, { end_row?: number; end_col?: number }|nil
|
--- @type number, number, number, { end_row?: number; end_col?: number }|nil
|
||||||
|
@ -37,7 +37,10 @@ function Signal:set(value)
|
|||||||
-- We don't handle cyclic updates:
|
-- We don't handle cyclic updates:
|
||||||
if self.changing then
|
if self.changing then
|
||||||
if M.debug then
|
if M.debug then
|
||||||
vim.notify('circular dependency detected' .. (self.name and (' in ' .. self.name) or ''), vim.log.levels.WARN)
|
vim.notify(
|
||||||
|
'circular dependency detected' .. (self.name and (' in ' .. self.name) or ''),
|
||||||
|
vim.log.levels.WARN
|
||||||
|
)
|
||||||
end
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
@ -143,7 +146,10 @@ function Signal:debounce(ms)
|
|||||||
local now_ms = (vim.uv or vim.loop).hrtime() / 1e6
|
local now_ms = (vim.uv or vim.loop).hrtime() / 1e6
|
||||||
|
|
||||||
-- If there is anything older than `ms` in our queue, emit it:
|
-- If there is anything older than `ms` in our queue, emit it:
|
||||||
local older_than_ms = vim.iter(state.queued):filter(function(item) return now_ms - item.ts > ms end):totable()
|
local older_than_ms = vim
|
||||||
|
.iter(state.queued)
|
||||||
|
:filter(function(item) return now_ms - item.ts > ms end)
|
||||||
|
:totable()
|
||||||
local last_older_than_ms = older_than_ms[#older_than_ms]
|
local last_older_than_ms = older_than_ms[#older_than_ms]
|
||||||
if last_older_than_ms then
|
if last_older_than_ms then
|
||||||
filtered:set(last_older_than_ms.value)
|
filtered:set(last_older_than_ms.value)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
call_parentheses = "None"
|
call_parentheses = "None"
|
||||||
collapse_simple_statement = "Always"
|
collapse_simple_statement = "Always"
|
||||||
column_width = 120
|
column_width = 100
|
||||||
indent_type = "Spaces"
|
indent_type = "Spaces"
|
||||||
indent_width = 2
|
indent_width = 2
|
||||||
quote_style = "AutoPreferSingle"
|
quote_style = "AutoPreferSingle"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user