mirror of
https://github.com/kevinhwang91/nvim-ufo
synced 2024-09-08 02:15:44 +02:00
chore: format code with latest options
This commit is contained in:
parent
138b39f5b2
commit
45aede6f5c
19 changed files with 96 additions and 98 deletions
|
@ -7,13 +7,10 @@ charset = utf-8
|
|||
trim_trailing_whitespace = true
|
||||
|
||||
[*.lua]
|
||||
align_call_args = only_not_exist_cross_row_expression
|
||||
align_table_field_to_first_field = true
|
||||
local_assign_continuation_align_to_first_expression = true
|
||||
keep_one_space_between_table_and_bracket = false
|
||||
align_continuous_assign_statement = false
|
||||
space_around_table_field_list = false
|
||||
align_call_args = false
|
||||
quote_style = single
|
||||
remove_empty_header_and_footer_lines_in_function = true
|
||||
remove_expression_list_finish_comma= true
|
||||
|
||||
[*.json,*.jsonc]
|
||||
indent_style = tab
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
local api = vim.api
|
||||
|
||||
local buffer = require('ufo.model.buffer')
|
||||
local event = require('ufo.lib.event')
|
||||
local buffer = require('ufo.model.buffer')
|
||||
local event = require('ufo.lib.event')
|
||||
local disposable = require('ufo.lib.disposable')
|
||||
local promise = require('promise')
|
||||
local utils = require('ufo.utils')
|
||||
local promise = require('promise')
|
||||
local utils = require('ufo.utils')
|
||||
|
||||
---@class UfoBufferManager
|
||||
---@field initialized boolean
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
local api = vim.api
|
||||
local fn = vim.fn
|
||||
local fn = vim.fn
|
||||
local cmd = vim.cmd
|
||||
|
||||
local utils = require('ufo.utils')
|
||||
local config = require('ufo.config')
|
||||
local log = require('ufo.lib.log')
|
||||
local utils = require('ufo.utils')
|
||||
local config = require('ufo.config')
|
||||
local log = require('ufo.lib.log')
|
||||
local disposable = require('ufo.lib.disposable')
|
||||
local event = require('ufo.lib.event')
|
||||
local event = require('ufo.lib.event')
|
||||
|
||||
local fold = require('ufo.fold')
|
||||
local render = require('ufo.render')
|
||||
|
@ -105,7 +105,7 @@ local function onEnd(name, tick)
|
|||
getFoldVirtText = function(l)
|
||||
assert(type(l) == 'number', 'expected a number, got ' .. type(l))
|
||||
assert(lnum <= l and l <= endLnum,
|
||||
('expected lnum range from %d to %d, got %d'):format(lnum, endLnum, l))
|
||||
('expected lnum range from %d to %d, got %d'):format(lnum, endLnum, l))
|
||||
local line = fb:lines(l)[1]
|
||||
return render.captureVirtText(bufnr, line, l, syntax, nss)
|
||||
end
|
||||
|
@ -197,7 +197,7 @@ function Decorator:highlightOpenFold(fb, winid, lnum)
|
|||
local _, winids = utils.getWinByBuf(fb.bufnr)
|
||||
local shared = winids ~= nil
|
||||
render.highlightLinesWithTimeout(shared and winid or fb.bufnr, 'UfoFoldedBg', self.hlNs,
|
||||
lnum, endLnum, self.openFoldHlTimeout, shared)
|
||||
lnum, endLnum, self.openFoldHlTimeout, shared)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
local api = vim.api
|
||||
local cmd = vim.cmd
|
||||
|
||||
local config = require('ufo.config')
|
||||
local promise = require('promise')
|
||||
local async = require('async')
|
||||
local utils = require('ufo.utils')
|
||||
local provider = require('ufo.provider')
|
||||
local log = require('ufo.lib.log')
|
||||
local event = require('ufo.lib.event')
|
||||
local manager = require('ufo.fold.manager')
|
||||
local config = require('ufo.config')
|
||||
local promise = require('promise')
|
||||
local async = require('async')
|
||||
local utils = require('ufo.utils')
|
||||
local provider = require('ufo.provider')
|
||||
local log = require('ufo.lib.log')
|
||||
local event = require('ufo.lib.event')
|
||||
local manager = require('ufo.fold.manager')
|
||||
local disposable = require('ufo.lib.disposable')
|
||||
|
||||
---@class UfoFold
|
||||
|
@ -226,7 +226,7 @@ function Fold:initialize(ns)
|
|||
event:on('BufAttach', Fold.attach, self.disposables)
|
||||
event:on('DiffModeChanged', handleDiffMode, self.disposables)
|
||||
table.insert(self.disposables, manager:initialize(ns, config.provider_selector,
|
||||
config.close_fold_kinds))
|
||||
config.close_fold_kinds))
|
||||
return self
|
||||
end
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
local buffer = require('ufo.model.foldbuffer')
|
||||
local event = require('ufo.lib.event')
|
||||
local buffer = require('ufo.model.foldbuffer')
|
||||
local event = require('ufo.lib.event')
|
||||
local disposable = require('ufo.lib.disposable')
|
||||
local bufmanager = require('ufo.bufmanager')
|
||||
local utils = require('ufo.utils')
|
||||
local driver = require('ufo.fold.driver')
|
||||
local log = require('ufo.lib.log')
|
||||
local utils = require('ufo.utils')
|
||||
local driver = require('ufo.fold.driver')
|
||||
local log = require('ufo.lib.log')
|
||||
|
||||
---@class UfoFoldBufferManager
|
||||
---@field initialized boolean
|
||||
|
|
|
@ -67,7 +67,7 @@ local function resetSignGroup()
|
|||
signNames = setmetatable({}, {
|
||||
__index = function(tbl, k)
|
||||
assert(fn.sign_define(k, {linehl = k}) == 0,
|
||||
'Define sign name ' .. k .. 'failed')
|
||||
'Define sign name ' .. k .. 'failed')
|
||||
rawset(tbl, k, k)
|
||||
return k
|
||||
end
|
||||
|
|
|
@ -15,8 +15,11 @@ local Debounce = {}
|
|||
---@param leading? boolean
|
||||
---@return UfoDebounce
|
||||
function Debounce:new(fn, wait, leading)
|
||||
vim.validate({fn = {fn, 'function'}, wait = {wait, 'number'},
|
||||
leading = {leading, 'boolean', true}})
|
||||
vim.validate({
|
||||
fn = {fn, 'function'},
|
||||
wait = {wait, 'number'},
|
||||
leading = {leading, 'boolean', true}
|
||||
})
|
||||
local o = setmetatable({}, self)
|
||||
o.timer = nil
|
||||
o.fn = vim.schedule_wrap(fn)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
local disposable = require('ufo.lib.disposable')
|
||||
local log = require('ufo.lib.log')
|
||||
local log = require('ufo.lib.log')
|
||||
|
||||
---@class UfoEvent
|
||||
local Event = {
|
||||
|
|
|
@ -2,12 +2,12 @@ local M = {}
|
|||
local cmd = vim.cmd
|
||||
local api = vim.api
|
||||
|
||||
local utils = require('ufo.utils')
|
||||
local provider = require('ufo.provider')
|
||||
local fold = require('ufo.fold')
|
||||
local decorator = require('ufo.decorator')
|
||||
local highlight = require('ufo.highlight')
|
||||
local preview = require('ufo.preview')
|
||||
local utils = require('ufo.utils')
|
||||
local provider = require('ufo.provider')
|
||||
local fold = require('ufo.fold')
|
||||
local decorator = require('ufo.decorator')
|
||||
local highlight = require('ufo.highlight')
|
||||
local preview = require('ufo.preview')
|
||||
local disposable = require('ufo.lib.disposable')
|
||||
local bufmanager = require('ufo.bufmanager')
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ function Buffer:attach()
|
|||
self._changedtick = changedtick
|
||||
self._lines = self:handleLinesChanged(self._lines, firstLine, lastLine, lastLineUpdated)
|
||||
event:emit('BufLinesChanged', bufnr, changedtick, firstLine, lastLine,
|
||||
lastLineUpdated, byteCount)
|
||||
lastLineUpdated, byteCount)
|
||||
end,
|
||||
on_changedtick = function(name, bufnr, changedtick)
|
||||
self._changedtick = changedtick
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
local api = vim.api
|
||||
local cmd = vim.cmd
|
||||
|
||||
local utils = require('ufo.utils')
|
||||
local buffer = require('ufo.model.buffer')
|
||||
local utils = require('ufo.utils')
|
||||
local buffer = require('ufo.model.buffer')
|
||||
local foldedline = require('ufo.model.foldedline')
|
||||
|
||||
---@class UfoFoldBuffer
|
||||
|
|
|
@ -29,7 +29,7 @@ local defaultBorder = {
|
|||
rounded = {'╭', '─', '╮', '│', '╯', '─', '╰', '│'},
|
||||
solid = {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
|
||||
shadow = {'', '', {' ', 'FloatShadowThrough'}, {' ', 'FloatShadow'},
|
||||
{' ', 'FloatShadow'}, {' ', 'FloatShadow'}, {' ', 'FloatShadowThrough'}, ''},
|
||||
{' ', 'FloatShadow'}, {' ', 'FloatShadow'}, {' ', 'FloatShadowThrough'}, ''},
|
||||
}
|
||||
|
||||
local function borderHasLine(border, index)
|
||||
|
|
|
@ -2,18 +2,18 @@ local api = vim.api
|
|||
local cmd = vim.cmd
|
||||
local fn = vim.fn
|
||||
|
||||
local promise = require('promise')
|
||||
local render = require('ufo.render')
|
||||
local utils = require('ufo.utils')
|
||||
local floatwin = require('ufo.preview.floatwin')
|
||||
local scrollbar = require('ufo.preview.scrollbar')
|
||||
local winbar = require('ufo.preview.winbar')
|
||||
local keymap = require('ufo.preview.keymap')
|
||||
local event = require('ufo.lib.event')
|
||||
local promise = require('promise')
|
||||
local render = require('ufo.render')
|
||||
local utils = require('ufo.utils')
|
||||
local floatwin = require('ufo.preview.floatwin')
|
||||
local scrollbar = require('ufo.preview.scrollbar')
|
||||
local winbar = require('ufo.preview.winbar')
|
||||
local keymap = require('ufo.preview.keymap')
|
||||
local event = require('ufo.lib.event')
|
||||
local disposable = require('ufo.lib.disposable')
|
||||
local config = require('ufo.config')
|
||||
local fold = require('ufo.fold')
|
||||
local highlight = require('ufo.highlight')
|
||||
local config = require('ufo.config')
|
||||
local fold = require('ufo.fold')
|
||||
local highlight = require('ufo.highlight')
|
||||
|
||||
---@class UfoPreview
|
||||
---@field initialized boolean
|
||||
|
@ -100,17 +100,17 @@ end
|
|||
|
||||
function Preview:scroll(char, toTopLeft)
|
||||
if self:winCall(function()
|
||||
local ctrlTbl = {B = 0x02, D = 0x04, E = 0x05, F = 0x06, U = 0x15, Y = 0x19}
|
||||
cmd(('norm! %c%s'):format(ctrlTbl[char], toTopLeft and 'H_' or ''))
|
||||
end) then
|
||||
local ctrlTbl = {B = 0x02, D = 0x04, E = 0x05, F = 0x06, U = 0x15, Y = 0x19}
|
||||
cmd(('norm! %c%s'):format(ctrlTbl[char], toTopLeft and 'H_' or ''))
|
||||
end) then
|
||||
self:viewChanged()
|
||||
end
|
||||
end
|
||||
|
||||
function Preview:jumpView(toBottom)
|
||||
if self:winCall(function()
|
||||
cmd(('norm! %s'):format(toBottom and 'GH_' or 'gg'))
|
||||
end) then
|
||||
cmd(('norm! %s'):format(toBottom and 'GH_' or 'gg'))
|
||||
end) then
|
||||
self:viewChanged()
|
||||
end
|
||||
end
|
||||
|
@ -120,8 +120,7 @@ function Preview:toggleCursor()
|
|||
local floatBufnr = floatwin:getBufnr()
|
||||
if self.bufnr == bufnr and self.lnum - self.foldedLnum > 0 then
|
||||
self.cursorSignId = fn.sign_place(self.cursorSignId or 0, 'UfoPreview',
|
||||
self.cursorSignName, floatBufnr,
|
||||
{lnum = self.lnum - self.foldedLnum + 1, priority = 1})
|
||||
self.cursorSignName, floatBufnr, {lnum = self.lnum - self.foldedLnum + 1, priority = 1})
|
||||
elseif self.cursorSignId then
|
||||
pcall(fn.sign_unplace, 'UfoPreview', {buffer = floatBufnr})
|
||||
self.cursorSignId = nil
|
||||
|
@ -290,8 +289,7 @@ function Preview:peekFoldedLinesUnderCursor(enter, nextLineIncluded)
|
|||
end)
|
||||
self:toggleCursor()
|
||||
render.mapHighlightLimitByRange(bufnr, floatwin:getBufnr(),
|
||||
{lnum - 1, 0}, {endLnum - 1, #text[endLnum - lnum + 1]},
|
||||
text, self.ns)
|
||||
{lnum - 1, 0}, {endLnum - 1, #text[endLnum - lnum + 1]}, text, self.ns)
|
||||
render.mapMatchByLnum(winid, floatwin.winid, lnum, endLnum)
|
||||
vim.wo[floatwin.winid].listchars = vim.wo[winid].listchars
|
||||
return floatwin.winid
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
local foldingrange = require('ufo.model.foldingrange')
|
||||
local bufmanager = require('ufo.bufmanager')
|
||||
local bufmanager = require('ufo.bufmanager')
|
||||
|
||||
local Indent = {}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
local uv = vim.loop
|
||||
|
||||
local promise = require('promise')
|
||||
local log = require('ufo.lib.log')
|
||||
local log = require('ufo.lib.log')
|
||||
|
||||
---@class Provider UfoProvider
|
||||
---@field modulePathPrefix string
|
||||
|
@ -52,7 +52,7 @@ function Provider:requestFoldingRange(providers, bufnr)
|
|||
p = p:finally(function()
|
||||
log.debug(('requestFoldingRange(%s, %d) has elapsed: %dms')
|
||||
:format(vim.inspect(providers, {indent = '', newline = ' '}),
|
||||
bufnr, (uv.hrtime() - s) / 1e6))
|
||||
bufnr, (uv.hrtime() - s) / 1e6))
|
||||
end)
|
||||
end
|
||||
return p
|
||||
|
@ -60,12 +60,12 @@ end
|
|||
|
||||
function Provider:initialize()
|
||||
self.modules = setmetatable({}, {
|
||||
__index = function(t, k)
|
||||
local ok, res = pcall(require, self.modulePathPrefix .. k)
|
||||
assert(ok, ([[Can't find a module in `%s%s`]]):format(self.modulePathPrefix, k))
|
||||
rawset(t, k, res)
|
||||
return res
|
||||
end
|
||||
__index = function(t, k)
|
||||
local ok, res = pcall(require, self.modulePathPrefix .. k)
|
||||
assert(ok, ([[Can't find a module in `%s%s`]]):format(self.modulePathPrefix, k))
|
||||
rawset(t, k, res)
|
||||
return res
|
||||
end
|
||||
})
|
||||
return self
|
||||
end
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
local uv = vim.loop
|
||||
|
||||
local promise = require('promise')
|
||||
local utils = require('ufo.utils')
|
||||
local log = require('ufo.lib.log')
|
||||
local promise = require('promise')
|
||||
local utils = require('ufo.utils')
|
||||
local log = require('ufo.lib.log')
|
||||
local bufmanager = require('ufo.bufmanager')
|
||||
|
||||
---@class UfoLSPProviderContext
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
local util = require('vim.lsp.util')
|
||||
local promise = require('promise')
|
||||
local utils = require('ufo.utils')
|
||||
local async = require('async')
|
||||
local log = require('ufo.lib.log')
|
||||
local util = require('vim.lsp.util')
|
||||
local promise = require('promise')
|
||||
local utils = require('ufo.utils')
|
||||
local async = require('async')
|
||||
local log = require('ufo.lib.log')
|
||||
local foldingrange = require('ufo.model.foldingrange')
|
||||
|
||||
---@class UfoLspNvimClient
|
||||
|
@ -75,17 +75,17 @@ function NvimClient.requestFoldingRange(bufnr, kind)
|
|||
error('UfoFallbackException')
|
||||
end
|
||||
local params = {textDocument = util.make_text_document_params(bufnr)}
|
||||
return NvimClient.request(client, 'textDocument/foldingRange',
|
||||
params, bufnr):thenCall(function(ranges)
|
||||
if not ranges then
|
||||
return {}
|
||||
end
|
||||
ranges = vim.tbl_filter(function(o)
|
||||
return (not kind or kind == o.kind) and o.startLine < o.endLine
|
||||
end, ranges)
|
||||
foldingrange.sortRanges(ranges)
|
||||
return ranges
|
||||
end)
|
||||
return NvimClient.request(client, 'textDocument/foldingRange', params, bufnr)
|
||||
:thenCall(function(ranges)
|
||||
if not ranges then
|
||||
return {}
|
||||
end
|
||||
ranges = vim.tbl_filter(function(o)
|
||||
return (not kind or kind == o.kind) and o.startLine < o.endLine
|
||||
end, ranges)
|
||||
foldingrange.sortRanges(ranges)
|
||||
return ranges
|
||||
end)
|
||||
end)
|
||||
end
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
local api = vim.api
|
||||
local fn = vim.fn
|
||||
|
||||
local highlight = require('ufo.highlight')
|
||||
local extmark = require('ufo.render.extmark')
|
||||
local highlight = require('ufo.highlight')
|
||||
local extmark = require('ufo.render.extmark')
|
||||
local treesitter = require('ufo.render.treesitter')
|
||||
local match = require('ufo.render.match')
|
||||
local utils = require('ufo.utils')
|
||||
local match = require('ufo.render.match')
|
||||
local utils = require('ufo.utils')
|
||||
|
||||
local M = {}
|
||||
|
||||
|
|
|
@ -197,7 +197,7 @@ end
|
|||
function M.getWinInfo(winid)
|
||||
local winfos = fn.getwininfo(winid)
|
||||
assert(type(winfos) == 'table' and #winfos == 1,
|
||||
'`getwininfo` expected 1 table with single element.')
|
||||
'`getwininfo` expected 1 table with single element.')
|
||||
return winfos[1]
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue