s1n7ax / nvim-window-picker

This plugins prompts the user to pick a window and returns the window id of the picked window
MIT License
296 stars 26 forks source link

pick_window not showing picker #65

Closed KunaPrime closed 6 months ago

KunaPrime commented 11 months ago

NVIM v0.10.0-dev Build type: RelWithDebInfo LuaJIT 2.1.0-beta3

command: :lua print(require("window-picker").pick_window())

prints id of current window but choice of window is never shown

configured without any parameters

s1n7ax commented 11 months ago

I'm going to need more information. There could be situations where the hints will not be displayed. Please add info to recreate the issue as well as the configuration you are using

KunaPrime commented 11 months ago

so i'm just using

  use {
    's1n7ax/nvim-window-picker',
    tag = 'v2.*',
    config = function()
        require'window-picker'.setup()
    end,
    }

in packer

and i'm opening two files in v-split that's it. Please can you specify what other data can i provide to aid pinpointing a problem. It might very well be that i'm doing something wrong

KunaPrime commented 10 months ago

is there anything else i can try? or maybe do you have any suggestions how to provide you with more information?

enidisepic commented 10 months ago

The 'fix' is quite simple. By default pick_window returns the ID of the other window if you only have two after filtering. As soon as you have three or more windows which one you want to switch to isn't obvious anymore and it asks you to pick.

If you want it to always ask which window you'd like to pick you have to set filter_rules.autoselect_one = false.

A minimal configuration example for this would be:

require('window-picker').setup({
  filter_rules = {
    autoselect_one = false
  }
})

Answering here cause I had the same issue and just figured it out by trying around and taking a second look at the documentation.

KunaPrime commented 10 months ago

@enidisepic thank you for sharing your solution, as it is in right direction for sure. However it is now quite there for me yet. What i didn't realized that when picking windows you need to have at least 3 windows otherwise it will choose the other one. can you share your configuration as i cannot seem to get it working:

require 'window-picker'.setup({
    hint = 'statusline-winbar',
    filter_rules = {
        include_current_win = true,
        autoselect_one = false
    }
})

i would think that this would work but it desn't in my case

KunaPrime commented 10 months ago

@s1n7ax what are you using to execute lua code in demo videos? maybe that's why we have different results, i'm using command mode : without any pop-up window

s1n7ax commented 6 months ago

@KunaPrime With your configuration, if there are two windows, then the prompt should show up. However, following are the default filters. So, if one of your windows are one of them, then that's why you need more than two windows.

        bo = {
            -- if the file type is one of following, the window will be ignored
            filetype = { 'NvimTree', 'neo-tree', 'notify' },

            -- if the file type is one of following, the window will be ignored
            buftype = { 'terminal' },
        },
KunaPrime commented 6 months ago

@s1n7ax this is still not working for me and none of my windows are one of filters

s1n7ax commented 6 months ago

@KunaPrime Please add the steps to recreate

KunaPrime commented 6 months ago

@s1n7ax maybe i have not understand something here. So in the demo clips in this repo command print(require("window-picker").pick_window()) is run and then window hints are shown so one can choose which one to focus or whatever. So i have two windows in my nvim instance and then i run in command-line mode lua print(require("window-picker").pick_window()) which i assume should have same behavior as in demo clips but it does not. Instead hint are shown only when more than two windows are present and one window is always missing hints.

s1n7ax commented 6 months ago

This is what you should see with following configuration. If this isn't what you get, it's either some filter removing some windows or you are calling window-picker setup wrong.

return {
    's1n7ax/nvim-window-picker',
    opts = {
        hint = 'statusline-winbar',
        filter_rules = {
            include_current_win = true,
            autoselect_one = false,
        },
    },
    event = 'VeryLazy',
}

image

s1n7ax commented 6 months ago

You can remove every configuration related to window-picker (it's used in neo-tree if you have added it). Then just put the configuration I have added in the previous comment (assuming you are using lazynvim), then it should work.

KunaPrime commented 6 months ago

unfortunately this is not what i get. this is exact config that i'm using for packer:

  use {
    's1n7ax/nvim-window-picker',
    tag = 'v2.*',
    config = function()
        require'window-picker'.setup()
    end,
    }

i think this is the same as per docs.

s1n7ax commented 6 months ago

@KunaPrime You don't pass any configurations. What you get is the expected behavior. If you want to get the same behavior as of the demo, the use the configuration I have added in the previous comment. If it still doesn't work, you are probably setting it up somewhere else.