chore(fmt): Finally let's use stylua
Hoping it's as good as go-fmt
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1 +1,2 @@
|
||||
doc/tags
|
||||
*.patch
|
||||
|
||||
12
.stylua.toml
Normal file
12
.stylua.toml
Normal file
@@ -0,0 +1,12 @@
|
||||
column_width = 100
|
||||
line_endings = 'Unix'
|
||||
indent_type = 'Spaces'
|
||||
indent_width = 2
|
||||
# Not very good looking in general, but faster to type
|
||||
quote_style = 'AutoPreferSingle'
|
||||
# Since there are ambiguities sometimes let's just not use this shortcut
|
||||
# alltogether
|
||||
call_parentheses = 'Always'
|
||||
|
||||
[sort_requires]
|
||||
enabled = true
|
||||
@@ -1,4 +1,4 @@
|
||||
local main = require 'outline'
|
||||
local main = require('outline')
|
||||
|
||||
local M = {}
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
local utils = require('outline.utils')
|
||||
|
||||
local M = {}
|
||||
local all_kinds = {'File', 'Module', 'Namespace', 'Package', 'Class', 'Method', 'Property', 'Field', 'Constructor', 'Enum', 'Interface', 'Function', 'Variable', 'Constant', 'String', 'Number', 'Boolean', 'Array', 'Object', 'Key', 'Null', 'EnumMember', 'Struct', 'Event', 'Operator', 'TypeParameter', 'Component', 'Fragment', 'TypeAlias', 'Parameter', 'StaticMethod', 'Macro',}
|
||||
-- stylua: ignore start
|
||||
local all_kinds = {'File', 'Module', 'Namespace', 'Package', 'Class', 'Method', 'Property', 'Field', 'Constructor', 'Enum', 'Interface', 'Function', 'Variable', 'Constant', 'String', 'Number', 'Boolean', 'Array', 'Object', 'Key', 'Null', 'EnumMember', 'Struct', 'Event', 'Operator', 'TypeParameter', 'Component', 'Fragment', 'TypeAlias', 'Parameter', 'StaticMethod', 'Macro'}
|
||||
-- stylua: ignore end
|
||||
|
||||
M.defaults = {
|
||||
guides = {
|
||||
@@ -31,7 +33,7 @@ M.defaults = {
|
||||
show_relative_numbers = false,
|
||||
show_cursorline = true,
|
||||
hide_cursor = false,
|
||||
winhl = "OutlineDetails:Comment,OutlineLineno:LineNr",
|
||||
winhl = 'OutlineDetails:Comment,OutlineLineno:LineNr',
|
||||
jump_highlight_duration = 500,
|
||||
},
|
||||
preview_window = {
|
||||
@@ -55,7 +57,7 @@ M.defaults = {
|
||||
goto_location = '<Cr>',
|
||||
peek_location = 'o',
|
||||
goto_and_close = '<S-Cr>',
|
||||
restore_location = "<C-g>",
|
||||
restore_location = '<C-g>',
|
||||
hover_symbol = '<C-space>',
|
||||
toggle_preview = 'K',
|
||||
rename_symbol = 'r',
|
||||
@@ -111,7 +113,7 @@ M.defaults = {
|
||||
Component = { icon = '', hl = '@function' },
|
||||
Fragment = { icon = '', hl = '@constant' },
|
||||
-- ccls
|
||||
TypeAlias = { icon = ' ', hl = '@type' },
|
||||
TypeAlias = { icon = ' ', hl = '@type' },
|
||||
Parameter = { icon = ' ', hl = '@parameter' },
|
||||
StaticMethod = { icon = ' ', hl = '@function' },
|
||||
Macro = { icon = ' ', hl = '@macro' },
|
||||
@@ -248,7 +250,7 @@ function M.get_providers()
|
||||
end
|
||||
|
||||
function M.show_help()
|
||||
print 'Current keymaps:'
|
||||
print('Current keymaps:')
|
||||
print(vim.inspect(M.o.keymaps))
|
||||
end
|
||||
|
||||
@@ -256,7 +258,7 @@ end
|
||||
-- Does not alter the opts. Might show messages.
|
||||
function M.check_config()
|
||||
if M.o.outline_window.hide_cursor and not M.o.outline_window.show_cursorline then
|
||||
utils.echo("config", "Warning: hide_cursor enabled without cursorline enabled")
|
||||
utils.echo('config', 'Warning: hide_cursor enabled without cursorline enabled')
|
||||
end
|
||||
end
|
||||
|
||||
@@ -277,7 +279,7 @@ function M.resolve_config()
|
||||
-- This should not be needed, nor is it failsafe. But in case user only provides
|
||||
-- the, eg, "topleft", we append the ' vs'.
|
||||
if not sc:find(' vs', 1, true) then
|
||||
M.o.outline_window.split_command = sc..' vs'
|
||||
M.o.outline_window.split_command = sc .. ' vs'
|
||||
end
|
||||
end
|
||||
----- COMPAT (renaming) -----
|
||||
@@ -307,10 +309,16 @@ end
|
||||
---@return T
|
||||
local function validate_filter_list(l, name)
|
||||
if type(l) == 'boolean' and l then
|
||||
utils.echo("config", ("Setting %s to true is undefined behaviour. Defaulting to nil."):format(name))
|
||||
utils.echo(
|
||||
'config',
|
||||
('Setting %s to true is undefined behaviour. Defaulting to nil.'):format(name)
|
||||
)
|
||||
l = nil
|
||||
elseif l and type(l) ~= 'table' and type(l) ~= 'boolean' then
|
||||
utils.echo("config", ("%s must either be a table, false, or nil. Defaulting to nil."):format(name))
|
||||
utils.echo(
|
||||
'config',
|
||||
('%s must either be a table, false, or nil. Defaulting to nil.'):format(name)
|
||||
)
|
||||
l = nil
|
||||
end
|
||||
return l
|
||||
@@ -321,7 +329,7 @@ end
|
||||
function M.resolve_filter_config()
|
||||
---@type outline.FilterConfig
|
||||
local tmp = M.o.symbols.filter
|
||||
tmp = validate_filter_list(tmp, "symbols.filter")
|
||||
tmp = validate_filter_list(tmp, 'symbols.filter')
|
||||
|
||||
---- legacy form -> ft filter list ----
|
||||
if table_has_content(M.o.symbols.blacklist) then
|
||||
@@ -337,7 +345,7 @@ function M.resolve_filter_config()
|
||||
if not table_has_content(tmp) then
|
||||
tmp = { ['*'] = { exclude = true } }
|
||||
|
||||
-- Lazy filter list -> ft filter list
|
||||
-- Lazy filter list -> ft filter list
|
||||
elseif tmp[1] then
|
||||
if type(tmp[1]) == 'string' then
|
||||
tmp = { ['*'] = vim.deepcopy(tmp) }
|
||||
@@ -365,7 +373,10 @@ function M.resolve_filter_config()
|
||||
-- }
|
||||
for ft, list in pairs(filter) do
|
||||
if type(ft) ~= 'string' then
|
||||
utils.echo("config", "ft (keys) for symbols.filter table can only be string. Skipping this ft.")
|
||||
utils.echo(
|
||||
'config',
|
||||
'ft (keys) for symbols.filter table can only be string. Skipping this ft.'
|
||||
)
|
||||
goto continue
|
||||
end
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
local M = {}
|
||||
local cfg = require 'outline.config'
|
||||
local cfg = require('outline.config')
|
||||
|
||||
---@param node outline.SymbolNode|outline.FlatSymbolNode
|
||||
function M.is_foldable(node)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
local outline = require 'outline'
|
||||
local cfg = require 'outline.config'
|
||||
local cfg = require('outline.config')
|
||||
local outline = require('outline')
|
||||
local util = vim.lsp.util
|
||||
|
||||
local M = {}
|
||||
@@ -31,9 +31,7 @@ function M.show_hover()
|
||||
if not (result and result.contents) then
|
||||
return
|
||||
end
|
||||
local markdown_lines = util.convert_input_to_markdown_lines(
|
||||
result.contents
|
||||
)
|
||||
local markdown_lines = util.convert_input_to_markdown_lines(result.contents)
|
||||
markdown_lines = util.trim_empty_lines(markdown_lines)
|
||||
if vim.tbl_isempty(markdown_lines) then
|
||||
return
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
local parser = require 'outline.parser'
|
||||
local providers = require 'outline.providers.init'
|
||||
local ui = require 'outline.ui'
|
||||
local writer = require 'outline.writer'
|
||||
local cfg = require 'outline.config'
|
||||
local utils = require 'outline.utils.init'
|
||||
local View = require 'outline.view'
|
||||
local folding = require 'outline.folding'
|
||||
local View = require('outline.view')
|
||||
local cfg = require('outline.config')
|
||||
local folding = require('outline.folding')
|
||||
local parser = require('outline.parser')
|
||||
local providers = require('outline.providers.init')
|
||||
local ui = require('outline.ui')
|
||||
local utils = require('outline.utils.init')
|
||||
local writer = require('outline.writer')
|
||||
|
||||
local M = {}
|
||||
|
||||
local function setup_global_autocmd()
|
||||
if
|
||||
cfg.o.outline_items.highlight_hovered_item or cfg.o.symbol_folding.auto_unfold_hover
|
||||
then
|
||||
if cfg.o.outline_items.highlight_hovered_item or cfg.o.symbol_folding.auto_unfold_hover then
|
||||
vim.api.nvim_create_autocmd('CursorHold', {
|
||||
pattern = '*',
|
||||
callback = function()
|
||||
@@ -54,24 +52,26 @@ M.state = {
|
||||
}
|
||||
|
||||
local function wipe_state()
|
||||
M.state = { outline_items = {}, flattened_outline_items = {}, code_win = 0, opts = {} }
|
||||
M.state = {
|
||||
outline_items = {},
|
||||
flattened_outline_items = {},
|
||||
code_win = 0,
|
||||
opts = {},
|
||||
}
|
||||
end
|
||||
|
||||
local function _update_lines()
|
||||
M.state.flattened_outline_items = writer.make_outline(M.view.bufnr, M.state.outline_items, M.state.code_win)
|
||||
M.state.flattened_outline_items =
|
||||
writer.make_outline(M.view.bufnr, M.state.outline_items, M.state.code_win)
|
||||
end
|
||||
|
||||
---@param items outline.SymbolNode[]
|
||||
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()
|
||||
local current_buffer_is_outline = M.view.bufnr
|
||||
== vim.api.nvim_get_current_buf()
|
||||
local current_buffer_is_outline = M.view.bufnr == vim.api.nvim_get_current_buf()
|
||||
if M.view:is_open() and not current_buffer_is_outline then
|
||||
local function refresh_handler(response)
|
||||
if response == nil or type(response) ~= 'table' then
|
||||
@@ -101,10 +101,7 @@ end
|
||||
---@param change_focus boolean
|
||||
function M.__goto_location(change_focus)
|
||||
local node = M._current_node()
|
||||
vim.api.nvim_win_set_cursor(
|
||||
M.state.code_win,
|
||||
{ node.line + 1, node.character }
|
||||
)
|
||||
vim.api.nvim_win_set_cursor(M.state.code_win, { node.line + 1, node.character })
|
||||
|
||||
if vim.fn.hlexists('OutlineJumpHighlight') == 0 then
|
||||
vim.api.nvim_set_hl(0, 'OutlineJumpHighlight', { link = 'Visual' })
|
||||
@@ -159,8 +156,8 @@ end
|
||||
local function hide_cursor()
|
||||
-- Set cursor color to CursorLine in normal mode
|
||||
M.state.original_cursor = vim.o.guicursor
|
||||
local cur = vim.o.guicursor:match("n.-:(.-)[-,]")
|
||||
vim.opt.guicursor:append("n:"..cur.."-Cursorline")
|
||||
local cur = vim.o.guicursor:match('n.-:(.-)[-,]')
|
||||
vim.opt.guicursor:append('n:' .. cur .. '-Cursorline')
|
||||
end
|
||||
|
||||
local function unhide_cursor()
|
||||
@@ -187,7 +184,7 @@ local function setup_buffer_autocmd()
|
||||
callback = function()
|
||||
-- Don't use _goto_location because we don't want to auto-close
|
||||
M.__goto_location(false)
|
||||
end
|
||||
end,
|
||||
})
|
||||
end
|
||||
if cfg.o.outline_window.hide_cursor then
|
||||
@@ -196,11 +193,11 @@ local function setup_buffer_autocmd()
|
||||
hide_cursor()
|
||||
vim.api.nvim_create_autocmd('BufEnter', {
|
||||
buffer = 0,
|
||||
callback = hide_cursor
|
||||
callback = hide_cursor,
|
||||
})
|
||||
vim.api.nvim_create_autocmd('BufLeave', {
|
||||
buffer = 0,
|
||||
callback = unhide_cursor
|
||||
callback = unhide_cursor,
|
||||
})
|
||||
end
|
||||
end
|
||||
@@ -221,15 +218,10 @@ function M._set_folded(folded, move_cursor, node_index)
|
||||
|
||||
_update_lines()
|
||||
elseif node.parent then
|
||||
local parent_node =
|
||||
M.state.flattened_outline_items[node.parent.line_in_outline]
|
||||
local parent_node = M.state.flattened_outline_items[node.parent.line_in_outline]
|
||||
|
||||
if parent_node then
|
||||
M._set_folded(
|
||||
folded,
|
||||
not parent_node.folded and folded,
|
||||
parent_node.line_in_outline
|
||||
)
|
||||
M._set_folded(folded, not parent_node.folded and folded, parent_node.line_in_outline)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -271,8 +263,7 @@ end
|
||||
function M._highlight_current_item(winnr)
|
||||
local has_provider = M.has_provider()
|
||||
local has_outline_open = M.view:is_open()
|
||||
local current_buffer_is_outline = M.view.bufnr
|
||||
== vim.api.nvim_get_current_buf()
|
||||
local current_buffer_is_outline = M.view.bufnr == vim.api.nvim_get_current_buf()
|
||||
|
||||
if not has_provider then
|
||||
return
|
||||
@@ -304,7 +295,11 @@ function M._highlight_current_item(winnr)
|
||||
|
||||
-- Must not skip folded nodes so that when user unfolds a parent, they can see the leaf
|
||||
-- node highlighted.
|
||||
for value in parser.preorder_iter(M.state.outline_items, function() return true end) do
|
||||
for value in
|
||||
parser.preorder_iter(M.state.outline_items, function()
|
||||
return true
|
||||
end)
|
||||
do
|
||||
value.hovered = nil
|
||||
|
||||
if
|
||||
@@ -372,30 +367,15 @@ local function setup_keymaps(bufnr)
|
||||
M._move_and_jump('up')
|
||||
end)
|
||||
-- hover symbol
|
||||
map(
|
||||
cfg.o.keymaps.hover_symbol,
|
||||
require('outline.hover').show_hover
|
||||
)
|
||||
map(cfg.o.keymaps.hover_symbol, require('outline.hover').show_hover)
|
||||
-- preview symbol
|
||||
map(
|
||||
cfg.o.keymaps.toggle_preview,
|
||||
require('outline.preview').toggle
|
||||
)
|
||||
map(cfg.o.keymaps.toggle_preview, require('outline.preview').toggle)
|
||||
-- rename symbol
|
||||
map(
|
||||
cfg.o.keymaps.rename_symbol,
|
||||
require('outline.rename').rename
|
||||
)
|
||||
map(cfg.o.keymaps.rename_symbol, require('outline.rename').rename)
|
||||
-- code actions
|
||||
map(
|
||||
cfg.o.keymaps.code_actions,
|
||||
require('outline.code_action').show_code_actions
|
||||
)
|
||||
map(cfg.o.keymaps.code_actions, require('outline.code_action').show_code_actions)
|
||||
-- show help
|
||||
map(
|
||||
cfg.o.keymaps.show_help,
|
||||
require('outline.config').show_help
|
||||
)
|
||||
map(cfg.o.keymaps.show_help, require('outline.config').show_help)
|
||||
-- close outline
|
||||
map(cfg.o.keymaps.close, function()
|
||||
M.view:close()
|
||||
@@ -502,9 +482,7 @@ end
|
||||
|
||||
function M._map_follow_cursor()
|
||||
if not M.follow_cursor({ focus_outline = true }) then
|
||||
utils.echo(
|
||||
"Code window no longer active. Try closing and reopening the outline."
|
||||
)
|
||||
utils.echo('Code window no longer active. Try closing and reopening the outline.')
|
||||
end
|
||||
end
|
||||
|
||||
@@ -527,7 +505,7 @@ local function _cmd_open_with_mods(fn)
|
||||
return function(opts)
|
||||
local old_sc, use_old_sc
|
||||
local split = opts.smods.split
|
||||
if split ~= "" then
|
||||
if split ~= '' then
|
||||
old_sc = cfg.o.outline_window.split_command
|
||||
use_old_sc = true
|
||||
cfg.o.outline_window.split_command = split .. ' vsplit'
|
||||
@@ -545,7 +523,6 @@ local function _cmd_open_with_mods(fn)
|
||||
else
|
||||
fn({ focus_outline = true, on_outline_setup = on_outline_setup })
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -558,7 +535,7 @@ function M.open_outline(opts)
|
||||
if not M.view:is_open() then
|
||||
local found = providers.request_symbols(handler, opts)
|
||||
if not found then
|
||||
utils.echo("No providers found for current buffer")
|
||||
utils.echo('No providers found for current buffer')
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -618,25 +595,25 @@ function M.show_status()
|
||||
end
|
||||
|
||||
if p ~= nil then
|
||||
print("Current provider: " .. p.name)
|
||||
print('Current provider: ' .. p.name)
|
||||
if p.get_status then
|
||||
print(p.get_status())
|
||||
print()
|
||||
end
|
||||
|
||||
if M.view:is_open() then
|
||||
print("Outline window is open.")
|
||||
print('Outline window is open.')
|
||||
else
|
||||
print("Outline window is not open.")
|
||||
print('Outline window is not open.')
|
||||
end
|
||||
|
||||
if require('outline.preview').has_code_win() then
|
||||
print("Code window is active.")
|
||||
print('Code window is active.')
|
||||
else
|
||||
print("Code window is either closed or invalid. Please close and reopen the outline window.")
|
||||
print('Code window is either closed or invalid. Please close and reopen the outline window.')
|
||||
end
|
||||
else
|
||||
print("No providers")
|
||||
print('No providers')
|
||||
end
|
||||
end
|
||||
|
||||
@@ -659,17 +636,17 @@ end
|
||||
|
||||
local function setup_commands()
|
||||
local cmd = function(n, c, o)
|
||||
vim.api.nvim_create_user_command('Outline'..n, c, o)
|
||||
vim.api.nvim_create_user_command('Outline' .. n, c, o)
|
||||
end
|
||||
|
||||
cmd('', _cmd_open_with_mods(M.toggle_outline), {
|
||||
desc = "Toggle the outline window. \
|
||||
With bang, keep focus on initial window after opening.",
|
||||
desc = 'Toggle the outline window. \
|
||||
With bang, keep focus on initial window after opening.',
|
||||
nargs = 0,
|
||||
bang = true,
|
||||
})
|
||||
cmd('Open', _cmd_open_with_mods(M.open_outline), {
|
||||
desc = "With bang, keep focus on initial window after opening.",
|
||||
desc = 'With bang, keep focus on initial window after opening.',
|
||||
nargs = 0,
|
||||
bang = true,
|
||||
})
|
||||
@@ -678,7 +655,7 @@ With bang, keep focus on initial window after opening.",
|
||||
cmd('FocusCode', M.focus_code, { nargs = 0 })
|
||||
cmd('Focus', M.focus_toggle, { nargs = 0 })
|
||||
cmd('Status', M.show_status, {
|
||||
desc = "Show a message about the current status of the outline window.",
|
||||
desc = 'Show a message about the current status of the outline window.',
|
||||
nargs = 0,
|
||||
})
|
||||
cmd('Follow', _cmd_follow_cursor, {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
local symbols = require 'outline.symbols'
|
||||
local ui = require 'outline.ui'
|
||||
local cfg = require 'outline.config'
|
||||
local t_utils = require 'outline.utils.table'
|
||||
local lsp_utils = require 'outline.utils.lsp_utils'
|
||||
local folding = require 'outline.folding'
|
||||
local cfg = require('outline.config')
|
||||
local folding = require('outline.folding')
|
||||
local lsp_utils = require('outline.utils.lsp_utils')
|
||||
local symbols = require('outline.symbols')
|
||||
local t_utils = require('outline.utils.table')
|
||||
local ui = require('outline.ui')
|
||||
|
||||
local M = {}
|
||||
|
||||
@@ -106,7 +106,8 @@ function M.preorder_iter(items, children_check)
|
||||
end
|
||||
|
||||
if
|
||||
node.children and node.traversal_child <= #node.children
|
||||
node.children
|
||||
and node.traversal_child <= #node.children
|
||||
and (node.is_root or children_check(node))
|
||||
then
|
||||
prev = node
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
local outline = require 'outline'
|
||||
local cfg = require 'outline.config'
|
||||
local hover = require 'outline.hover'
|
||||
local cfg = require('outline.config')
|
||||
local hover = require('outline.hover')
|
||||
local outline = require('outline')
|
||||
|
||||
local M = {}
|
||||
|
||||
@@ -30,8 +30,8 @@ local function get_width_offset()
|
||||
---@type integer
|
||||
local outline_winnr = outline.view.winnr
|
||||
local width = cfg.get_preview_width() + 3
|
||||
local has_numbers = vim.api.nvim_win_get_option(outline_winnr, "number")
|
||||
has_numbers = has_numbers or vim.api.nvim_win_get_option(outline_winnr, "relativenumber")
|
||||
local has_numbers = vim.api.nvim_win_get_option(outline_winnr, 'number')
|
||||
has_numbers = has_numbers or vim.api.nvim_win_get_option(outline_winnr, 'relativenumber')
|
||||
|
||||
if has_numbers then
|
||||
width = width + 4
|
||||
@@ -67,10 +67,7 @@ local function update_preview(code_buf)
|
||||
|
||||
if state.preview_buf ~= nil then
|
||||
vim.api.nvim_buf_set_lines(state.preview_buf, 0, -1, 0, lines)
|
||||
vim.api.nvim_win_set_cursor(
|
||||
state.preview_win,
|
||||
{ node.line + 1, node.character }
|
||||
)
|
||||
vim.api.nvim_win_set_cursor(state.preview_win, { node.line + 1, node.character })
|
||||
end
|
||||
end
|
||||
|
||||
@@ -79,7 +76,7 @@ local function setup_preview_buf()
|
||||
local ft = vim.api.nvim_buf_get_option(code_buf, 'filetype')
|
||||
|
||||
local function treesitter_attach()
|
||||
local ts_highlight = require 'nvim-treesitter.highlight'
|
||||
local ts_highlight = require('nvim-treesitter.highlight')
|
||||
|
||||
ts_highlight.attach(state.preview_buf, ft)
|
||||
end
|
||||
@@ -139,14 +136,10 @@ end
|
||||
|
||||
function M.close()
|
||||
if has_code_win() then
|
||||
if
|
||||
state.preview_win ~= nil and vim.api.nvim_win_is_valid(state.preview_win)
|
||||
then
|
||||
if state.preview_win ~= nil and vim.api.nvim_win_is_valid(state.preview_win) then
|
||||
vim.api.nvim_win_close(state.preview_win, true)
|
||||
end
|
||||
if
|
||||
state.hover_win ~= nil and vim.api.nvim_win_is_valid(state.hover_win)
|
||||
then
|
||||
if state.hover_win ~= nil and vim.api.nvim_win_is_valid(state.hover_win) then
|
||||
vim.api.nvim_win_close(state.hover_win, true)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -2,9 +2,8 @@ local M = {
|
||||
name = 'coc',
|
||||
}
|
||||
|
||||
|
||||
function M.should_use_provider(_)
|
||||
local not_coc_installed = vim.fn.exists '*CocActionAsync' == 0
|
||||
local not_coc_installed = vim.fn.exists('*CocActionAsync') == 0
|
||||
local not_coc_service_initialized = vim.g.coc_service_initialized == 0
|
||||
|
||||
if not_coc_installed or not_coc_service_initialized then
|
||||
@@ -28,61 +27,61 @@ end
|
||||
|
||||
---@param result table
|
||||
local function convert_symbols(result)
|
||||
local s = {}
|
||||
local kinds_index = {}
|
||||
-- create a inverse indexing of symbols.kind
|
||||
local symbols = require("outline.symbols")
|
||||
for k, v in pairs(symbols.kinds) do
|
||||
kinds_index[v] = k
|
||||
local s = {}
|
||||
local kinds_index = {}
|
||||
-- create a inverse indexing of symbols.kind
|
||||
local symbols = require('outline.symbols')
|
||||
for k, v in pairs(symbols.kinds) do
|
||||
kinds_index[v] = k
|
||||
end
|
||||
-- rebuild coc.nvim symbol list hierarchy according to the 'level' key
|
||||
for _, value in pairs(result) do
|
||||
value.children = {}
|
||||
value.kind = kinds_index[value.kind]
|
||||
if #s == 0 then
|
||||
table.insert(s, value)
|
||||
goto continue
|
||||
end
|
||||
-- rebuild coc.nvim symbol list hierarchy according to the 'level' key
|
||||
for _, value in pairs(result) do
|
||||
value.children = {}
|
||||
value.kind = kinds_index[value.kind]
|
||||
if #s == 0 then
|
||||
table.insert(s, value)
|
||||
goto continue
|
||||
end
|
||||
if value.level == s[#s].level then
|
||||
if value.level == 0 then
|
||||
table.insert(s, value)
|
||||
goto continue
|
||||
end
|
||||
local tmp = s[#s]
|
||||
table.remove(s)
|
||||
table.insert(s[#s].children, tmp)
|
||||
table.insert(s, value)
|
||||
elseif value.level == s[#s].level + 1 then
|
||||
table.insert(s[#s].children, value)
|
||||
elseif value.level == s[#s].level + 2 then
|
||||
local tmp = s[#s].children[#(s[#s].children)]
|
||||
table.remove(s[#s].children)
|
||||
table.insert(s, tmp)
|
||||
table.insert(s[#s].children, value)
|
||||
elseif value.level < s[#s].level then
|
||||
while value.level < s[#s].level do
|
||||
local tmp = s[#s]
|
||||
table.remove(s)
|
||||
table.insert(s[#s].children, tmp)
|
||||
end
|
||||
if s[#s].level ~= 0 then
|
||||
local tmp = s[#s]
|
||||
table.remove(s)
|
||||
table.insert(s[#s].children, tmp)
|
||||
table.insert(s, value)
|
||||
else
|
||||
table.insert(s, value)
|
||||
end
|
||||
end
|
||||
::continue::
|
||||
end
|
||||
local top = s[#s]
|
||||
while top.level ~= 0 do
|
||||
if value.level == s[#s].level then
|
||||
if value.level == 0 then
|
||||
table.insert(s, value)
|
||||
goto continue
|
||||
end
|
||||
local tmp = s[#s]
|
||||
table.remove(s)
|
||||
table.insert(s[#s].children, tmp)
|
||||
table.insert(s, value)
|
||||
elseif value.level == s[#s].level + 1 then
|
||||
table.insert(s[#s].children, value)
|
||||
elseif value.level == s[#s].level + 2 then
|
||||
local tmp = s[#s].children[#s[#s].children]
|
||||
table.remove(s[#s].children)
|
||||
table.insert(s, tmp)
|
||||
table.insert(s[#s].children, value)
|
||||
elseif value.level < s[#s].level then
|
||||
while value.level < s[#s].level do
|
||||
local tmp = s[#s]
|
||||
table.remove(s)
|
||||
table.insert(s[#s].children, top)
|
||||
top = s[#s]
|
||||
table.insert(s[#s].children, tmp)
|
||||
end
|
||||
if s[#s].level ~= 0 then
|
||||
local tmp = s[#s]
|
||||
table.remove(s)
|
||||
table.insert(s[#s].children, tmp)
|
||||
table.insert(s, value)
|
||||
else
|
||||
table.insert(s, value)
|
||||
end
|
||||
end
|
||||
return s
|
||||
::continue::
|
||||
end
|
||||
local top = s[#s]
|
||||
while top.level ~= 0 do
|
||||
table.remove(s)
|
||||
table.insert(s[#s].children, top)
|
||||
top = s[#s]
|
||||
end
|
||||
return s
|
||||
end
|
||||
|
||||
---@param on_symbols function
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
local cfg = require "outline.config"
|
||||
local cfg = require('outline.config')
|
||||
|
||||
local M = {}
|
||||
local import_prefix = "outline/providers/"
|
||||
local import_prefix = 'outline/providers/'
|
||||
|
||||
_G._outline_current_provider = nil
|
||||
|
||||
|
||||
function M.find_provider()
|
||||
if not M.providers then
|
||||
M.providers = vim.tbl_map(function(p) return import_prefix..p end, cfg.get_providers())
|
||||
M.providers = vim.tbl_map(function(p)
|
||||
return import_prefix .. p
|
||||
end, cfg.get_providers())
|
||||
end
|
||||
for _, name in ipairs(M.providers) do
|
||||
local provider = require(name)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
local config = require 'outline.config'
|
||||
local lsp_utils = require 'outline.utils.lsp_utils'
|
||||
local jsx = require 'outline.utils.jsx'
|
||||
local config = require('outline.config')
|
||||
local jsx = require('outline.utils.jsx')
|
||||
local lsp_utils = require('outline.utils.lsp_utils')
|
||||
|
||||
local M = {
|
||||
name = 'lsp',
|
||||
@@ -10,9 +10,9 @@ local M = {
|
||||
|
||||
function M.get_status()
|
||||
if not M.client then
|
||||
return "No clients"
|
||||
return 'No clients'
|
||||
end
|
||||
return "client: "..M.client.name
|
||||
return 'client: ' .. M.client.name
|
||||
end
|
||||
|
||||
local function get_params()
|
||||
@@ -83,15 +83,10 @@ end
|
||||
|
||||
---@param on_symbols function
|
||||
function M.request_symbols(on_symbols, opts)
|
||||
vim.lsp.buf_request_all(
|
||||
0,
|
||||
'textDocument/documentSymbol',
|
||||
get_params(),
|
||||
function (response)
|
||||
response = M.postprocess_symbols(response)
|
||||
on_symbols(response, opts)
|
||||
end
|
||||
)
|
||||
vim.lsp.buf_request_all(0, 'textDocument/documentSymbol', get_params(), function(response)
|
||||
response = M.postprocess_symbols(response)
|
||||
on_symbols(response, opts)
|
||||
end)
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
local outline = require 'outline'
|
||||
local outline = require('outline')
|
||||
|
||||
local M = {}
|
||||
|
||||
@@ -26,17 +26,12 @@ function M.rename()
|
||||
|
||||
params.newName = new_name
|
||||
|
||||
vim.lsp.buf_request(
|
||||
params.bufnr,
|
||||
'textDocument/rename',
|
||||
params,
|
||||
function(_, result, ctx)
|
||||
if result ~= nil then
|
||||
local client = vim.lsp.get_client_by_id(ctx.client_id)
|
||||
vim.lsp.util.apply_workspace_edit(result, client.offset_encoding)
|
||||
end
|
||||
vim.lsp.buf_request(params.bufnr, 'textDocument/rename', params, function(_, result, ctx)
|
||||
if result ~= nil then
|
||||
local client = vim.lsp.get_client_by_id(ctx.client_id)
|
||||
vim.lsp.util.apply_workspace_edit(result, client.offset_encoding)
|
||||
end
|
||||
)
|
||||
end)
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
local cfg = require 'outline.config'
|
||||
local cfg = require('outline.config')
|
||||
|
||||
local M = {}
|
||||
|
||||
@@ -60,10 +60,13 @@ function M.icon_from_kind(kind)
|
||||
if cfg.o.symbols.icon_source == 'lspkind' then
|
||||
local has_lspkind, lspkind = pcall(require, 'lspkind')
|
||||
if not has_lspkind then
|
||||
vim.notify("[outline]: icon_source set to lspkind but failed to require lspkind!", vim.log.levels.ERROR)
|
||||
vim.notify(
|
||||
'[outline]: icon_source set to lspkind but failed to require lspkind!',
|
||||
vim.log.levels.ERROR
|
||||
)
|
||||
else
|
||||
local icon = lspkind.symbolic(kindstr, { with_text = false })
|
||||
if icon and icon ~= "" then
|
||||
if icon and icon ~= '' then
|
||||
return icon
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,26 +1,19 @@
|
||||
local M = {}
|
||||
|
||||
M.hovered_hl_ns = vim.api.nvim_create_namespace 'hovered_item'
|
||||
M.hovered_hl_ns = vim.api.nvim_create_namespace('hovered_item')
|
||||
|
||||
function M.clear_hover_highlight(bufnr)
|
||||
vim.api.nvim_buf_clear_namespace(bufnr, M.hovered_hl_ns, 0, -1)
|
||||
end
|
||||
|
||||
function M.add_hover_highlight(bufnr, line, col_start)
|
||||
vim.api.nvim_buf_add_highlight(
|
||||
bufnr,
|
||||
M.hovered_hl_ns,
|
||||
'OutlineCurrent',
|
||||
line,
|
||||
col_start,
|
||||
-1
|
||||
)
|
||||
vim.api.nvim_buf_add_highlight(bufnr, M.hovered_hl_ns, 'OutlineCurrent', line, col_start, -1)
|
||||
end
|
||||
|
||||
function M.setup_highlights()
|
||||
-- Setup the OutlineCurrent highlight group if it hasn't been done already by
|
||||
-- a theme or manually set
|
||||
if vim.fn.hlexists 'OutlineCurrent' == 0 then
|
||||
if vim.fn.hlexists('OutlineCurrent') == 0 then
|
||||
-- TODO: Use nvim_get_hl
|
||||
local cline_hl = vim.api.nvim_get_hl_by_name('CursorLine', true)
|
||||
local string_hl = vim.api.nvim_get_hl_by_name('String', true)
|
||||
@@ -36,16 +29,10 @@ function M.setup_highlights()
|
||||
-- notably making them italic, which messes up the outline connector. Fix
|
||||
-- this by copying the foreground color from the comment hl into a new
|
||||
-- highlight.
|
||||
local comment_fg_gui = vim.fn.synIDattr(
|
||||
vim.fn.synIDtrans(vim.fn.hlID 'Comment'),
|
||||
'fg',
|
||||
'gui'
|
||||
)
|
||||
local comment_fg_gui = vim.fn.synIDattr(vim.fn.synIDtrans(vim.fn.hlID('Comment')), 'fg', 'gui')
|
||||
|
||||
if vim.fn.hlexists 'OutlineGuides' == 0 then
|
||||
vim.cmd(
|
||||
string.format('hi OutlineGuides guifg=%s', comment_fg_gui)
|
||||
)
|
||||
if vim.fn.hlexists('OutlineGuides') == 0 then
|
||||
vim.cmd(string.format('hi OutlineGuides guifg=%s', comment_fg_gui))
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -67,9 +67,9 @@ end
|
||||
|
||||
function View:is_open()
|
||||
return self.winnr
|
||||
and self.bufnr
|
||||
and vim.api.nvim_buf_is_valid(self.bufnr)
|
||||
and vim.api.nvim_win_is_valid(self.winnr)
|
||||
and self.bufnr
|
||||
and vim.api.nvim_buf_is_valid(self.bufnr)
|
||||
and vim.api.nvim_win_is_valid(self.winnr)
|
||||
end
|
||||
|
||||
return View
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
local symbols = require 'outline.symbols'
|
||||
local parser = require 'outline.parser'
|
||||
local cfg = require 'outline.config'
|
||||
local ui = require 'outline.ui'
|
||||
local t_utils = require 'outline.utils.table'
|
||||
local folding = require 'outline.folding'
|
||||
local cfg = require('outline.config')
|
||||
local folding = require('outline.folding')
|
||||
local parser = require('outline.parser')
|
||||
local symbols = require('outline.symbols')
|
||||
local t_utils = require('outline.utils.table')
|
||||
local ui = require('outline.ui')
|
||||
|
||||
local strlen = vim.fn.strlen
|
||||
|
||||
|
||||
local M = {}
|
||||
|
||||
local hlns = vim.api.nvim_create_namespace 'outline-icon-highlight'
|
||||
local ns = vim.api.nvim_create_namespace 'outline-virt-text'
|
||||
|
||||
local hlns = vim.api.nvim_create_namespace('outline-icon-highlight')
|
||||
local ns = vim.api.nvim_create_namespace('outline-virt-text')
|
||||
|
||||
---@param bufnr integer
|
||||
---@return boolean
|
||||
@@ -31,14 +29,7 @@ end
|
||||
function M.add_highlights(bufnr, hl_info, nodes)
|
||||
for _, line_hl in ipairs(hl_info) do
|
||||
local line, hl_start, hl_end, hl_type = unpack(line_hl)
|
||||
vim.api.nvim_buf_add_highlight(
|
||||
bufnr,
|
||||
hlns,
|
||||
hl_type,
|
||||
line - 1,
|
||||
hl_start,
|
||||
hl_end
|
||||
)
|
||||
vim.api.nvim_buf_add_highlight(bufnr, hlns, hl_type, line - 1, hl_start, hl_end)
|
||||
end
|
||||
M.add_hover_highlights(bufnr, nodes)
|
||||
end
|
||||
@@ -50,7 +41,7 @@ end
|
||||
|
||||
---@param bufnr integer
|
||||
---@param nodes outline.FlatSymbolNode[] flattened nodes
|
||||
function M.add_hover_highlights (bufnr, nodes)
|
||||
function M.add_hover_highlights(bufnr, nodes)
|
||||
if not cfg.o.outline_items.highlight_hovered_item then
|
||||
return
|
||||
end
|
||||
@@ -63,11 +54,7 @@ function M.add_hover_highlights (bufnr, nodes)
|
||||
end
|
||||
|
||||
if node.prefix_length then
|
||||
ui.add_hover_highlight(
|
||||
bufnr,
|
||||
node.line_in_outline - 1,
|
||||
node.prefix_length
|
||||
)
|
||||
ui.add_hover_highlight(bufnr, node.line_in_outline - 1, node.prefix_length)
|
||||
end
|
||||
::continue::
|
||||
end
|
||||
@@ -101,7 +88,7 @@ function M.make_outline(bufnr, items, codewin)
|
||||
|
||||
-- Find the prefix for each line needed for the lineno space
|
||||
local lineno_offset = 0
|
||||
local lineno_prefix = ""
|
||||
local lineno_prefix = ''
|
||||
local lineno_max_width = #tostring(vim.api.nvim_buf_line_count(codebuf) - 1)
|
||||
if cfg.o.outline_items.show_symbol_lineno then
|
||||
-- Use max width-1 plus 1 space padding.
|
||||
@@ -120,7 +107,7 @@ function M.make_outline(bufnr, items, codewin)
|
||||
#flattened,
|
||||
from,
|
||||
to,
|
||||
"OutlineGuides"
|
||||
'OutlineGuides',
|
||||
})
|
||||
end
|
||||
|
||||
@@ -129,7 +116,7 @@ function M.make_outline(bufnr, items, codewin)
|
||||
#flattened,
|
||||
from,
|
||||
to,
|
||||
"OutlineFoldMarker"
|
||||
'OutlineFoldMarker',
|
||||
})
|
||||
end
|
||||
|
||||
@@ -147,9 +134,9 @@ function M.make_outline(bufnr, items, codewin)
|
||||
table.insert(flattened, node)
|
||||
node.line_in_outline = #flattened
|
||||
table.insert(details, node.detail or '')
|
||||
local lineno = tostring(node.range_start+1)
|
||||
local leftpad = string.rep(' ', lineno_max_width-#lineno)
|
||||
table.insert(linenos, leftpad..lineno)
|
||||
local lineno = tostring(node.range_start + 1)
|
||||
local leftpad = string.rep(' ', lineno_max_width - #lineno)
|
||||
table.insert(linenos, leftpad .. lineno)
|
||||
|
||||
-- Make the guides for the line prefix
|
||||
local pref = t_utils.str_to_table(string.rep(' ', node.depth))
|
||||
@@ -180,7 +167,7 @@ function M.make_outline(bufnr, items, codewin)
|
||||
-- ancestor is the entire outline itself, it should not have a vertical
|
||||
-- guide).
|
||||
local iternode = node
|
||||
for i = node.depth-1, 2, -1 do
|
||||
for i = node.depth - 1, 2, -1 do
|
||||
iternode = iternode.parent_node
|
||||
if not iternode.isLast then
|
||||
pref[i] = guide_markers.vertical
|
||||
@@ -199,18 +186,18 @@ function M.make_outline(bufnr, items, codewin)
|
||||
add_fold_hl(total_pref_len - fold_marker_width, total_pref_len + 1)
|
||||
end
|
||||
|
||||
local line = lineno_prefix..pref_str
|
||||
local line = lineno_prefix .. pref_str
|
||||
local icon_pref = 0
|
||||
if node.icon ~= "" then
|
||||
line = line..' '..node.icon
|
||||
if node.icon ~= '' then
|
||||
line = line .. ' ' .. node.icon
|
||||
icon_pref = 1
|
||||
end
|
||||
line = line..' '..node.name
|
||||
line = line .. ' ' .. node.name
|
||||
|
||||
-- Highlight for the icon ✨
|
||||
-- Start from icon col
|
||||
local hl_start = #pref_str + #lineno_prefix + icon_pref
|
||||
local hl_end = hl_start + #node.icon -- until after icon
|
||||
local hl_end = hl_start + #node.icon -- until after icon
|
||||
local hl_type = cfg.o.symbols.icons[symbols.kinds[node.kind]].hl
|
||||
table.insert(hl, { #flattened, hl_start, hl_end, hl_type })
|
||||
|
||||
@@ -219,7 +206,7 @@ function M.make_outline(bufnr, items, codewin)
|
||||
node.prefix_length = hl_end + 1
|
||||
|
||||
-- lines passed to nvim_buf_set_lines cannot contain newlines in each line
|
||||
line = line:gsub("\n", " ")
|
||||
line = line:gsub('\n', ' ')
|
||||
table.insert(lines, line)
|
||||
end
|
||||
|
||||
@@ -278,5 +265,4 @@ end
|
||||
-- have to call nvim_buf_set_lines n times (each line) rather than add lines
|
||||
-- all at once, saving only the need of 1 extra table (lines table) in memory.
|
||||
|
||||
|
||||
return M
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
column_width = 80
|
||||
line_endings = 'Unix'
|
||||
indent_type = 'Spaces'
|
||||
indent_width = 2
|
||||
quote_style = 'AutoPreferSingle'
|
||||
call_parentheses = 'None'
|
||||
Reference in New Issue
Block a user