style: Run stylua

This commit is contained in:
charburgx
2022-08-17 16:14:47 -05:00
parent ced4e476cf
commit b275066e23
8 changed files with 60 additions and 38 deletions

View File

@@ -10,7 +10,9 @@ local folding = require 'symbols-outline.folding'
local M = {}
local function setup_global_autocmd()
if config.options.highlight_hovered_item or config.options.auto_unfold_hover then
if
config.options.highlight_hovered_item or config.options.auto_unfold_hover
then
vim.api.nvim_create_autocmd('CursorHold', {
pattern = '*',
callback = function()
@@ -70,7 +72,10 @@ local function _update_lines()
end
local function _merge_items(items)
utils.merge_items_rec({ children = items }, { children = M.state.outline_items })
utils.merge_items_rec(
{ children = items },
{ children = M.state.outline_items }
)
end
local function __refresh()
@@ -192,7 +197,10 @@ function M._highlight_current_item(winnr)
local cb = function(value)
value.hovered = nil
if value.line == hovered_line or (hovered_line > value.range_start and hovered_line < value.range_end) then
if
value.line == hovered_line
or (hovered_line > value.range_start and hovered_line < value.range_end)
then
value.hovered = true
leaf_node = value
end
@@ -205,8 +213,8 @@ function M._highlight_current_item(winnr)
if leaf_node then
for index, node in ipairs(M.state.flattened_outline_items) do
if node == leaf_node then
vim.api.nvim_win_set_cursor(M.view.winnr, { index, 1 })
break
vim.api.nvim_win_set_cursor(M.view.winnr, { index, 1 })
break
end
end
end
@@ -228,9 +236,12 @@ local function setup_keymaps(bufnr)
map(
config.options.keymaps.hover_symbol,
require('symbols-outline.hover').show_hover
)
)
-- preview symbol
map(config.options.keymaps.toggle_preview, require('symbols-outline.preview').toggle)
map(
config.options.keymaps.toggle_preview,
require('symbols-outline.preview').toggle
)
-- rename symbol
map(
config.options.keymaps.rename_symbol,
@@ -251,23 +262,23 @@ local function setup_keymaps(bufnr)
M.view:close()
end)
-- fold selection
map( config.options.keymaps.fold, function ()
map(config.options.keymaps.fold, function()
M._set_folded(true)
end)
-- unfold selection
map(config.options.keymaps.unfold, function ()
map(config.options.keymaps.unfold, function()
M._set_folded(false)
end)
-- fold all
map(config.options.keymaps.fold_all, function ()
map(config.options.keymaps.fold_all, function()
M._set_all_folded(true)
end)
-- unfold all
map(config.options.keymaps.unfold_all, function ()
map(config.options.keymaps.unfold_all, function()
M._set_all_folded(false)
end)
-- fold reset
map(config.options.keymaps.fold_reset,function ()
map(config.options.keymaps.fold_reset, function()
M._set_all_folded(nil)
end)
end

View File

@@ -25,4 +25,3 @@ M.is_folded = function(node)
end
return M

View File

@@ -25,7 +25,7 @@ function M.show_hover()
hover_params.bufnr,
'textDocument/hover',
hover_params,
---@diagnostic disable-next-line: param-type-mismatch
---@diagnostic disable-next-line: param-type-mismatch
function(_, result, _, config)
if not (result and result.contents) then
-- return { 'No information available' }

View File

@@ -65,7 +65,6 @@ local function parse_result(result, depth, hierarchy, parent)
end
node.children = children
end
end
return ret
@@ -230,8 +229,11 @@ function M.get_lines(flattened_outline_items)
elseif not node.hierarchy[index] and depth > 1 then
line[index + marker_space] = ui.markers.vertical
add_guide_hl(
running_length - 1 + 2*marker_space,
running_length + vim.fn.strlen(ui.markers.vertical) - 1 + 2 * marker_space
running_length - 1 + 2 * marker_space,
running_length
+ vim.fn.strlen(ui.markers.vertical)
- 1
+ 2 * marker_space
)
end
end

View File

@@ -8,15 +8,12 @@ function M.should_use_provider(bufnr)
end
function M.hover_info(_, _, on_info)
on_info(
nil,
{
contents = {
kind = 'markdown',
contents = { 'No extra information availaible!' },
},
}
)
on_info(nil, {
contents = {
kind = 'markdown',
contents = { 'No extra information availaible!' },
},
})
end
---@param on_symbols function

View File

@@ -23,15 +23,12 @@ function M.hover_info(bufnr, params, on_info)
end
if not used_client then
on_info(
nil,
{
contents = {
kind = 'markdown',
content = { 'No extra information availaible!' },
},
}
)
on_info(nil, {
contents = {
kind = 'markdown',
content = { 'No extra information availaible!' },
},
})
end
used_client.request('textDocument/hover', params, on_info, bufnr)

View File

@@ -52,7 +52,19 @@ M.merge_items_rec = function(new_node, old_node, index, parent)
failed = true
else
for key, _ in pairs(new_node) do
if vim.tbl_contains({ 'parent', 'children', 'folded', 'hovered', 'line_in_outline', 'hierarchy' }, key) then
if
vim.tbl_contains(
{
'parent',
'children',
'folded',
'hovered',
'line_in_outline',
'hierarchy',
},
key
)
then
goto continue
end

View File

@@ -72,9 +72,13 @@ M.add_hover_highlights = function(bufnr, nodes)
if not node.hovered then
goto continue
end
local marker_fac = (config.options.fold_markers and 1) or 0
ui.add_hover_highlight(bufnr, node.line_in_outline - 1, (node.depth + marker_fac) * 2)
ui.add_hover_highlight(
bufnr,
node.line_in_outline - 1,
(node.depth + marker_fac) * 2
)
::continue::
end
end