jakewvincent / mkdnflow.nvim

Fluent navigation and management of markdown notebooks
GNU General Public License v3.0
684 stars 41 forks source link

Error handling if no bibliography entry specified in YAML #204

Closed life00 closed 5 months ago

life00 commented 6 months ago

I have yaml module enabled. It will try to get the bibliography path only if the YAML block is present. If it finds it then everything is fine and it works, but if the YAML block doesn't have the bibliography entry it would constantly error whenever I type any character:

Error detected while processing TextChangedI Autocommands for "*":
Error executing lua callback: ...er/etc/data/nvim/lazy/mkdnflow.nvim/lua/mkdnflow/cmp.lua:128: bad argument #1 to 'pairs' (table expected, got nil)
stack traceback:
    [C]: in function 'pairs'
    ...er/etc/data/nvim/lazy/mkdnflow.nvim/lua/mkdnflow/cmp.lua:128: in function 'complete'
    /home/user/etc/data/nvim/lazy/nvim-cmp/lua/cmp/source.lua:326: in function 'complete'
    /home/user/etc/data/nvim/lazy/nvim-cmp/lua/cmp/core.lua:299: in function 'complete'
    /home/user/etc/data/nvim/lazy/nvim-cmp/lua/cmp/core.lua:169: in function 'callback'
    /home/user/etc/data/nvim/lazy/nvim-cmp/lua/cmp/core.lua:229: in function 'autoindent'
    /home/user/etc/data/nvim/lazy/nvim-cmp/lua/cmp/core.lua:161: in function 'on_change'
    /home/user/etc/data/nvim/lazy/nvim-cmp/lua/cmp/init.lua:338: in function 'callback'
    ...er/etc/data/nvim/lazy/nvim-cmp/lua/cmp/utils/autocmd.lua:49: in function 'emit'
    ...er/etc/data/nvim/lazy/nvim-cmp/lua/cmp/utils/autocmd.lua:23: in function <...er/etc/data/nvim/lazy/nvim-cmp/lua/cmp/utils/autocmd.lua:22>

This should not be the right behavior as YAML block may be used for other purposes while not having any bibliography. I suggest implementing an error check that will ensure that autocmd is created only if the correct YAML entry is present.

jakewvincent commented 5 months ago

@life00, thanks for the bug report. This should now be fixed in the latest update. Let me know if the error still occurs for you after updating the plugin.