aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/_defaults.lua
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-04-05 18:08:54 +0800
committerGitHub <noreply@github.com>2024-04-05 18:08:54 +0800
commit9711370c26453f3a966b9306111939b144248b41 (patch)
treeefa026eba653f1af347b280cf3b187b9046372a0 /runtime/lua/vim/_defaults.lua
parenta500c5f808ccf0b678c935f00e0af4503a5bd724 (diff)
downloadrneovim-9711370c26453f3a966b9306111939b144248b41.tar.gz
rneovim-9711370c26453f3a966b9306111939b144248b41.tar.bz2
rneovim-9711370c26453f3a966b9306111939b144248b41.zip
feat(defaults): add :Inspect to right-click menu (#28181)
Ref #21393 - Move default user commands to _defaults.lua as that now contains all kinds of defaults rather than just default mappings and menus. - Remove the :aunmenu as there are no menus when _defaults.lua is run.
Diffstat (limited to 'runtime/lua/vim/_defaults.lua')
-rw-r--r--runtime/lua/vim/_defaults.lua30
1 files changed, 29 insertions, 1 deletions
diff --git a/runtime/lua/vim/_defaults.lua b/runtime/lua/vim/_defaults.lua
index 6223082622..0798ca8d16 100644
--- a/runtime/lua/vim/_defaults.lua
+++ b/runtime/lua/vim/_defaults.lua
@@ -1,3 +1,31 @@
+--- Default user commands
+do
+ vim.api.nvim_create_user_command('Inspect', function(cmd)
+ if cmd.bang then
+ vim.print(vim.inspect_pos())
+ else
+ vim.show_pos()
+ end
+ end, { desc = 'Inspect highlights and extmarks at the cursor', bang = true })
+
+ vim.api.nvim_create_user_command('InspectTree', function(cmd)
+ if cmd.mods ~= '' or cmd.count ~= 0 then
+ local count = cmd.count ~= 0 and cmd.count or ''
+ local new = cmd.mods ~= '' and 'new' or 'vnew'
+
+ vim.treesitter.inspect_tree({
+ command = ('%s %s%s'):format(cmd.mods, count, new),
+ })
+ else
+ vim.treesitter.inspect_tree()
+ end
+ end, { desc = 'Inspect treesitter language tree for buffer', count = true })
+
+ vim.api.nvim_create_user_command('EditQuery', function(cmd)
+ vim.treesitter.query.edit(cmd.fargs[1])
+ end, { desc = 'Edit treesitter query', nargs = '?' })
+end
+
--- Default mappings
do
--- Default maps for * and # in visual mode.
@@ -93,7 +121,6 @@ do
--- Right click popup menu
-- TODO VimScript, no l10n
vim.cmd([[
- aunmenu *
vnoremenu PopUp.Cut "+x
vnoremenu PopUp.Copy "+y
anoremenu PopUp.Paste "+gP
@@ -102,6 +129,7 @@ do
nnoremenu PopUp.Select\ All ggVG
vnoremenu PopUp.Select\ All gg0oG$
inoremenu PopUp.Select\ All <C-Home><C-O>VG
+ anoremenu PopUp.Inspect <Cmd>Inspect<CR>
anoremenu PopUp.-1- <Nop>
anoremenu PopUp.How-to\ disable\ mouse <Cmd>help disable-mouse<CR>
]])