aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/_inspector.lua
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2025-02-05 23:09:29 +0000
committerJosh Rahm <joshuarahm@gmail.com>2025-02-05 23:09:29 +0000
commitd5f194ce780c95821a855aca3c19426576d28ae0 (patch)
treed45f461b19f9118ad2bb1f440a7a08973ad18832 /runtime/lua/vim/_inspector.lua
parentc5d770d311841ea5230426cc4c868e8db27300a8 (diff)
parent44740e561fc93afe3ebecfd3618bda2d2abeafb0 (diff)
downloadrneovim-d5f194ce780c95821a855aca3c19426576d28ae0.tar.gz
rneovim-d5f194ce780c95821a855aca3c19426576d28ae0.tar.bz2
rneovim-d5f194ce780c95821a855aca3c19426576d28ae0.zip
Merge remote-tracking branch 'upstream/master' into mix_20240309HEADrahm
Diffstat (limited to 'runtime/lua/vim/_inspector.lua')
-rw-r--r--runtime/lua/vim/_inspector.lua27
1 files changed, 22 insertions, 5 deletions
diff --git a/runtime/lua/vim/_inspector.lua b/runtime/lua/vim/_inspector.lua
index fccf4b8dbe..35063dffca 100644
--- a/runtime/lua/vim/_inspector.lua
+++ b/runtime/lua/vim/_inspector.lua
@@ -1,3 +1,5 @@
+--- @diagnostic disable:no-unknown
+
--- @class vim._inspector.Filter
--- @inlinedoc
---
@@ -53,7 +55,7 @@ function vim.inspect_pos(bufnr, row, col, filter)
local cursor = vim.api.nvim_win_get_cursor(win)
row, col = cursor[1] - 1, cursor[2]
end
- bufnr = bufnr == 0 and vim.api.nvim_get_current_buf() or bufnr
+ bufnr = vim._resolve_bufnr(bufnr)
local results = {
treesitter = {}, --- @type table[]
@@ -78,6 +80,7 @@ function vim.inspect_pos(bufnr, row, col, filter)
-- treesitter
if filter.treesitter then
for _, capture in pairs(vim.treesitter.get_captures_at_pos(bufnr, row, col)) do
+ --- @diagnostic disable-next-line: inject-field
capture.hl_group = '@' .. capture.capture .. '.' .. capture.lang
results.treesitter[#results.treesitter + 1] = resolve_hl(capture)
end
@@ -128,13 +131,13 @@ function vim.inspect_pos(bufnr, row, col, filter)
if filter.semantic_tokens then
results.semantic_tokens = vim.tbl_filter(function(extmark)
- return extmark.ns:find('vim_lsp_semantic_tokens') == 1
+ return extmark.ns:find('nvim.lsp.semantic_tokens') == 1
end, extmarks)
end
if filter.extmarks then
results.extmarks = vim.tbl_filter(function(extmark)
- return extmark.ns:find('vim_lsp_semantic_tokens') ~= 1
+ return extmark.ns:find('nvim.lsp.semantic_tokens') ~= 1
and (filter.extmarks == 'all' or extmark.opts.hl_group)
end, extmarks)
end
@@ -146,6 +149,13 @@ end
---
---Can also be shown with `:Inspect`. [:Inspect]()
---
+---Example: To bind this function to the vim-scriptease
+---inspired `zS` in Normal mode:
+---
+---```lua
+---vim.keymap.set('n', 'zS', vim.show_pos)
+---```
+---
---@since 11
---@param bufnr? integer defaults to the current buffer
---@param row? integer row to inspect, 0-based. Defaults to the row of the current cursor
@@ -171,7 +181,7 @@ function vim.show_pos(bufnr, row, col, filter)
if data.hl_group ~= data.hl_group_link then
append('links to ', 'MoreMsg')
append(data.hl_group_link, data.hl_group_link)
- append(' ')
+ append(' ')
end
if comment then
append(comment, 'Comment')
@@ -184,7 +194,14 @@ function vim.show_pos(bufnr, row, col, filter)
append('Treesitter', 'Title')
nl()
for _, capture in ipairs(items.treesitter) do
- item(capture, capture.lang)
+ item(
+ capture,
+ string.format(
+ 'priority: %d language: %s',
+ capture.metadata.priority or vim.hl.priorities.treesitter,
+ capture.lang
+ )
+ )
end
nl()
end