summary refs log tree commit diff
path: root/.vim/after
diff options
context:
space:
mode:
authorRobert Günzler <r@gnzler.io>2022-11-04 16:35:44 +0100
committerRobert Günzler <r@gnzler.io>2022-11-18 18:37:23 +0100
commit4e4bd3beb90a4057ca97086bc4ba1acde109b65f (patch)
tree46b32651306eb407d67032982b2b00152a81e32c /.vim/after
parent6995add9f0bc738d37821fd0d872f756ee30c48c (diff)
vim: handle numbered lists with smart-o
Diffstat (limited to '.vim/after')
-rw-r--r--.vim/after/ftplugin/markdown.lua8
1 files changed, 5 insertions, 3 deletions
diff --git a/.vim/after/ftplugin/markdown.lua b/.vim/after/ftplugin/markdown.lua
index c827d17..226f9ed 100644
--- a/.vim/after/ftplugin/markdown.lua
+++ b/.vim/after/ftplugin/markdown.lua
@@ -44,9 +44,11 @@ vim.keymap.set('n', 'o', function()
   local node = vim.treesitter.get_node_at_pos(0, cursor[1]-1, cursor[2], {})
   while node do
     if node:type() == 'list_item' then
-      vim.api.nvim_buf_set_lines(0, cursor[1], cursor[1], false, {
-        vim.treesitter.get_node_text(node:child(0), 0, {})
-      })
+      local ln = vim.treesitter.get_node_text(node:child(0), 0, {})
+      local ln_start = string.match(ln, '^(%d+)%.'); if ln_start ~= nil then
+        ln = ln:gsub(ln_start, tonumber(ln_start)+1)
+      end
+      vim.api.nvim_buf_set_lines(0, cursor[1], cursor[1], false, {ln})
       vim.api.nvim_feedkeys('jA', 'n', false)
       return
     end