nyngwang / NeoZoom.lua

A simple usecase of floating window to help you focus.
MIT License
184 stars 15 forks source link

Bug in combination with quickfix windows. #4

Closed zbindenren closed 2 years ago

zbindenren commented 2 years ago

I use <cr> to Toogle zoom. If I press enter in quickfix window to go to the corresponding location, I get the following error:

E5108: Error executing lua ...nvim/site/pack/packer/start/NeoZoom.lua/lua/neo-zoom.lua:25: Vim(tabedit):E499: Empty file name for '%' or '#', only works with ":p:h": tabedit %:p                                                                                                             
stack traceback:                                                                                                                                                                                                                                                                              
        [C]: in function 'cmd'                                                                                                                                                                                                                                                                
        ...nvim/site/pack/packer/start/NeoZoom.lua/lua/neo-zoom.lua:25: in function 'maximize_current_split'                                                                                                                                                                                  
        [string ":lua"]:1: in main chunk
nyngwang commented 2 years ago

Thanks for the report. Let me fix this now, wait some minutes~

nyngwang commented 2 years ago

It should be fixed now~

While I didn't test the case that when an item indeed gets selected(, since I don't know how to use quickfix list...). But with an empty quickfix list and pressing <cr> I got no error after the newest update. You might try it and let me know the result :)

zbindenren commented 2 years ago

Now there is no error, but if I hit enter to go to the corresponding instance, nothing happens anymore. So Quickfix window is not working anymore.

nyngwang commented 2 years ago

@zbindenren: As a temporary solution could you try the following alternative as the triggering command in your .lua file? (If you're using init.vim then please let me know, I will turn the following into a complete vimscript)

vim.api.nvim_set_keymap('n', '<CR>', "&ft != 'qf' ? 'NeoZoomToggle' : '<CR>'", { expr = true, noremap = true, silent = true, nowait = true })

My intuition is that this would be better done on the client-side(i.e. you decide when to use <cr> or NeoZoomToggle), or I will have to update this every time a new filetype is created. But don't worry, I also added a todo for this issue in the README.md that planning to provide an exclude option. (I will spend some time to reference other plugins)


I think this one would work, since now when I press <cr> in the list it shows me an error that is expected to appear when pressing <cr> on empty:

E42: No Errors
zbindenren commented 2 years ago

Of course I have a lua config :smile: . Your suggestion did almost work, but with the following it seems to work:

keymap(
    "n",
    "<cr>",
    "&ft != 'qf' ? '<cmd> NeoZoomToggle <cr>' : '<cr>'",
    { expr = true, noremap = true, silent = true, nowait = true }
)

see the <cmd> before NeoZoomToggle and the <cr> after.

I think it is enough to solve it on client side and document it in the Readme.

nyngwang commented 2 years ago

@zbindenren: Lol, you're right, when using expr some prefix/postfix should be added.(Sorry I was busy on some other things, so a hash debugging) And I'm happy that you resolved it yourself! Thanks for your issue, let me fix the Readme now with your script :)