chomosuke / typst-preview.nvim

Low latency typst preview for Neovim
GNU General Public License v3.0
254 stars 16 forks source link

the first buffer autocommands not registered #12

Closed m4cey closed 8 months ago

m4cey commented 9 months ago

when starting a new neovim instance on a typst filetype, the buffer autocmds aren't created for that file. but the next time I open a file in that same neovim instance, things work as expected. however the first buffer is still without autocmds. I can manually refresh things with :set filetype=typst as a workaround.

I was able to reproduce this on a clean configuration with lazy.nvim and no other plugins.

m4cey commented 8 months ago

update: I noticed this only happens when the call to setup happens outside of lazy.nvim's plugin declaration like this:

require 'lazy'.setup({
    {
        'chomosuke/typst-preview.nvim',
        ft = 'typst',
        version = '0.1.*',
        build = function() require 'typst-preview'.update() end,
    },
})

require 'typst-preview'.setup {
    debug = false,
    get_root = function(_)
        return vim.fn.getcwd()
    end,
}

if I don't call setup outside or use opts to pass options or config = function(), everything works fine; which is probably all anyone needs