Skip to content

Commit 4812bdd

Browse files
committed
Update markview keyboard shortcut
- Update the keyboard shortcut to imitate Joplin behavior
1 parent 2133680 commit 4812bdd

File tree

1 file changed

+31
-28
lines changed

1 file changed

+31
-28
lines changed

lua/custom/plugins/init.lua

Lines changed: 31 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,37 @@
33
--
44
-- See the kickstart.nvim README for more information
55
return {
6-
{
7-
'OXY2DEV/markview.nvim',
8-
lazy = false, -- Recommended
9-
-- ft = "markdown" -- If you decide to lazy-load anyway
10-
11-
dependencies = {
12-
'nvim-treesitter/nvim-treesitter',
13-
'nvim-tree/nvim-web-devicons',
14-
},
6+
{
7+
'OXY2DEV/markview.nvim',
8+
lazy = false, -- Recommended
9+
-- ft = "markdown" -- If you decide to lazy-load anyway
1510

16-
opts = {
17-
initial_state = false,
18-
},
19-
config = function(_, opts)
20-
require('markview').setup(opts)
21-
22-
local splitToggle_state = false
23-
vim.keymap.set('n', '<C-ö>', function()
24-
if not splitToggle_state then
25-
-- The split toggle will not work unless markview is disabled in the initial window beforehand
26-
vim.cmd 'Markview disableAll'
27-
vim.cmd 'Markview splitEnable'
28-
splitToggle_state = true
29-
else
30-
vim.cmd 'Markview splitDisable'
31-
splitToggle_state = false
32-
end
33-
end, { silent = true, desc = 'Toggle Markview split view' })
34-
end,
11+
dependencies = {
12+
'nvim-treesitter/nvim-treesitter',
13+
'nvim-tree/nvim-web-devicons',
3514
},
15+
16+
opts = {
17+
initial_state = false,
18+
},
19+
config = function(_, opts)
20+
require('markview').setup(opts)
21+
22+
-- This function imitates the behavior of Joplin when rendering notes
23+
local splitToggle_state = 0
24+
vim.keymap.set('n', '<C-ö>', function()
25+
if splitToggle_state == 0 then
26+
vim.cmd 'Markview enableAll'
27+
splitToggle_state = 1
28+
elseif splitToggle_state == 1 then
29+
vim.cmd 'Markview splitEnable'
30+
splitToggle_state = 2
31+
else
32+
vim.cmd 'Markview splitDisable'
33+
vim.cmd 'Markview disableAll'
34+
splitToggle_state = 0
35+
end
36+
end, { silent = true, desc = 'Toggle Markview split view' })
37+
end,
38+
},
3639
}

0 commit comments

Comments
 (0)