From 0ec49583bd7cf73341f52ce56ddc6aa033a7ad15 Mon Sep 17 00:00:00 2001 From: Marty Oehme Date: Sun, 16 Jun 2024 21:30:20 +0200 Subject: [PATCH] nvim: Set up image.nvim image display Finally got image.nvim fully working on wezterm with the kitty backend and auto-installed rock dependencies. --- nvim/.config/nvim/lazy-lock.json | 2 + .../nvim/lua/plugins/data_analysis.lua | 53 +++++++++++++------ 2 files changed, 40 insertions(+), 15 deletions(-) diff --git a/nvim/.config/nvim/lazy-lock.json b/nvim/.config/nvim/lazy-lock.json index 940af3f..1ed5022 100644 --- a/nvim/.config/nvim/lazy-lock.json +++ b/nvim/.config/nvim/lazy-lock.json @@ -38,6 +38,7 @@ "lazy.nvim": { "branch": "main", "commit": "fafe1f7c640aed75e70a10e6649612cd96f39149" }, "lsp-setup.nvim": { "branch": "main", "commit": "6e4e977512ce426d8b52c27f3b6e6aefc73e1452" }, "lualine.nvim": { "branch": "master", "commit": "0a5a66803c7407767b799067986b4dc3036e1983" }, + "luarocks.nvim": { "branch": "main", "commit": "1db9093915eb16ba2473cfb8d343ace5ee04130a" }, "markmap.nvim": { "branch": "main", "commit": "5fb6755cf5434511cc23a4936c9eb76b9142fba5" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "9ae570e206360e47d30b4c35a4550c165f4ea7b7" }, "mason-tool-installer.nvim": { "branch": "main", "commit": "c5e07b8ff54187716334d585db34282e46fa2932" }, @@ -84,6 +85,7 @@ "vim-pandoc-syntax": { "branch": "master", "commit": "16939cda184ff555938cc895cc62477c172997f9" }, "vim-scimark": { "branch": "master", "commit": "9b66a88fa4bb87b8baab3c4aecc43b985b32e7fd" }, "vim-spellsync": { "branch": "master", "commit": "3d6dd50de9c4d953cc16638112a6ae196df41463" }, + "wezterm.nvim": { "branch": "main", "commit": "f73bba23ab4becd146fa2d0a3a16a84b987eeaca" }, "which-key.nvim": { "branch": "main", "commit": "0539da005b98b02cf730c1d9da82b8e8edb1c2d2" }, "wrapping.nvim": { "branch": "master", "commit": "3a823200c297885b70515fa8d974e1763c578e26" }, "zen-mode.nvim": { "branch": "main", "commit": "cb73b8bd0ef9d765b942db09dc762c603a89ae44" }, diff --git a/nvim/.config/nvim/lua/plugins/data_analysis.lua b/nvim/.config/nvim/lua/plugins/data_analysis.lua index 6eb80b2..9d6e926 100644 --- a/nvim/.config/nvim/lua/plugins/data_analysis.lua +++ b/nvim/.config/nvim/lua/plugins/data_analysis.lua @@ -50,25 +50,48 @@ return { ft = { "quarto" }, }, + { + "vhyrro/luarocks.nvim", + priority = 1001, -- this plugin needs to run before anything else + opts = { + rocks = { "magick" }, + }, + }, + -- image display { "3rd/image.nvim", + dependencies = { "luarocks.nvim" }, + cond = vim.fn.executable("magick") == 1, -- only runs if imagemagick installed config = function() - -- Example for configuring Neovim to load user-installed installed Lua rocks: - package.path = package.path .. ";" .. vim.fn.expand("$HOME") .. "/.luarocks/share/lua/5.1/?/init.lua;" - package.path = package.path .. ";" .. vim.fn.expand("$HOME") .. "/.luarocks/share/lua/5.1/?.lua;" - require("image").setup({ - backend = "kitty", - integrations = { - markdown = { - enabled = true, - download_remote_images = true, - only_render_image_at_cursor = true, - filetypes = { "markdown", "vimwiki", "quarto" }, - }, - }, - }) + local integrations = {} + if vim.treesitter.language.get_lang("markdown") then + integrations["markdown"] = { + enabled = true, + clear_in_insert_mode = true, + download_remote_images = true, + only_render_image_at_cursor = true, + filetypes = { "markdown", "vimwiki", "quarto" }, + } + end + if vim.treesitter.language.get_lang("norg") then + integrations["neorg"] = { + enabled = true, + clear_in_insert_mode = true, + download_remote_images = true, + only_render_image_at_cursor = true, + filetypes = { "norg" }, + } + end + if next(integrations) ~= nil then -- only set up if we have at least 1 TS parser + require("image").setup({ + backend = "kitty", + integrations = integrations, + }) + vim.g.molten_image_provider = "image.nvim" + end end, - ft = { "markdown", "vimwiki", "quarto" }, + ft = { "markdown", "vimwiki", "quarto", "norg", "python" }, + priority = 51, }, -- REPL work {