Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better support for relative path in bib and yaml modules #203

Open
life00 opened this issue Mar 10, 2024 · 0 comments
Open

Better support for relative path in bib and yaml modules #203

life00 opened this issue Mar 10, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@life00
Copy link

life00 commented Mar 10, 2024

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.

@jakewvincent jakewvincent added the enhancement New feature or request label Apr 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants