summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--.vim/after/ftplugin/markdown.lua24
-rw-r--r--.vim/lua/plugins.lua1
2 files changed, 21 insertions, 4 deletions
diff --git a/.vim/after/ftplugin/markdown.lua b/.vim/after/ftplugin/markdown.lua
index d07e131..49dbcee 100644
--- a/.vim/after/ftplugin/markdown.lua
+++ b/.vim/after/ftplugin/markdown.lua
@@ -1,5 +1,6 @@
 require('spell')
-vim.opt.foldlevel = 1
+vim.opt_local.foldenable = false
+vim.opt_local.foldlevel = 1
 
 vim.fn.matchadd('Conceal', '- \\[ \\]\\&- \\zs\\[ ', 0, -1, { conceal = '☐ ' })
 -- vim.fn.matchadd('Conceal', '\\[x\\]', 0, -1, { conceal = '☑ ' })
@@ -27,8 +28,7 @@ local function toggle_checkbox()
   vim.api.nvim_set_current_line(ln)
 end
 vim.keymap.set('n', '<space><space>', toggle_checkbox, {desc='toggle checkbox'})
-vim.keymap.set('n', '<tab><tab>', toggle_checkbox, {desc='toggle checkbox'})
-vim.keymap.set('i', '<c-tab>', toggle_checkbox, {desc='toggle checkbox'})
+vim.keymap.set('i', '<c-space>', toggle_checkbox, {desc='toggle checkbox'})
 
 -- vim.keymap.set('n', '<leader>zn', function() require('zk').new() end)
 -- vim.keymap.set('n', '<leader>zi', function() require('zk').index() end)
@@ -37,3 +37,21 @@ vim.keymap.set('i', '<c-tab>', toggle_checkbox, {desc='toggle checkbox'})
 vim.keymap.set('n', 'gt', function()
   require('telescope._extensions.todo-comments').exports.todo {cwd=vim.env.ZK_NOTEBOOK_DIR}
 end, {desc='show zk todos'})
+
+vim.keymap.set('n', 'o', function()
+  local cursor = vim.api.nvim_win_get_cursor(0)
+  -- need to decrement the row number here, to account for 0 indexing
+  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, {})
+      })
+      vim.api.nvim_feedkeys('jA', 'n', false)
+      return
+    end
+    node = node:parent()
+  end
+
+  vim.api.nvim_feedkeys('o', 'n', false)
+end, {desc='smart-o'})
diff --git a/.vim/lua/plugins.lua b/.vim/lua/plugins.lua
index db76618..768f051 100644
--- a/.vim/lua/plugins.lua
+++ b/.vim/lua/plugins.lua
@@ -951,7 +951,6 @@ require('packer').startup({function()
       vim.g.vim_markdown_conceal_code_blocks = true
     end} -- }}}
 
-  -- use {'masukomi/vim-markdown-folding', ft = {'markdown'}}
   use {'gentoo/gentoo-syntax'}
 
   use {'NMAC427/guess-indent.nvim', disable = false, -- {{{