nvim: Ensure TS is always set up for image.nvim

This commit is contained in:
Marty Oehme 2024-06-20 17:43:11 +02:00
parent 87ce74de40
commit 51145e740a
Signed by: Marty
GPG key ID: EDBF2ED917B2EF6A
3 changed files with 10 additions and 5 deletions

View file

@ -12,7 +12,11 @@ end
-- Start quarto session -- Start quarto session
local startsession = function(file, args) local startsession = function(file, args)
file = file or default_buffer_session() file = file or default_buffer_session()
local path = require("core.util").get_python_venv_bin() local path = require("core.util").get_python_venv_bin()
if not path then
return
end
vim.g["python3_host_prog"] = path vim.g["python3_host_prog"] = path
if vim.fn.executable("jupyter-console") ~= 1 then if vim.fn.executable("jupyter-console") ~= 1 then

View file

@ -157,10 +157,10 @@ local python_path
lspconfig.basedpyright.setup({ lspconfig.basedpyright.setup({
on_attach = function(client, bufnr) on_attach = function(client, bufnr)
on_attach(client, bufnr) on_attach(client, bufnr)
require("core.util").set_python_env()
if python_path == nil then if python_path == nil then
python_path, _ = vim.fn.expand(require("core.util").get_python_venv_bin(client.config.root_dir)) python_path, _ = vim.fn.expand(require("core.util").get_python_venv_bin(client.config.root_dir))
end end
vim.g["python3_host_prog"] = python_path
-- print(string.format("[PYTHON VENV]: %s", vim.inspect(python_path))) -- print(string.format("[PYTHON VENV]: %s", vim.inspect(python_path)))
client.config.settings.python = {} or client.config.settings.python client.config.settings.python = {} or client.config.settings.python
client.config.settings.python.pythonPath = python_path client.config.settings.python.pythonPath = python_path
@ -180,11 +180,11 @@ lspconfig.basedpyright.setup({
lspconfig.ruff.setup({ lspconfig.ruff.setup({
on_attach = function(client, bufnr) on_attach = function(client, bufnr)
on_attach(client, bufnr) on_attach(client, bufnr)
require("core.util").set_python_env()
client.server_capabilities.hoverProvider = false -- we use pyright for hover info client.server_capabilities.hoverProvider = false -- we use pyright for hover info
if python_path == nil then if python_path == nil then
python_path, _ = vim.fn.expand(require("core.util").get_python_venv_bin(client.config.root_dir)) python_path, _ = vim.fn.expand(require("core.util").get_python_venv_bin(client.config.root_dir))
end end
vim.g["python3_host_prog"] = python_path
client.config.settings.python = {} or client.config.settings.python client.config.settings.python = {} or client.config.settings.python
client.config.settings.python.pythonPath = python_path client.config.settings.python.pythonPath = python_path
end, end,

View file

@ -60,7 +60,7 @@ return {
-- image display -- image display
{ {
"3rd/image.nvim", "3rd/image.nvim",
dependencies = { "luarocks.nvim" }, dependencies = { "luarocks.nvim", { "nvim-treesitter/nvim-treesitter", optional = true } },
cond = vim.fn.executable("magick") == 1, -- only runs if imagemagick installed cond = vim.fn.executable("magick") == 1, -- only runs if imagemagick installed
config = function() config = function()
local integrations = {} local integrations = {}
@ -88,10 +88,11 @@ return {
integrations = integrations, integrations = integrations,
}) })
vim.g.molten_image_provider = "image.nvim" vim.g.molten_image_provider = "image.nvim"
pcall(vim.fn.MoltenUpdateOption, "molten_image_provider", "image.nvim")
end end
end, end,
ft = { "markdown", "vimwiki", "quarto", "norg", "python" }, ft = { "markdown", "vimwiki", "quarto", "norg", "python" },
priority = 51, priority = 60,
}, },
-- REPL work -- REPL work
{ {
@ -242,6 +243,6 @@ return {
}, },
}, },
cond = vim.fn.executable("jupytext") == 1, -- only runs if imagemagick installed cond = vim.fn.executable("jupytext") == 1, -- only runs if imagemagick installed
lazy = false -- does not work in lazy mode lazy = false, -- does not work in lazy mode
}, },
} }