mirror of
https://github.com/stevearc/aerial.nvim
synced 2024-09-16 14:34:08 +02:00
fix: type annotations and type errors
This commit is contained in:
parent
81713b37d1
commit
ffb5fd0aa7
12 changed files with 43 additions and 12 deletions
|
@ -40,7 +40,7 @@ end
|
|||
---@param symbols table
|
||||
---@param bufnr integer
|
||||
---@param fix_start_col boolean
|
||||
---@param client_name LSP client name
|
||||
---@param client_name string LSP client name
|
||||
local function process_symbols(symbols, bufnr, fix_start_col, client_name)
|
||||
local include_kind = config.get_filter_kind_map(bufnr)
|
||||
local max_line = vim.api.nvim_buf_line_count(bufnr)
|
||||
|
|
|
@ -5,6 +5,8 @@ local _, utils = pcall(require, "nvim-treesitter.utils")
|
|||
local helpers = require("aerial.backends.treesitter.helpers")
|
||||
local M = {}
|
||||
|
||||
---@diagnostic disable deprecated
|
||||
|
||||
local get_node_text
|
||||
if vim.treesitter.get_node_text then
|
||||
-- Neovim 0.9
|
||||
|
|
|
@ -3,6 +3,8 @@ local config = require("aerial.config")
|
|||
local helpers = require("aerial.backends.treesitter.helpers")
|
||||
local util = require("aerial.backends.util")
|
||||
|
||||
---@diagnostic disable deprecated
|
||||
|
||||
---@type aerial.Backend
|
||||
local M = {}
|
||||
|
||||
|
|
|
@ -516,6 +516,15 @@ M.setup = function(opts)
|
|||
-- for backwards compatibility
|
||||
for k, _ in pairs(default_options.lsp) do
|
||||
if newconf[k] ~= nil then
|
||||
vim.notify_once(
|
||||
string.format(
|
||||
"aerial.config.%s should be moved to aerial.config.lsp.%s (see :help aerial-options)\nThis shim will be removed on 2024-02-11",
|
||||
k,
|
||||
k
|
||||
),
|
||||
vim.log.levels.WARN
|
||||
)
|
||||
---@diagnostic disable-next-line assign-type-mismatch
|
||||
newconf.lsp[k] = newconf[k]
|
||||
newconf[k] = nil
|
||||
end
|
||||
|
|
|
@ -17,6 +17,9 @@ local config = require("aerial.config")
|
|||
---@field parent? aerial.Symbol
|
||||
---@field selection_range? aerial.Range
|
||||
---@field children? aerial.Symbol[]
|
||||
---@field prev_sibling? aerial.Symbol
|
||||
---@field next_sibling? aerial.Symbol
|
||||
---@field id? string
|
||||
|
||||
---@class aerial.BufData
|
||||
---@field bufnr integer
|
||||
|
@ -27,6 +30,7 @@ local config = require("aerial.config")
|
|||
---@field collapsed table<string, boolean>
|
||||
---@field collapse_level integer
|
||||
---@field max_level integer
|
||||
---@field manage_folds boolean
|
||||
local BufData = {}
|
||||
|
||||
---@param bufnr integer
|
||||
|
@ -86,7 +90,7 @@ function BufData:set_collapsed(item, collapsed)
|
|||
end
|
||||
|
||||
---@param item aerial.Symbol
|
||||
---@return boolean
|
||||
---@return boolean?
|
||||
function BufData:is_collapsable(item)
|
||||
return self.manage_folds or (item.children and not vim.tbl_isempty(item.children))
|
||||
end
|
||||
|
|
|
@ -54,9 +54,21 @@ M.get_highlight = function(symbol, is_icon, is_collapsed)
|
|||
return string.format("Aerial%s%s", symbol.kind, is_icon and "Icon" or "")
|
||||
end
|
||||
|
||||
local get_hl_by_name
|
||||
if vim.fn.has("nvim-0.9") == 1 then
|
||||
get_hl_by_name = function(name)
|
||||
return vim.api.nvim_get_hl(0, { name = name, link = false })
|
||||
end
|
||||
else
|
||||
get_hl_by_name = function(name)
|
||||
---@diagnostic disable-next-line undefined-field
|
||||
return vim.api.nvim_get_hl_by_name(name, true)
|
||||
end
|
||||
end
|
||||
|
||||
M.create_highlight_groups = function()
|
||||
-- Use Normal colors for AerialNormal, while stripping bold/italic/etc
|
||||
local normal_defn = vim.api.nvim_get_hl_by_name("Normal", true)
|
||||
local normal_defn = get_hl_by_name("Normal")
|
||||
-- The default text highlight
|
||||
vim.api.nvim_set_hl(0, "AerialNormal", {
|
||||
fg = normal_defn.foreground,
|
||||
|
@ -68,7 +80,7 @@ M.create_highlight_groups = function()
|
|||
})
|
||||
|
||||
-- Set another group for NormalFloat, for use in the nav view
|
||||
local normal_float_defn = vim.api.nvim_get_hl_by_name("NormalFloat", true)
|
||||
local normal_float_defn = get_hl_by_name("NormalFloat")
|
||||
-- Don't set the background for the float so that it blends nicely with the cursorline
|
||||
vim.api.nvim_set_hl(0, "AerialNormalFloat", {
|
||||
fg = normal_float_defn.foreground,
|
||||
|
@ -86,7 +98,7 @@ M.create_highlight_groups = function()
|
|||
link("AerialProtected", "Comment")
|
||||
|
||||
-- Use Comment colors for AerialGuide, while stripping bold/italic/etc
|
||||
local comment_defn = vim.api.nvim_get_hl_by_name("Comment", true)
|
||||
local comment_defn = get_hl_by_name("Comment")
|
||||
-- The guides when show_guide = true
|
||||
vim.api.nvim_set_hl(0, "AerialGuide", {
|
||||
fg = comment_defn.foreground,
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
local M = {}
|
||||
|
||||
---@diagnostic disable undefined-doc-param
|
||||
|
||||
local was_closed = nil
|
||||
|
||||
local function list_complete(choices)
|
||||
|
|
|
@ -4,7 +4,7 @@ local M = {}
|
|||
local function resolve(action_module, rhs)
|
||||
if type(rhs) == "string" and vim.startswith(rhs, "actions.") then
|
||||
local mod = require(action_module)
|
||||
return resolve(action_module, mod[vim.split(rhs, ".", true)[2]])
|
||||
return resolve(action_module, mod[vim.split(rhs, ".", { plain = true })[2]])
|
||||
elseif type(rhs) == "table" then
|
||||
local opts = vim.deepcopy(rhs)
|
||||
opts.callback = nil
|
||||
|
|
|
@ -169,13 +169,13 @@ local function get_all_siblings(symbol)
|
|||
table.insert(ret, symbol)
|
||||
local i = 1
|
||||
local iter = symbol
|
||||
while iter.prev_sibling do
|
||||
while assert(iter).prev_sibling do
|
||||
iter = iter.prev_sibling
|
||||
i = i + 1
|
||||
table.insert(ret, 1, iter)
|
||||
end
|
||||
iter = symbol
|
||||
while iter.next_sibling do
|
||||
while assert(iter).next_sibling do
|
||||
iter = iter.next_sibling
|
||||
table.insert(ret, iter)
|
||||
end
|
||||
|
|
|
@ -379,7 +379,7 @@ M.throttle = function(func, opts)
|
|||
if type(delay) == "function" then
|
||||
delay = delay(unpack(args))
|
||||
end
|
||||
timer = vim.loop.new_timer()
|
||||
timer = assert(vim.loop.new_timer())
|
||||
timer:start(delay, 0, function()
|
||||
timer:close()
|
||||
timer = nil
|
||||
|
|
|
@ -98,7 +98,7 @@ function M:color_text(text, symbol, is_icon)
|
|||
if not self.options.colored then
|
||||
return text
|
||||
end
|
||||
local hl_group = require("aerial.highlight").get_highlight(symbol, is_icon)
|
||||
local hl_group = require("aerial.highlight").get_highlight(symbol, is_icon, false)
|
||||
if hl_group then
|
||||
local lualine_hl_group = self.highlight_groups[hl_group]
|
||||
if not lualine_hl_group then
|
||||
|
|
|
@ -60,8 +60,8 @@ local function aerial_picker(opts)
|
|||
local function make_display(entry)
|
||||
local item = entry.value
|
||||
local icon = config.get_icon(bufnr, item.kind)
|
||||
local icon_hl = highlight.get_highlight(item, true) or "NONE"
|
||||
local name_hl = highlight.get_highlight(item, false) or "NONE"
|
||||
local icon_hl = highlight.get_highlight(item, true, false) or "NONE"
|
||||
local name_hl = highlight.get_highlight(item, false, false) or "NONE"
|
||||
local columns = {
|
||||
{ icon, icon_hl },
|
||||
{ entry.name, name_hl },
|
||||
|
|
Loading…
Reference in a new issue