chore(fmt): Finally let's use stylua
Hoping it's as good as go-fmt
This commit is contained in:
@@ -9,12 +9,7 @@ function M.nmap(bufnr, keys, action)
|
||||
end
|
||||
|
||||
for _, lhs in ipairs(keys) do
|
||||
vim.keymap.set(
|
||||
'n',
|
||||
lhs,
|
||||
action,
|
||||
{ silent = true, noremap = true, buffer = bufnr }
|
||||
)
|
||||
vim.keymap.set('n', lhs, action, { silent = true, noremap = true, buffer = bufnr })
|
||||
end
|
||||
end
|
||||
|
||||
@@ -114,7 +109,7 @@ function M.flash_highlight(winnr, lnum, durationMs, hl_group)
|
||||
if durationMs == false then
|
||||
return
|
||||
end
|
||||
hl_group = hl_group or "Visual"
|
||||
hl_group = hl_group or 'Visual'
|
||||
if durationMs == true or durationMs == 1 then
|
||||
durationMs = 500
|
||||
end
|
||||
@@ -131,13 +126,13 @@ end
|
||||
function M.echo(module, message)
|
||||
if not message then
|
||||
message = module
|
||||
module = ""
|
||||
module = ''
|
||||
end
|
||||
local prefix = "outline"
|
||||
if module ~= "" then
|
||||
prefix = prefix.."."..module
|
||||
local prefix = 'outline'
|
||||
if module ~= '' then
|
||||
prefix = prefix .. '.' .. module
|
||||
end
|
||||
local prefix_chunk = { '('..prefix..') ', "WarningMsg" }
|
||||
local prefix_chunk = { '(' .. prefix .. ') ', 'WarningMsg' }
|
||||
-- For now we don't echo much, so add all to history
|
||||
vim.api.nvim_echo({ prefix_chunk, { message } }, true, {})
|
||||
end
|
||||
|
||||
@@ -5,7 +5,7 @@ local SYMBOL_FRAGMENT = 28
|
||||
|
||||
local function get_open_tag(node)
|
||||
if node:type() == 'jsx_element' then
|
||||
for _, outer in ipairs(node:field 'open_tag') do
|
||||
for _, outer in ipairs(node:field('open_tag')) do
|
||||
if outer:type() == 'jsx_opening_element' then
|
||||
return outer
|
||||
end
|
||||
@@ -18,7 +18,7 @@ end
|
||||
local function jsx_node_detail(node, buf)
|
||||
node = get_open_tag(node) or node
|
||||
|
||||
local param_nodes = node:field 'attribute'
|
||||
local param_nodes = node:field('attribute')
|
||||
if #param_nodes == 0 then
|
||||
return nil
|
||||
end
|
||||
@@ -42,7 +42,7 @@ local function jsx_node_tagname(node, buf)
|
||||
|
||||
local identifier = nil
|
||||
|
||||
for _, val in ipairs(tagnode:field 'name') do
|
||||
for _, val in ipairs(tagnode:field('name')) do
|
||||
if val:type() == 'identifier' then
|
||||
identifier = val
|
||||
end
|
||||
@@ -66,8 +66,7 @@ local function convert_ts(child, children, bufnr)
|
||||
}
|
||||
|
||||
local converted = {
|
||||
name = (not is_frag and (jsx_node_tagname(child, bufnr) or '<unknown>'))
|
||||
or 'fragment',
|
||||
name = (not is_frag and (jsx_node_tagname(child, bufnr) or '<unknown>')) or 'fragment',
|
||||
children = (#children > 0 and children) or nil,
|
||||
kind = (is_frag and SYMBOL_FRAGMENT) or SYMBOL_COMPONENT,
|
||||
detail = jsx_node_detail(child, bufnr),
|
||||
@@ -82,12 +81,7 @@ function M.parse_ts(root, children, bufnr)
|
||||
children = children or {}
|
||||
|
||||
for child in root:iter_children() do
|
||||
if
|
||||
vim.tbl_contains(
|
||||
{ 'jsx_element', 'jsx_self_closing_element' },
|
||||
child:type()
|
||||
)
|
||||
then
|
||||
if vim.tbl_contains({ 'jsx_element', 'jsx_self_closing_element' }, child:type()) then
|
||||
local new_children = {}
|
||||
|
||||
M.parse_ts(child, new_children, bufnr)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
local config = require 'outline.config'
|
||||
local tbl_utils = require 'outline.utils.table'
|
||||
local config = require('outline.config')
|
||||
local tbl_utils = require('outline.utils.table')
|
||||
|
||||
local M = {}
|
||||
|
||||
@@ -16,7 +16,7 @@ end
|
||||
function M.flatten_response(response)
|
||||
local all_results = {}
|
||||
|
||||
-- flatten results to one giant table of symbols
|
||||
-- flatten results to one giant table of symbols
|
||||
for client_id, client_response in pairs(response) do
|
||||
if config.is_client_blacklisted(client_id) then
|
||||
print('skipping client ' .. client_id)
|
||||
@@ -51,8 +51,8 @@ end
|
||||
function M.get_range(token)
|
||||
if token == nil then
|
||||
return {
|
||||
start={ line=math.huge, character=math.huge },
|
||||
['end']={ line=-math.huge, character=-math.huge },
|
||||
start = { line = math.huge, character = math.huge },
|
||||
['end'] = { line = -math.huge, character = -math.huge },
|
||||
}
|
||||
end
|
||||
|
||||
@@ -87,10 +87,7 @@ end
|
||||
---Recursively sorts all children of each symbol
|
||||
function M.sort_symbols(symbols)
|
||||
table.sort(symbols, function(a, b)
|
||||
return range_compare(
|
||||
M.get_range(a).start,
|
||||
M.get_range(b).start
|
||||
)
|
||||
return range_compare(M.get_range(a).start, M.get_range(b).start)
|
||||
end)
|
||||
|
||||
for _, child in ipairs(symbols) do
|
||||
@@ -132,15 +129,17 @@ function M.symbol_preorder_iter(symbols)
|
||||
return stk[#stk]
|
||||
end
|
||||
|
||||
return { next=next, is_empty=is_empty, peek=peek }
|
||||
return { next = next, is_empty = is_empty, peek = peek }
|
||||
end
|
||||
|
||||
local function merge_symbols_rec(iter1, iter2, ub)
|
||||
local res = {}
|
||||
|
||||
while not (iter1.is_empty() and iter2.is_empty()) do
|
||||
local bv1 = ((not iter1.is_empty()) and M.get_range(iter1.peek()).start) or { line=math.huge, character=math.huge }
|
||||
local bv2 = ((not iter2.is_empty()) and M.get_range(iter2.peek()).start) or { line=math.huge, character=math.huge }
|
||||
local bv1 = ((not iter1.is_empty()) and M.get_range(iter1.peek()).start)
|
||||
or { line = math.huge, character = math.huge }
|
||||
local bv2 = ((not iter2.is_empty()) and M.get_range(iter2.peek()).start)
|
||||
or { line = math.huge, character = math.huge }
|
||||
|
||||
local iter = (range_compare(bv1, bv2) and iter1) or iter2
|
||||
|
||||
|
||||
@@ -28,14 +28,13 @@ function M.array_copy(t)
|
||||
return ret
|
||||
end
|
||||
|
||||
|
||||
--- Deep copy a table, deeply excluding certain keys
|
||||
function M.deepcopy_excluding(t, keys)
|
||||
local res = {}
|
||||
|
||||
|
||||
for key, value in pairs(t) do
|
||||
if not vim.tbl_contains(keys, key) then
|
||||
if type(value) == "table" then
|
||||
if type(value) == 'table' then
|
||||
res[key] = M.deepcopy_excluding(value, keys)
|
||||
else
|
||||
res[key] = value
|
||||
|
||||
Reference in New Issue
Block a user