Closed kawarimidoll closed 2 years ago
You should try doing require('hologram').setup()
before executing the example code, it should work
You should try doing require('hologram').setup() before executing the example code, it should work
It still raises same error ๐ข
In GIF above,
call plug#begin(stdpath('config') .. '/plugged')
Plug 'edluffy/hologram.nvim'
call plug#end()
lua require('hologram').setup({})
2. check `hologram.nvim` is loaded by `:PlugStatus`
3. run `require('hologram').add_image(0, '~/hologram-test/sample.png', 0, 0)`, then โ
E5108: Error executing lua [string ":lua"]:1: attempt to call field 'add_image' (a nil value) stack traceback: [string ":lua"]:1: in main chunk
The README document seems a little outdated (quite different from the main branch). Currently, the following code works for me.
function Test()
local Image = require('hologram.image')
local source = '/home/user/Pictures/unknown.png'
local img = Image:new(source, {})
local buf = vim.api.nvim_get_current_buf()
img:display(1, 1, buf, {})
end
BTW the autocmd of automatic displaying images in a markdown file is working correctly, just add the auto_display = true
option.
require('hologram').setup { auto_display = true }
You'll need to launch neovim in a terminal emulator like kitty, as the README mentioned that hologram.nvim only supports Kitty Graphics Protocol at present.
Thank you for detailed answer, but the code does not work for me... ๐ญ
In GIF above,
function HologramTest
is from @OmeletWithoutEgg 's answer, sample.png
is my icon):
call plug#begin(stdpath('config') .. '/plugged')
Plug 'edluffy/hologram.nvim'
call plug#end()
lua << EOF require('hologram').setup({auto_display = true}) function HologramTest() local Image = require('hologram.image') local source = vim.fn.expand('~/hologram-test/sample.png') local img = Image:new(source, {}) local buf = vim.api.nvim_get_current_buf() img:display(1, 1, buf, {}) end EOF
2. run `:lua HologramTest()` โ image is not displayed
3. open markdown file that contains `![img](./sample.png)` โ image is not displayed, cursor flickers after entered visual mode
I'm using:
โฏ kitty --version kitty 0.25.2 created by Kovid Goyal
โฏ nvim --version NVIM v0.8.0-dev-853-g9a3877ff9 Build type: Release LuaJIT 2.1.0-beta3 Compiled by kawarimidoll@kawarimidoll-mba
Features: +acl +iconv +tui See ":help feature-compile"
ใทในใใ vimrc: "$VIM/sysinit.vim"
็็ฅๆใฎ $VIM: "/opt/homebrew/Cellar/neovim/HEAD-9a3877f_1/share/nvim"
Run :checkhealth for more info
@OmeletWithoutEgg This is correct - after adding inline image display I must have forgotten to change the example in the README - I have updated the docs now.
@kawarimidoll If I am correct in thinking this is an issue with macOS (just tested using a mac now and it seems to be) then the latest commit should fix your problem.
@edluffy The latest example in README shows image but that is narrow than I expected.
source image is square โ
Image should be full size with latest commit now. Although there might still be some scaling issues when scrolling...
The problem is fixed, nice work ๐ฅฐ Thank you!
I tried examples in README, but they caused error and cannot process images.
example in Usage section,
require('hologram').add_image(0, img_path, 0, 0)
โE5108: Error executing lua [string ":lua"]:1: attempt to call field 'add_image' (a nil value)
example in image.lua API section,
require('hologram.image'):new({ source = img_path, row = 0, col = 0, })
โE5113: Error while calling lua chunk: ...config/nvim/plugged/hologram.nvim/lua/hologram/image.lua:32: Image source is not a valid string