matbme / JABS.nvim

Just Another Buffer Switcher for Neovim
GNU General Public License v3.0
282 stars 10 forks source link

Error on open #14

Open dkirchhof opened 3 years ago

dkirchhof commented 3 years ago

Hello, i wanted to try out this plugin but it behaves very strangely.

  1. open neovim without arguments - it opens a readonly scratchpad (my custom dashboard). :ls will show nothing 1.1. execute :JABSOpen 1.1 error in jabs.lua:141: attempt to index local 'linenr' (a nil value)

  2. open three buffers via :e ... 1.1. execute :JABSOpen 1.1 error in jabs.lua:130: attempt to concatenate local 's' (a table value)

  3. open two buffers via :e ... 1.1. execute :JABSOpen 1.1. no error

At some point, i got an error in jabs.lua: 186: Invalid window id after reopening it. At some point, i also got an error after opening buffers via TeleScope...

Versions:

matbme commented 3 years ago

Hello!

The second issue should be fixed now, I let this bug slide when I changed the parsing logic a while back.

I have an idea on what may be causing the first problem, but to be sure could you please send the output of :ls?

dkirchhof commented 3 years ago

Okay, for the first Issue i just start neovim. Here is the output (ls / ls!):

:ls 
:ls!                                                                                                                                       
  1u%a-  "[Scratch]"                    line 1     
matbme commented 3 years ago

Is your custom dashboard a popup? The first issue should be fixed now. If it's ok, could you share how you create the scratchpad on startup so I can check if there are any other bugs when opening JABS with no listed buffers?

dkirchhof commented 3 years ago

Sure. Here is the code:

function startup()
    local firstParam = vim.fn.argv()[1]
    local isDirectory = vim.fn.isdirectory(firstParam) == 1

    if (firstParam == nil or isDirectory) then
        vim.api.nvim_buf_set_lines(0, 0, -1, false, "...")

        -- ...

        vim.cmd('setlocal filetype=dashboard')
        vim.cmd('setlocal bufhidden=wipe')
        vim.cmd('setlocal buftype=nofile')
        vim.cmd('setlocal nobuflisted') 
        vim.cmd('setlocal nomodifiable') 
        vim.cmd('setlocal nocursorcolumn') 
        vim.cmd('setlocal nocursorline') 
        vim.cmd('setlocal nonumber') 
        vim.cmd('setlocal norelativenumber')

        -- ...
    end
end

create_augroup('STARTUP', {
    'VimEnter * :cd %:p:h',
    'VimEnter * :lua startup()',
})