11# nvim-window-picker
22
3- https://user-images.githubusercontent.com/18459807/161597479-a3d8cf73-3dca-44b1-9eb6-d00b4e6eb842.mp4
3+ < https://user-images.githubusercontent.com/18459807/161597479-a3d8cf73-3dca-44b1-9eb6-d00b4e6eb842.mp4 >
44
5- This plugins prompts the user to pick a window and returns the window id of the picked window.
6- Part of the code is from [ nvim-tree] ( https://github.com/kyazdani42/nvim-tree.lua ) so shout out to
7- them for coming up with this idea.
5+ This plugins prompts the user to pick a window and returns the window id of the
6+ picked window. Part of the code is from
7+ [ nvim-tree] ( https://github.com/kyazdani42/nvim-tree.lua ) so shout out to them
8+ for coming up with this idea.
89
910## Install
1011
11- #### packer
12+ ### packer
1213
1314``` lua
1415use {
1516 ' s1n7ax/nvim-window-picker' ,
16- tag = ' v1 .*' ,
17+ tag = ' v2 .*' ,
1718 config = function ()
1819 require ' window-picker' .setup ()
1920 end ,
@@ -28,33 +29,45 @@ use {
2829local picked_window_id = require (' window-picker' ).pick_window ()
2930```
3031
31- ** You can put the picked window id to good use**
32+ You can put the picked window id to good use
3233
3334## Configuration
3435
3536If you want to have custom properties just for one time, you can pass any of
36- following directly to ` pick_window() ` function itself.
37+ following directly to ` pick_window() ` function itself to override the default
38+ behaviour.
3739
3840``` lua
3941require ' window-picker' .setup ({
40- -- when there is only one window available to pick from, use that window
41- -- without prompting the user to select
42- autoselect_one = true ,
43-
44- -- whether you want to include the window you are currently on to window
45- -- selection or not
46- include_current_win = false ,
47-
4842 -- when you go to window selection mode, status bar will show one of
4943 -- following letters on them so you can use that letter to select the window
5044 selection_chars = ' FJDKSLA;CMRUEIWOQP' ,
5145
46+ -- You can change the display string in status bar.
47+ -- It supports '%' printf style. Such as `return char .. ': %f'` to display
48+ -- buffer filepath. See :h 'stl' for details.
49+ selection_display = function (char , windowid )
50+ return ' %=' .. char .. ' %='
51+ end ,
52+
53+ -- whether you want to use winbar instead of the statusline
54+ -- "always" means to always use winbar,
55+ -- "never" means to never use winbar
56+ -- "smart" means to use winbar if cmdheight=0 and statusline if cmdheight > 0
57+ use_winbar = ' smart' , -- "always" | "never" | "smart"
58+
59+ -- whether to show 'Pick window:' prompt
60+ show_prompt = false ,
61+
62+ -- prompt message to show to get the user input
63+ prompt_message = ' Pick window: ' ,
64+
5265 -- if you want to manually filter out the windows, pass in a function that
53- -- takes two parameters. you should return window ids that should be
66+ -- takes two parameters. You should return window ids that should be
5467 -- included in the selection
5568 -- EX:-
5669 -- function(window_ids, filters)
57- -- -- filter the window_ids
70+ -- -- folder the window_ids
5871 -- -- return only the ones you want to include
5972 -- return {1000, 1001}
6073 -- end
@@ -64,12 +77,20 @@ require 'window-picker'.setup({
6477 -- defined by this plugin. if you pass in a function to "filter_func"
6578 -- property, you are on your own
6679 filter_rules = {
80+ -- when there is only one window available to pick from, use that window
81+ -- without prompting the user to select
82+ autoselect_one = true ,
83+
84+ -- whether you want to include the window you are currently on to window
85+ -- selection or not
86+ include_current_win = false ,
87+
6788 -- filter using buffer options
6889 bo = {
6990 -- if the file type is one of following, the window will be ignored
70- filetype = { ' NvimTree' , " neo-tree" , " notify" },
91+ filetype = { ' NvimTree' , ' neo-tree' , ' notify' },
7192
72- -- if the buffer type is one of following, the window will be ignored
93+ -- if the file type is one of following, the window will be ignored
7394 buftype = { ' terminal' },
7495 },
7596
@@ -85,6 +106,9 @@ require 'window-picker'.setup({
85106 file_name_contains = {},
86107 },
87108
109+ -- the foreground (text) color of the picker
110+ fg_color = ' #ededed' ,
111+
88112 -- if you have include_current_win == true, then current_win_hl_color will
89113 -- be highlighted using this background color
90114 current_win_hl_color = ' #e35e4f' ,
@@ -97,12 +121,21 @@ require 'window-picker'.setup({
97121
98122``` lua
99123require (package_name ).pick_window ({
100- include_current_win = true ,
101124 selection_chars = ' 123345' ,
102125 filter_rules = {
126+ include_current_win = true ,
103127 bo = {
104128 filetype = {' markdown' }
105129 }
106130 },
107131})
108132```
133+
134+ ## Breaking changes in v2.0.0
135+
136+ _ Before_ : return value from ` selection_display ` will be wrapped by ` '%=' ` and
137+ ` '%=' ` to fill the empty space of status line or winbar.
138+
139+ _ After_ : return value of ` selection_display ` will be passed directly to the
140+ status line or winbar. This allows all the customizations available from
141+ statusline syntax. You can check ` :help statusline ` for more info.
0 commit comments