Closed Jarshvor closed 7 months ago
I hope it is alright to ask here.
That's totally fine!
Can you try setting debug to true and paste the output of :messages
? The config should look like this in lazy.nvim (which seems to be recommended over vim-plug these days):
opts = {
default = {
debug = true,
},
},
P.S. (There is a small typo in the github 'bug' issue template for this repo. ^verison^version
Thanks! Fixed in https://github.com/HakonHarnes/img-clip.nvim/commit/852a1f8dd349af3e3261d40939ee05cdb0388573.
Perhaps vim-plug isn't calling the setup
function? Could you please save this as repro.lua
and run it with nvim -u repro.lua
and see if that resolves the issue?
-- save as repro.lua
-- run with nvim -u repro.lua
-- DO NOT change the paths
local root = vim.fn.fnamemodify("./.repro", ":p")
-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "runtime", "cache" }) do
vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"--single-branch",
"https://github.com/folke/lazy.nvim.git",
lazypath,
})
end
vim.opt.runtimepath:prepend(lazypath)
-- install plugins
local plugins = {
{
"hakonharnes/img-clip.nvim",
config = true,
},
-- add any other plugins here
}
require("lazy").setup(plugins, {
root = root .. "/plugins",
})
Perhaps vim-plug isn't calling the
setup
function? Could you please save this asrepro.lua
and run it withnvim -u repro.lua
and see if that resolves the issue?
Thanks @HakonHarnes! That does indeed resolve it! I guess I should have tested the recommended plugin manager from the project. (Didn't know vim-plug was 'out of favour'. Will look into that for sure and consider lazy-vim).
Managed to drag and drop some images into my squeaky clean .tex file and the appropriate figure environment appeared like magic. Thanks so much for this project. I was really missing something like this working with latex in vim.
Side (and possibly beginner) question: Will this plugin work at all under plain vim? (considering I use an adequate plugin manager to install it?) Or does the fact that it's written in lua make it not compatible at all with vim?
If that's the case I will probably switch to nvim from vim, but just asking out of curiosity.
Thanks again for the help and the great plugin!
That does indeed resolve it!
No problem, glad I could help!
Side (and possibly beginner) question: Will this plugin work at all under plain vim? (considering I use an adequate plugin manager to install it?) Or does the fact that it's written in lua make it not compatible at all with vim?
AFAIK Lua plugins will only work in Neovim (unless something has changed since I switched from Vim myself). Both Lua and Vimscript plugins work in Neovim.
If that's the case I will probably switch to nvim from vim, but just asking out of curiosity.
I see no reason not to make the switch to Neovim. Writing the configuration in Lua is so much nicer than in Vimscript. There are also a lot of pre-configured Neovim distros, like LazyVim, NvChad, kickstart.nvim etc. I'd check those out if you're looking for a fully-fledged IDE-like experience.
I was really missing something like this working with latex in vim.
I recommend you check out Typst, a modern alternative to LaTeX written in Rust with incremental compilation (so it's blazingly fast), and a much simpler syntax. I've really been enjoying it.
By the way @Jarshvor (and to anyone else reading this thread later on) there are similar plugins that work with Vim. These might not be as feature-rich as this plugin, but it should allow you to at least paste images from the clipboard.
So, if you're not looking to migrate from Vim to Neovim, see img-paste.vim.
I did have a look at img-paste, however what I am interested in most, is the drag-and-drop feature from my file manager, and it doesn't seem that img-paste supports that.
So I will be using img-clip for sure. At least when I have to go and insert a bunch of images. For now both vim and nvim co-exist peacefully on my machine. Only time will tell if I finally make the jump or not.
And thanks for the Typist recommendation btw. It looks almost.. "too good to be true"..? Is that just cause it's like really young? I can barely find any info on it except on the homepage.
And thanks for the Typist recommendation btw. It looks almost.. "too good to be true"..? Is that just cause it's like really young?
It looks too good to be true, not because it's really young; but because you're used to LaTeX. LaTeX was released in the 1980s and relies on a messy ecosystem of plugins for basic functionality. The PDFs it produces is great, but it's horribly slow, the errors are difficult to decipher, and the syntax is really \textbf{\textit{\huge{convoluted}}}\normalsize
.
I believe they started working on Typst in 2019, but only recently open sourced it in 2023. It's already quite powerful. I know people have written books, presentations and their master's thesis in it already. There has been other attempts to de-throne LaTeX throughout the years, but I think this has a really good chance.
I can barely find any info on it except on the homepage.
You should join their Discord. They showcase a lot of cool stuff and you can ask for help there as well. Also, check out:
Also, there's a typst plugin for (neo)vim:
You might have to use Neovim nightly for it though. Although the web app is also great and has an integrated vim mode.
Was just going to comment that after perusing their Mastodon and GitHub page I am officially intrigued. Guess I maybe wont be earning that LATEX street-cred after all (hehe).
Thanks for those links btw. Will check those plugins out!
No worries! I hope for broader adoption of Typst, so I mention it to people whenever I can :)
It's still useful to learn LaTeX, especially if you ever want to publish something. Typst is not yet supported by journals, and likely won't be for a long time.
Hello, I'm actually having a similar problem but with lazy.nvim as my plugin manager. I'm on mac, and I turned on debug. I just got the PNG data when I tried to use the command.
I find a new directory: v:null though.
@SeniorMars Does the issue persist with the repro? Save the below code block as repro.lua
and run it with nvim -u repro.lua
:
-- save as repro.lua
-- run with nvim -u repro.lua
-- DO NOT change the paths
local root = vim.fn.fnamemodify("./.repro", ":p")
-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "runtime", "cache" }) do
vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end
-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
"git",
"clone",
"--filter=blob:none",
"--single-branch",
"https://github.com/folke/lazy.nvim.git",
lazypath,
})
end
vim.opt.runtimepath:prepend(lazypath)
-- install plugins
local plugins = {
{
"hakonharnes/img-clip.nvim",
config = true,
},
-- add any other plugins here
}
require("lazy").setup(plugins, {
root = root .. "/plugins",
})
Seems like the setup
function is only being called if the opts
or config = true
is set in lazy.nvim. This is due to a regression in https://github.com/HakonHarnes/img-clip.nvim/commit/ad88dee260145ffbdd4c9f7375011999b2e5aa83 where I removed the M.setup()
call. This has been reverted in https://github.com/HakonHarnes/img-clip.nvim/commit/c93f0d67db424e9e83fe55730aa42dfafa847d8f.
@SeniorMars, this should resolve your issues.
@Jarshvor, you should be able to use vim-plug if you so wish :)
hehe.. Thanks a bunch @HakonHarnes. That means I can simply sym-link my .vimrc to nvim for now.
Was unable to debug this by myself and did not manage to get support elsewhere. I hope it is alright to ask here.
Problem: When trying to use the :PasteImage command I get the following error: 'Could not insert markup code'. This happens irrespective of weather I paste from clipboard, or drag and drop from filesystem.
Neovim version: 0.9.5-2
xclip 0.13 is installed and seems to work correctly.
minimal
.config/nvim/init.vim
(literally nothing else in there)" Declare the list of plugins. "# Drag n' Drop and paste Images Plug 'HakonHarnes/img-clip.nvim'
" List ends here. Plugins become visible to Vim after this call. call plug#end()
Executing command: "'/bin/bash' '-c' 'xclip -selection clipboard -t TARGETS -o'" Executing command: "'/bin/bash' '-c' 'xclip -selection clipboard -o -t image/png > "v:null/lun 05 feb 2024 20:51:36.png"'" Could not insert markup code.