Skip to content

Commit 0ef80ed

Browse files
committed
doc: fix deprecation warnings from nvim 0.11
1 parent 9ebc135 commit 0ef80ed

File tree

5 files changed

+29
-13
lines changed

5 files changed

+29
-13
lines changed

lua/aerial/backends/treesitter/init.lua

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,18 @@ M.fetch_symbols_sync = function(bufnr)
9191
end
9292
local kind = match.kind
9393
if not kind then
94-
vim.api.nvim_err_writeln(
95-
string.format("Missing 'kind' metadata in query file for language %s", lang)
94+
vim.api.nvim_echo(
95+
{ { string.format("Missing 'kind' metadata in query file for language %s", lang) } },
96+
true,
97+
{ err = true }
9698
)
9799
break
98100
elseif not vim.lsp.protocol.SymbolKind[kind] then
99-
vim.api.nvim_err_writeln(
100-
string.format("Invalid 'kind' metadata '%s' in query file for language %s", kind, lang)
101-
)
101+
vim.api.nvim_echo({
102+
{
103+
string.format("Invalid 'kind' metadata '%s' in query file for language %s", kind, lang),
104+
},
105+
}, true, { err = true })
102106
break
103107
end
104108
local range = helpers.range_from_nodes(start_node, end_node)

lua/aerial/highlight.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ M.get_highlight = function(symbol, is_icon, is_collapsed)
6262
end
6363

6464
---@param name string
65-
---@return vim.api.keyset.hl_info
65+
---@return vim.api.keyset.get_hl_info
6666
local function get_hl_by_name(name)
6767
return vim.api.nvim_get_hl(0, { name = name, link = false })
6868
end

lua/aerial/nav_view.lua

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,14 +199,14 @@ local function render_symbols(panel)
199199
table.insert(lines, text)
200200
local text_cols = vim.api.nvim_strwidth(text)
201201
table.insert(highlights, { "Aerial" .. item.kind .. "Icon", i - 1, 0, kind:len() })
202-
table.insert(highlights, { "Aerial" .. item.kind, i - 1, kind:len(), -1 })
202+
table.insert(highlights, { "Aerial" .. item.kind, i - 1, kind:len(), text:len() })
203203
max_len = math.max(max_len, text_cols)
204204
end
205205

206206
-- If there are no symbols in this section, add some indicator of that
207207
if #lines == 0 then
208208
table.insert(lines, "<none>")
209-
table.insert(highlights, { "Comment", 0, 0, -1 })
209+
table.insert(highlights, { "Comment", 0, 0, 6 })
210210
end
211211

212212
vim.bo[bufnr].modifiable = true
@@ -217,7 +217,11 @@ local function render_symbols(panel)
217217
local ns = vim.api.nvim_create_namespace("aerial")
218218
vim.api.nvim_buf_clear_namespace(bufnr, ns, 0, -1)
219219
for _, hl in ipairs(highlights) do
220-
vim.api.nvim_buf_add_highlight(bufnr, ns, unpack(hl))
220+
local hl_group, line, col, end_col = unpack(hl)
221+
vim.api.nvim_buf_set_extmark(bufnr, ns, line, col, {
222+
end_col = end_col,
223+
hl_group = hl_group,
224+
})
221225
end
222226
panel.width = max_len
223227
panel.height = #lines

lua/aerial/render.lua

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ M.update_aerial_buffer = function(buf)
166166
group = name_hl,
167167
row = row,
168168
col_start = string_len[spacing] + string_len[kind],
169-
col_end = -1,
169+
col_end = text:len(),
170170
})
171171
end
172172
max_len = math.max(max_len, text_cols)
@@ -184,7 +184,10 @@ M.update_aerial_buffer = function(buf)
184184
local ns = vim.api.nvim_create_namespace("aerial")
185185
vim.api.nvim_buf_clear_namespace(aer_bufnr, ns, 0, -1)
186186
for _, hl in ipairs(highlights) do
187-
vim.api.nvim_buf_add_highlight(aer_bufnr, ns, hl.group, hl.row - 1, hl.col_start, hl.col_end)
187+
vim.api.nvim_buf_set_extmark(aer_bufnr, ns, hl.row - 1, hl.col_start, {
188+
end_col = hl.col_end,
189+
hl_group = hl.group,
190+
})
188191
end
189192
M.update_highlights(bufnr)
190193
vim.b[aer_bufnr].rendered = true

lua/aerial/util.lua

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,14 @@ M.flash_highlight = function(bufnr, lnum, durationMs, hl_group)
180180
if durationMs == true or durationMs == 1 then
181181
durationMs = 300
182182
end
183-
local ns = vim.api.nvim_buf_add_highlight(bufnr, 0, hl_group, lnum - 1, 0, -1)
183+
local ns = vim.api.nvim_create_namespace("AerialFlashHighlight")
184+
local line = vim.api.nvim_buf_get_lines(bufnr, lnum - 1, lnum, true)[1]
185+
local ext_id = vim.api.nvim_buf_set_extmark(bufnr, ns, lnum - 1, 0, {
186+
end_col = #line,
187+
hl_group = hl_group,
188+
})
184189
local remove_highlight = function()
185-
pcall(vim.api.nvim_buf_clear_namespace, bufnr, ns, 0, -1)
190+
vim.api.nvim_buf_del_extmark(bufnr, ns, ext_id)
186191
end
187192
vim.defer_fn(remove_highlight, durationMs)
188193
end

0 commit comments

Comments
 (0)