fix(docs): replace yxx mappings with g== #31947

Problem:
`yx` uses "y" prefix, which shadows a builtin operator.

Solution:
Use `g=` (in the form of `g==` currently), drawing from precedent of
CTRL-= and 'tpope/vim-scriptease'.
This commit is contained in:
Evgeni Chasnovski
2025-01-15 12:36:00 +02:00
committed by GitHub
parent 9552fe7ef9
commit 09bcb31068
7 changed files with 10 additions and 10 deletions

View File

@@ -57,7 +57,7 @@ for _, match, metadata in query:iter_matches(tree:root(), 0, 0, -1) do
if name == 'code' then
vim.api.nvim_buf_set_extmark(0, run_message_ns, start, 0, {
virt_text = { { 'Run with `yxx`', 'LspCodeLens' } },
virt_text = { { 'Run with `g==`', 'LspCodeLens' } },
})
local code = vim.treesitter.get_node_text(node, 0)
local lang_node = match[metadata[id].lang][1] --[[@as TSNode]]
@@ -69,7 +69,7 @@ for _, match, metadata in query:iter_matches(tree:root(), 0, 0, -1) do
end
end
vim.keymap.set('n', 'yxx', function()
vim.keymap.set('n', 'g==', function()
local pos = vim.api.nvim_win_get_cursor(0)[1]
local code_block = code_blocks[pos]
if not code_block then
@@ -82,5 +82,5 @@ vim.keymap.set('n', 'yxx', function()
end, { buffer = true })
vim.b.undo_ftplugin = (vim.b.undo_ftplugin or '')
.. '\n exe "nunmap <buffer> gO" | exe "nunmap <buffer> yxx"'
.. '\n exe "nunmap <buffer> gO" | exe "nunmap <buffer> g=="'
vim.b.undo_ftplugin = vim.b.undo_ftplugin .. ' | call v:lua.vim.treesitter.stop()'