style: Run stylua
This commit is contained in:
@@ -10,7 +10,9 @@ local folding = require 'symbols-outline.folding'
|
|||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
local function setup_global_autocmd()
|
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', {
|
vim.api.nvim_create_autocmd('CursorHold', {
|
||||||
pattern = '*',
|
pattern = '*',
|
||||||
callback = function()
|
callback = function()
|
||||||
@@ -70,7 +72,10 @@ local function _update_lines()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function _merge_items(items)
|
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
|
end
|
||||||
|
|
||||||
local function __refresh()
|
local function __refresh()
|
||||||
@@ -192,7 +197,10 @@ function M._highlight_current_item(winnr)
|
|||||||
local cb = function(value)
|
local cb = function(value)
|
||||||
value.hovered = nil
|
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
|
value.hovered = true
|
||||||
leaf_node = value
|
leaf_node = value
|
||||||
end
|
end
|
||||||
@@ -205,8 +213,8 @@ function M._highlight_current_item(winnr)
|
|||||||
if leaf_node then
|
if leaf_node then
|
||||||
for index, node in ipairs(M.state.flattened_outline_items) do
|
for index, node in ipairs(M.state.flattened_outline_items) do
|
||||||
if node == leaf_node then
|
if node == leaf_node then
|
||||||
vim.api.nvim_win_set_cursor(M.view.winnr, { index, 1 })
|
vim.api.nvim_win_set_cursor(M.view.winnr, { index, 1 })
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -228,9 +236,12 @@ local function setup_keymaps(bufnr)
|
|||||||
map(
|
map(
|
||||||
config.options.keymaps.hover_symbol,
|
config.options.keymaps.hover_symbol,
|
||||||
require('symbols-outline.hover').show_hover
|
require('symbols-outline.hover').show_hover
|
||||||
)
|
)
|
||||||
-- preview symbol
|
-- 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
|
-- rename symbol
|
||||||
map(
|
map(
|
||||||
config.options.keymaps.rename_symbol,
|
config.options.keymaps.rename_symbol,
|
||||||
@@ -251,23 +262,23 @@ local function setup_keymaps(bufnr)
|
|||||||
M.view:close()
|
M.view:close()
|
||||||
end)
|
end)
|
||||||
-- fold selection
|
-- fold selection
|
||||||
map( config.options.keymaps.fold, function ()
|
map(config.options.keymaps.fold, function()
|
||||||
M._set_folded(true)
|
M._set_folded(true)
|
||||||
end)
|
end)
|
||||||
-- unfold selection
|
-- unfold selection
|
||||||
map(config.options.keymaps.unfold, function ()
|
map(config.options.keymaps.unfold, function()
|
||||||
M._set_folded(false)
|
M._set_folded(false)
|
||||||
end)
|
end)
|
||||||
-- fold all
|
-- fold all
|
||||||
map(config.options.keymaps.fold_all, function ()
|
map(config.options.keymaps.fold_all, function()
|
||||||
M._set_all_folded(true)
|
M._set_all_folded(true)
|
||||||
end)
|
end)
|
||||||
-- unfold all
|
-- unfold all
|
||||||
map(config.options.keymaps.unfold_all, function ()
|
map(config.options.keymaps.unfold_all, function()
|
||||||
M._set_all_folded(false)
|
M._set_all_folded(false)
|
||||||
end)
|
end)
|
||||||
-- fold reset
|
-- fold reset
|
||||||
map(config.options.keymaps.fold_reset,function ()
|
map(config.options.keymaps.fold_reset, function()
|
||||||
M._set_all_folded(nil)
|
M._set_all_folded(nil)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -25,4 +25,3 @@ M.is_folded = function(node)
|
|||||||
end
|
end
|
||||||
|
|
||||||
return M
|
return M
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ function M.show_hover()
|
|||||||
hover_params.bufnr,
|
hover_params.bufnr,
|
||||||
'textDocument/hover',
|
'textDocument/hover',
|
||||||
hover_params,
|
hover_params,
|
||||||
---@diagnostic disable-next-line: param-type-mismatch
|
---@diagnostic disable-next-line: param-type-mismatch
|
||||||
function(_, result, _, config)
|
function(_, result, _, config)
|
||||||
if not (result and result.contents) then
|
if not (result and result.contents) then
|
||||||
-- return { 'No information available' }
|
-- return { 'No information available' }
|
||||||
|
|||||||
@@ -65,7 +65,6 @@ local function parse_result(result, depth, hierarchy, parent)
|
|||||||
end
|
end
|
||||||
|
|
||||||
node.children = children
|
node.children = children
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return ret
|
return ret
|
||||||
@@ -230,8 +229,11 @@ function M.get_lines(flattened_outline_items)
|
|||||||
elseif not node.hierarchy[index] and depth > 1 then
|
elseif not node.hierarchy[index] and depth > 1 then
|
||||||
line[index + marker_space] = ui.markers.vertical
|
line[index + marker_space] = ui.markers.vertical
|
||||||
add_guide_hl(
|
add_guide_hl(
|
||||||
running_length - 1 + 2*marker_space,
|
running_length - 1 + 2 * marker_space,
|
||||||
running_length + vim.fn.strlen(ui.markers.vertical) - 1 + 2 * marker_space
|
running_length
|
||||||
|
+ vim.fn.strlen(ui.markers.vertical)
|
||||||
|
- 1
|
||||||
|
+ 2 * marker_space
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -8,15 +8,12 @@ function M.should_use_provider(bufnr)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function M.hover_info(_, _, on_info)
|
function M.hover_info(_, _, on_info)
|
||||||
on_info(
|
on_info(nil, {
|
||||||
nil,
|
contents = {
|
||||||
{
|
kind = 'markdown',
|
||||||
contents = {
|
contents = { 'No extra information availaible!' },
|
||||||
kind = 'markdown',
|
},
|
||||||
contents = { 'No extra information availaible!' },
|
})
|
||||||
},
|
|
||||||
}
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param on_symbols function
|
---@param on_symbols function
|
||||||
|
|||||||
@@ -23,15 +23,12 @@ function M.hover_info(bufnr, params, on_info)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if not used_client then
|
if not used_client then
|
||||||
on_info(
|
on_info(nil, {
|
||||||
nil,
|
contents = {
|
||||||
{
|
kind = 'markdown',
|
||||||
contents = {
|
content = { 'No extra information availaible!' },
|
||||||
kind = 'markdown',
|
},
|
||||||
content = { 'No extra information availaible!' },
|
})
|
||||||
},
|
|
||||||
}
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
used_client.request('textDocument/hover', params, on_info, bufnr)
|
used_client.request('textDocument/hover', params, on_info, bufnr)
|
||||||
|
|||||||
@@ -52,7 +52,19 @@ M.merge_items_rec = function(new_node, old_node, index, parent)
|
|||||||
failed = true
|
failed = true
|
||||||
else
|
else
|
||||||
for key, _ in pairs(new_node) do
|
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
|
goto continue
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -72,9 +72,13 @@ M.add_hover_highlights = function(bufnr, nodes)
|
|||||||
if not node.hovered then
|
if not node.hovered then
|
||||||
goto continue
|
goto continue
|
||||||
end
|
end
|
||||||
|
|
||||||
local marker_fac = (config.options.fold_markers and 1) or 0
|
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::
|
::continue::
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user