mirror of
https://github.com/neovim/neovim.git
synced 2025-09-07 03:48:18 +00:00
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:

committed by
GitHub

parent
9552fe7ef9
commit
09bcb31068
@@ -193,7 +193,7 @@ Jump to specific subjects by using tags. This can be done in two ways:
|
|||||||
|
|
||||||
Use CTRL-T or CTRL-O to jump back.
|
Use CTRL-T or CTRL-O to jump back.
|
||||||
Use ":q" to close the help window.
|
Use ":q" to close the help window.
|
||||||
Use `yxx` to execute the current Lua/Vimscript code block.
|
Use `g==` to execute the current Lua/Vimscript code block.
|
||||||
|
|
||||||
If there are several matches for an item you are looking for, this is how you
|
If there are several matches for an item you are looking for, this is how you
|
||||||
can jump to each one of them:
|
can jump to each one of them:
|
||||||
|
@@ -229,7 +229,7 @@ DIAGNOSTICS
|
|||||||
|
|
||||||
EDITOR
|
EDITOR
|
||||||
|
|
||||||
• Use |yxx| in :help docs to execute Lua and Vimscript code examples.
|
• Use |g==| in :help docs to execute Lua and Vimscript code examples.
|
||||||
• Improved |paste| handling for redo (dot-repeat) and macros (|recording|):
|
• Improved |paste| handling for redo (dot-repeat) and macros (|recording|):
|
||||||
• Redoing a large paste is significantly faster and ignores 'autoindent'.
|
• Redoing a large paste is significantly faster and ignores 'autoindent'.
|
||||||
• Replaying a macro with |@| also replays pasted text.
|
• Replaying a macro with |@| also replays pasted text.
|
||||||
|
@@ -166,7 +166,7 @@ directory indicated in the request. >lua
|
|||||||
})
|
})
|
||||||
|
|
||||||
To try it out, select the above code and source it with `:'<,'>lua` (or
|
To try it out, select the above code and source it with `:'<,'>lua` (or
|
||||||
`yxx`), then run this command in a :terminal buffer: >
|
`g==`), then run this command in a :terminal buffer: >
|
||||||
|
|
||||||
printf "\033]7;file://./foo/bar\033\\"
|
printf "\033]7;file://./foo/bar\033\\"
|
||||||
|
|
||||||
|
@@ -1339,7 +1339,7 @@ parse({lang}, {query}) *vim.treesitter.query.parse()*
|
|||||||
`info.captures`).
|
`info.captures`).
|
||||||
• `info.patterns`: information about predicates.
|
• `info.patterns`: information about predicates.
|
||||||
|
|
||||||
Example (to try it, use `yxx` or select the code then run `:'<,'>lua`): >lua
|
Example (to try it, use `g==` or select the code then run `:'<,'>lua`): >lua
|
||||||
local query = vim.treesitter.query.parse('vimdoc', [[
|
local query = vim.treesitter.query.parse('vimdoc', [[
|
||||||
; query
|
; query
|
||||||
((h1) @str
|
((h1) @str
|
||||||
|
@@ -554,8 +554,8 @@ gO Show a filetype-specific, navigable "outline" of the
|
|||||||
*:sl!* *:sleep!*
|
*:sl!* *:sleep!*
|
||||||
:[N]sl[eep]! [N][m] Same as above, but hide the cursor.
|
:[N]sl[eep]! [N][m] Same as above, but hide the cursor.
|
||||||
|
|
||||||
*yxx*
|
*g==*
|
||||||
yxx Executes the current code block.
|
g== Executes the current code block.
|
||||||
|
|
||||||
Works in |help| buffers.
|
Works in |help| buffers.
|
||||||
|
|
||||||
|
@@ -57,7 +57,7 @@ for _, match, metadata in query:iter_matches(tree:root(), 0, 0, -1) do
|
|||||||
|
|
||||||
if name == 'code' then
|
if name == 'code' then
|
||||||
vim.api.nvim_buf_set_extmark(0, run_message_ns, start, 0, {
|
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 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]]
|
||||||
@@ -69,7 +69,7 @@ for _, match, metadata in query:iter_matches(tree:root(), 0, 0, -1) do
|
|||||||
end
|
end
|
||||||
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 pos = vim.api.nvim_win_get_cursor(0)[1]
|
||||||
local code_block = code_blocks[pos]
|
local code_block = code_blocks[pos]
|
||||||
if not code_block then
|
if not code_block then
|
||||||
@@ -82,5 +82,5 @@ vim.keymap.set('n', 'yxx', function()
|
|||||||
end, { buffer = true })
|
end, { buffer = true })
|
||||||
|
|
||||||
vim.b.undo_ftplugin = (vim.b.undo_ftplugin or '')
|
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()'
|
vim.b.undo_ftplugin = vim.b.undo_ftplugin .. ' | call v:lua.vim.treesitter.stop()'
|
||||||
|
@@ -301,7 +301,7 @@ api.nvim_create_autocmd('OptionSet', {
|
|||||||
--- - `captures`: a list of unique capture names defined in the query (alias: `info.captures`).
|
--- - `captures`: a list of unique capture names defined in the query (alias: `info.captures`).
|
||||||
--- - `info.patterns`: information about predicates.
|
--- - `info.patterns`: information about predicates.
|
||||||
---
|
---
|
||||||
--- Example (to try it, use `yxx` or select the code then run `:'<,'>lua`):
|
--- Example (to try it, use `g==` or select the code then run `:'<,'>lua`):
|
||||||
--- ```lua
|
--- ```lua
|
||||||
--- local query = vim.treesitter.query.parse('vimdoc', [[
|
--- local query = vim.treesitter.query.parse('vimdoc', [[
|
||||||
--- ; query
|
--- ; query
|
||||||
|
Reference in New Issue
Block a user