mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 19:38:20 +00:00
fix(help): remove runnable code virtual text
Problem: Virtual text indicating runnable code examples in help files is intrusive and non-configurable (and often denotes actually non-working examples). Solution: Remove virtual text.
This commit is contained in:

committed by
Christian Clason

parent
6623b4e050
commit
9177371014
@@ -82,9 +82,7 @@ local query = vim.treesitter.query.parse(
|
|||||||
]]
|
]]
|
||||||
)
|
)
|
||||||
local root = parser:parse()[1]:root()
|
local root = parser:parse()[1]:root()
|
||||||
local run_message_ns = vim.api.nvim_create_namespace('nvim.vimdoc.run_message')
|
|
||||||
|
|
||||||
vim.api.nvim_buf_clear_namespace(0, run_message_ns, 0, -1)
|
|
||||||
for _, match, metadata in query:iter_matches(root, 0, 0, -1) do
|
for _, match, metadata in query:iter_matches(root, 0, 0, -1) do
|
||||||
for id, nodes in pairs(match) do
|
for id, nodes in pairs(match) do
|
||||||
local name = query.captures[id]
|
local name = query.captures[id]
|
||||||
@@ -92,9 +90,6 @@ for _, match, metadata in query:iter_matches(root, 0, 0, -1) do
|
|||||||
local start, _, end_ = node:parent():range()
|
local start, _, end_ = node:parent():range()
|
||||||
|
|
||||||
if name == 'code' then
|
if name == 'code' then
|
||||||
vim.api.nvim_buf_set_extmark(0, run_message_ns, start, 0, {
|
|
||||||
virt_text = { { 'Run with `g==`', 'LspCodeLens' } },
|
|
||||||
})
|
|
||||||
local code = vim.treesitter.get_node_text(node, 0)
|
local code = vim.treesitter.get_node_text(node, 0)
|
||||||
local lang_node = match[metadata[id].lang][1] --[[@as TSNode]]
|
local lang_node = match[metadata[id].lang][1] --[[@as TSNode]]
|
||||||
local lang = vim.treesitter.get_node_text(lang_node, 0)
|
local lang = vim.treesitter.get_node_text(lang_node, 0)
|
||||||
|
Reference in New Issue
Block a user