aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/_defaults.lua
diff options
context:
space:
mode:
authorPeter Aronoff <peter@aronoff.org>2024-11-17 16:31:24 -0500
committerGitHub <noreply@github.com>2024-11-17 13:31:24 -0800
commitcc6992f1ca443f4da01cb4d57159d4cef37b36b7 (patch)
tree3b51134d7e6190637daff3db1d274159118ed6e4 /runtime/lua/vim/_defaults.lua
parent44229bb85b6cff00193164967126d85a7a785a7b (diff)
downloadrneovim-cc6992f1ca443f4da01cb4d57159d4cef37b36b7.tar.gz
rneovim-cc6992f1ca443f4da01cb4d57159d4cef37b36b7.tar.bz2
rneovim-cc6992f1ca443f4da01cb4d57159d4cef37b36b7.zip
feat(defaults): dot-repeat [<Space> #31186
Problem: `[<Space>` and `]<Space>` do not support repetition. Solution: use `operatorfunc` and `g@l` to make these mappings dot repeatable.
Diffstat (limited to 'runtime/lua/vim/_defaults.lua')
-rw-r--r--runtime/lua/vim/_defaults.lua16
1 files changed, 8 insertions, 8 deletions
diff --git a/runtime/lua/vim/_defaults.lua b/runtime/lua/vim/_defaults.lua
index 25afd83145..06f6ed6829 100644
--- a/runtime/lua/vim/_defaults.lua
+++ b/runtime/lua/vim/_defaults.lua
@@ -366,16 +366,16 @@ do
-- Add empty lines
vim.keymap.set('n', '[<Space>', function()
- local repeated = vim.fn['repeat']({ '' }, vim.v.count1)
- local linenr = vim.api.nvim_win_get_cursor(0)[1]
- vim.api.nvim_buf_set_lines(0, linenr - 1, linenr - 1, true, repeated)
- end, { desc = 'Add empty line above cursor' })
+ -- TODO: update once it is possible to assign a Lua function to options #25672
+ vim.go.operatorfunc = "v:lua.require'vim._buf'.space_above"
+ return 'g@l'
+ end, { expr = true, desc = 'Add empty line above cursor' })
vim.keymap.set('n', ']<Space>', function()
- local repeated = vim.fn['repeat']({ '' }, vim.v.count1)
- local linenr = vim.api.nvim_win_get_cursor(0)[1]
- vim.api.nvim_buf_set_lines(0, linenr, linenr, true, repeated)
- end, { desc = 'Add empty line below cursor' })
+ -- TODO: update once it is possible to assign a Lua function to options #25672
+ vim.go.operatorfunc = "v:lua.require'vim._buf'.space_below"
+ return 'g@l'
+ end, { expr = true, desc = 'Add empty line below cursor' })
end
end