diff --git a/nvim/.config/nvim/after/ftplugin/markdown.lua b/nvim/.config/nvim/after/ftplugin/markdown.lua index 9da841e..303dc82 100644 --- a/nvim/.config/nvim/after/ftplugin/markdown.lua +++ b/nvim/.config/nvim/after/ftplugin/markdown.lua @@ -32,18 +32,18 @@ if require("core.util").is_available("which-key") then require("which-key").add({ "p", group = "prose" }) end -- show nice md preview in browser (auto-syncs scrolling) +local peek_key = "po" if require("core.util").is_available("peek") then - local peek = require("peek") - local function togglePeek() + map("n", peek_key, function() + local peek = require("peek") if peek.is_open() then peek.close() else peek.open() end - end - map("n", "po", togglePeek, { desc = "show md preview" }) -else - map("n", "po", "MarkdownPreviewToggle", { desc = "show md preview" }) + end, { desc = "show md preview" }) +elseif vim.fn.exists(":MarkdownPreviewToggle") > 0 then + map("n", peek_key, "MarkdownPreviewToggle", { desc = "show md preview" }) end -- create mindmaps directly from markdown! requires external executable diff --git a/nvim/.config/nvim/after/ftplugin/quarto.lua b/nvim/.config/nvim/after/ftplugin/quarto.lua index 213108e..3251bbc 100644 --- a/nvim/.config/nvim/after/ftplugin/quarto.lua +++ b/nvim/.config/nvim/after/ftplugin/quarto.lua @@ -1,3 +1,7 @@ +if require("core.util").is_available("quarto") then + vim.keymap.set("n", "po", require("quarto").quartoPreview, { desc = "show quarto preview" }) +end + local default_buffer_session = function() local buffer_path = vim.api.nvim_buf_get_name(0) or vim.fn.tempname() local temp_path = vim.fn.stdpath("run") .. "/molten-sessions" .. buffer_path .. ".json" @@ -34,7 +38,6 @@ local startsession = function(opts) -- simply attach to existing if exists if vim.fn.filereadable(kernel_filen) == 1 then - print(kernel_filen) vim.cmd("MoltenInit " .. kernel_filen) return end diff --git a/nvim/.config/nvim/after/ftplugin/typst.lua b/nvim/.config/nvim/after/ftplugin/typst.lua new file mode 100644 index 0000000..e3d8d14 --- /dev/null +++ b/nvim/.config/nvim/after/ftplugin/typst.lua @@ -0,0 +1,3 @@ +if vim.fn.exists(":TypstPreviewToggle") > 0 then + vim.keymap.set("n", "po", "TypstPreviewToggle", { desc = "show typst preview" }) +end diff --git a/nvim/.config/nvim/lazy-lock.json b/nvim/.config/nvim/lazy-lock.json index 9cdd146..838c019 100644 --- a/nvim/.config/nvim/lazy-lock.json +++ b/nvim/.config/nvim/lazy-lock.json @@ -74,6 +74,7 @@ "todo-comments.nvim": { "branch": "main", "commit": "ae0a2afb47cf7395dc400e5dc4e05274bf4fb9e0" }, "trouble.nvim": { "branch": "main", "commit": "40c5317a6e90fe3393f07b0fee580d9e93a216b4" }, "twilight.nvim": { "branch": "main", "commit": "8bb7fa7b918baab1ca81b977102ddb54afa63512" }, + "typst-preview.nvim": { "branch": "master", "commit": "c1100e8788baabe8ca8f8cd7fd63d3d479e49e36" }, "undotree": { "branch": "main", "commit": "eab459ab87dd249617b5f7187bb69e614a083047" }, "vifm.vim": { "branch": "master", "commit": "a8130c37d144b51d84bee19f0532abcd3583383f" }, "vim-criticmarkup": { "branch": "master", "commit": "d15dc134eb177a170c79f6377f81eb02a9d20b02" }, diff --git a/nvim/.config/nvim/lua/plugins/prose.lua b/nvim/.config/nvim/lua/plugins/prose.lua index dbd4f3a..76b531b 100644 --- a/nvim/.config/nvim/lua/plugins/prose.lua +++ b/nvim/.config/nvim/lua/plugins/prose.lua @@ -97,7 +97,7 @@ local prose_plugs = { cmd = "RenderMarkdown", keys = { { - "pp", + "pm", function() require("render-markdown").toggle() end, @@ -106,29 +106,43 @@ local prose_plugs = { }, }, }, + --- PREVIEW SECTION -- generate an auto-updating html preview for md files -- uses the very nice peek if deno is available, otherwise falls back to markdown-preview { "toppair/peek.nvim", - event = { "VeryLazy" }, cond = vim.fn.executable("deno") == 1, build = "deno task --quiet build:fast", ft = md_like, - config = function() - require("peek").setup() - vim.api.nvim_create_user_command("PeekOpen", require("peek").open, {}) - vim.api.nvim_create_user_command("PeekClose", require("peek").close, {}) - end, + opts = {}, }, { "iamcco/markdown-preview.nvim", - event = { "VeryLazy" }, cond = vim.fn.executable("deno") == 0, build = function() vim.fn["mkdp#util#install"]() end, + version = false, ft = md_like, + cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" }, }, + { + "chomosuke/typst-preview.nvim", + ft = { "typst" }, + opts = { -- to use mason-managed binary + dependencies_bin = { ["tinymist"] = "tinymist" }, + }, + cmd = { + "TypstPreview", + "TypstPreviewUpdate", + "TypstPreviewStop", + "TypstPreviewToggle", + "TypstPreviewFollowCursor", + "TypstPreviewNoFollowCursor", + "TypstPreviewFollowCursorToggle", + }, + }, + --- END PREVIEW SECTION -- easy copy paste of images into markup files { @@ -145,7 +159,7 @@ local prose_plugs = { }, cmd = { "PasteImage" }, keys = { - { "pi", "PasteImage", desc = "Paste image from system clipboard" }, + { "pi", "PasteImage", desc = "Paste image from system clipboard" }, }, ft = prose_ft, }, @@ -244,22 +258,25 @@ local prose_plugs = { -- cite as you write from papis databases -- ADDITIONAL DEPENDENCIES: papis and yq in shell env - -- { - -- "jghauser/papis.nvim", - -- dependencies = { - -- "kkharji/sqlite.lua", - -- "MunifTanjim/nui.nvim", - -- "pysan3/pathlib.nvim", - -- "nvim-neotest/nvim-nio", - -- "nvim-treesitter/nvim-treesitter", - -- }, - -- cond = vim.fn.executable("papis") == 1 and vim.fn.executable("yq") == 1, - -- ft = writing_ft, - -- lazy = false, - -- config = function() - -- require("papis").setup({}) - -- end, - -- }, + -- still same issues: slow, buggy, does not work for me + { + "jghauser/papis.nvim", + dependencies = { + "kkharji/sqlite.lua", + "MunifTanjim/nui.nvim", + "pysan3/pathlib.nvim", + "nvim-neotest/nvim-nio", + -- if not already installed, you may also want: + { "nvim-telescope/telescope.nvim", optional = true }, + -- "hrsh7th/nvim-cmp", + }, + config = function() + require("papis").setup({ + init_filetypes = prose_ft, + }) + end, + lazy = false, + }, { "barreiroleo/ltex_extra.nvim", branch = "dev",