Better support for relative path in `bib` and `yaml` modules
life00 opened this issue · 0 comments
I know that it is strongly recommended to use absolute paths when specifying YAML or default bib path, but it doesn't really fit my workflow. Relative paths work out of the box for both of these as long as current working directory of neovim is right, however the problem is lack of additional checks that results in a lot of errors.
For example I use default_path
which I prefer as follows:
bib = {
default_path = "./references.bib",
},
It works flawlessly as long as my cwd has that file. If it doesn't then it will violently error every time I type a character. The same happens with YAML, if there is no such file then it will error. For both scenarios there is the same error.
Error detected while processing TextChangedI Autocommands for "*":
Error executing lua callback: ...er/etc/data/nvim/lazy/mkdnflow.nvim/lua/mkdnflow/cmp.lua:82: attempt to index local 'file' (a nil value)
stack traceback:
...er/etc/data/nvim/lazy/mkdnflow.nvim/lua/mkdnflow/cmp.lua:82: in function 'parse_bib'
...er/etc/data/nvim/lazy/mkdnflow.nvim/lua/mkdnflow/cmp.lua:117: 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>
I suggest to make an error check. If the file exists then create the autocmd, otherwise skip, notify user or be silent.