diff --git a/lua/custom/plugins/init.lua b/lua/custom/plugins/init.lua index d8dfd9b1..4170ae60 100644 --- a/lua/custom/plugins/init.lua +++ b/lua/custom/plugins/init.lua @@ -3,34 +3,37 @@ -- -- See the kickstart.nvim README for more information return { - { - 'OXY2DEV/markview.nvim', - lazy = false, -- Recommended - -- ft = "markdown" -- If you decide to lazy-load anyway - - dependencies = { - 'nvim-treesitter/nvim-treesitter', - 'nvim-tree/nvim-web-devicons', - }, + { + 'OXY2DEV/markview.nvim', + lazy = false, -- Recommended + -- ft = "markdown" -- If you decide to lazy-load anyway - opts = { - initial_state = false, - }, - config = function(_, opts) - require('markview').setup(opts) - - local splitToggle_state = false - vim.keymap.set('n', '', function() - if not splitToggle_state then - -- The split toggle will not work unless markview is disabled in the initial window beforehand - vim.cmd 'Markview disableAll' - vim.cmd 'Markview splitEnable' - splitToggle_state = true - else - vim.cmd 'Markview splitDisable' - splitToggle_state = false - end - end, { silent = true, desc = 'Toggle Markview split view' }) - end, + dependencies = { + 'nvim-treesitter/nvim-treesitter', + 'nvim-tree/nvim-web-devicons', }, + + opts = { + initial_state = false, + }, + config = function(_, opts) + require('markview').setup(opts) + + -- This function imitates the behavior of Joplin when rendering notes + local splitToggle_state = 0 + vim.keymap.set('n', '', function() + if splitToggle_state == 0 then + vim.cmd 'Markview enableAll' + splitToggle_state = 1 + elseif splitToggle_state == 1 then + vim.cmd 'Markview splitEnable' + splitToggle_state = 2 + else + vim.cmd 'Markview splitDisable' + vim.cmd 'Markview disableAll' + splitToggle_state = 0 + end + end, { silent = true, desc = 'Toggle Markview split view' }) + end, + }, }