aymericbeaumet / vim-symlink

:running: Automagically follow symlinks
MIT License
74 stars 10 forks source link

Error with Neovim 0.9 #14

Open cristobaltapia opened 1 year ago

cristobaltapia commented 1 year ago

Hi, this plugin has been working for me perfectly for some years (so much that I had forgotten I had it installed :) ). But I think that the latest version of neovim introduced a problem:

Error detected while processing BufReadPost Autocommands for "*":
Error executing lua callback: /usr/share/nvim/runtime/lua/editorconfig.lua:210: Invalid buffer id: 1                                                                                  
stack traceback:
        [C]: in function 'nvim_buf_get_name'
        /usr/share/nvim/runtime/lua/editorconfig.lua:210: in function 'config'
        /usr/share/nvim/runtime/plugin/editorconfig.lua:11: in function </usr/share/nvim/runtime/plugin/editorconfig.lua:4>

Do you think this is a problem with neovim or with vim-symlink? Do you think that this can be fixed easily? I tried today for a while, but I am not sure where the problem might be.

Jasha10 commented 1 year ago

The traceback points to runtime/lua/editorconfig.lua:210. That line of code looks like this:

  local path = vim.fs.normalize(vim.api.nvim_buf_get_name(bufnr))

The traceback gives the error message Invalid buffer id: 1. This makes me think that the function call vim.api.nvim_buf_get_name(bufnr) on that line of code is failing because bufnr == 1 is invalid.

Looking at the code of this vim-symlink plugin, I see that there is a call to Bwipeout or bwipeout:

...
  if exists(':Bwipeout') " vim-bbye
    silent! Bwipeout
  else
    if &diff
      echoerr "symlink.vim: 'moll/vim-bbye' is required in order for this plugin to properly work in diff mode"
      return
    endif
    enew
    bwipeout #
  endif
...

I suspect that the call to Bwipeout is causing bufnr == 1 to be invalid.

Jasha10 commented 1 year ago

After much experimenting, I've found a workaround: Changing the BufRead autocmd in vim-symlink into a BufEnter autocmd. So far I haven't noticed any negative side-effects from making this change. I'll submit a PR.

EDIT: I've submitted PR #16.

I'm still seeing some issues after changing to BufEnter

  autocmd BufEnter * nested call s:on_buf_read(expand('<afile>'))
  " Works for first file. Subsequent :edit ~/my_symlink gave error:
    " python3-rplugin-host: Async request caused an error:
    " Vim(sign):E158: Invalid buffer name: 4
    " python3-rplugin-host: Async request caused an error:
    " Invalid buffer id: 4
yut23 commented 1 year ago

An alternative workaround I've been using is to entirely disable Neovim's EditorConfig integration (see https://neovim.io/doc/user/editorconfig.html#editorconfig), since I use a separate EditorConfig plugin anyways for vim compatibility.