-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsnipewin.txt
222 lines (165 loc) · 8.89 KB
/
snipewin.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
*snipewin.txt* Manipulate windows most quickly like sniper
Author: Hibiki <mail@4513echo.dev>
License: MIT License
URL: https://github.com/4513ECHO/vim-snipewin
Last change: 2024 Feb 05
==============================================================================
CONTENTS *snipewin-contents*
Introduction |snipewin-introduction|
Interface |snipewin-interface|
Key Mappings |snipewin-key-mappings|
Functions |snipewin-functions|
Variables |snipewin-variables|
Callbacks |snipewin-callbacks|
Filters |snipewin-filters|
Lua Interface |snipewin-lua-interface|
Highlight Groups |snipewin-highlight-groups|
Compatibility |snipewin-compatibility|
About |snipewin-about|
==============================================================================
INTRODUCTION *snipewin-introduction*
*snipewin* ( *vim-snipewin* ) is a plugin to provide interactive |window|
selector. The selector can be used to manipulate anything about window
through |snipewin-callbacks|.
The main idea is inspired by tmux's `display-panes` feature, vim-|choosewin|
and chowcho.nvim.
https://github.com/t9md/vim-choosewin
https://github.com/tkmpypy/chowcho.nvim
Vim v9.0.0000+ or Neovim v0.8.0+ is required.
==============================================================================
INTERFACE *snipewin-interface*
------------------------------------------------------------------------------
KEY MAPPINGS *snipewin-key-mappings*
<Plug>(snipewin) *<Plug>(snipewin)*
The mapping version of |snipewin#select()|.
Example: >
nnoremap <C-w>W <Plug>(snipewin)
------------------------------------------------------------------------------
FUNCTIONS *snipewin-functions*
snipewin#select([{callback}]) *snipewin#select()*
Start selecting windows.
{callback} is optional |Funcref| that called after confirm selecting.
See |snipewin-callbacks| for details.
Return a result of {callback} if it called, otherwise return |v:null|.
If your Vim/Neovim supports mouse, selecting by click is enabled.
NOTE: If typed charactor is lower case alphabet, treated as upper case.
NOTE: If typed charactor is invalid, Selecting is canceled and
callback is not called.
------------------------------------------------------------------------------
VARIABLES *snipewin-variables*
g:snipewin_filters *g:snipewin_filters*
|List| of |Funcref| (default: `[]`)
Filters to judge whether a window should not be labeled.
Each function recieves |window-ID| and return |Boolean|.
Only windows that pass all filter functions are labeled.
Example to ignore current window: >
let g:snipewin_filters = [{ winid -> winid !=# win_getid() }]
<
See |snipewin-filters| for builtin filters.
g:snipewin_ignore_single *g:snipewin_ignore_single*
|Boolean| (default: |v:false|)
If |v:true| cancel selecting immediately when only one window exists.
g:snipewin_label_chars *g:snipewin_label_chars*
|String| (default: "ABCDEFGHIJKLMNOPQRSTUVWXYZ")
The set of charactors used for label, used from the head.
Only upper case alphabets are acceptable.
WARNING: If the number of windows overflows the length of this
variable, You cannot select the rest of windows without mouse.
g:snipewin_label_font *g:snipewin_label_font*
|String| (default: "asciian")
The font used for label. "asciian", "asciian_inverted" are available.
g:snipewin_label_pixel *g:snipewin_label_pixel*
|String| (default: "#")
The single charactor used for pixel of the label.
g:snipewin_override_winopts *g:snipewin_override_winopts*
|Dictionary| (default: `{}`)
Override configs of label window, such as border or zindex.
See |popup_create-arguments| in Vim or |nvim_open_win()| in Neovim for
specifically option names.
------------------------------------------------------------------------------
CALLBACKS *snipewin-callbacks*
Callback of |snipewin#select()| is a |Funcref| that recieves |window-ID| of
selected window.
Callback is always called in the current window.
If {callback} is ommited, |g:snipewin#callback#default| is used.
Example: >
" Pass through winid
call snipewin#select({ winid -> winid })
" Use 'only' callback
call snipewin#select({ winid -> snipewin#callback#only(winid) })
BUILTIN CALLBACKS~
Following builtin callbacks are available.
g:snipewin#callback#default *g:snipewin#callback#default*
Default callback of |snipewin#select()| and you can define this. It is
alias of |snipewin#callback#goto()| by default.
snipewin#callback#close() *snipewin#callback#close()*
Execute |:close| in target window.
snipewin#callback#hide() *snipewin#callback#hide()*
Execute |:hide| in target window.
snipewin#callback#goto() *snipewin#callback#goto()*
Go to target window.
snipewin#callback#only() *snipewin#callback#only()*
Execute |:only| in target window.
snipewin#callback#swap() *snipewin#callback#swap()*
Swap displayed buffers between current window and target window.
It may fallback to |CTRL-W_x| if possible.
WARNING: Unlike |CTRL-W_x|, this callback does not actually exchange
the windows. This means that window-local options (|global-local|)
will not be inheritd correctly.
------------------------------------------------------------------------------
FILTERS *snipewin-filters*
BUILTIN FILTERS~
Following builtin filters are available.
snipewin#filter#filetype() *snipewin#filter#filetype()*
Higher-order function that recieves a list of filtypes to ignore.
Example: >
" Ignore famous fuzzy finder plugins.
let g:snipewin_filters = [
\ g:snipewin#filter#filetype(['fzf', 'ctrlp', 'ddu-ff']),
\ ]
snipewin#filter#floatwin() *snipewin#filter#floatwin()*
Filter to ignore Neovim's floating window (|api-floatwin|).
------------------------------------------------------------------------------
LUA INTERFACE *snipewin-lua-interface*
NOTE: This feature is only available in Neovim.
Unlike |vim.fn|, Funcref through |lua-vim-variables| is not converted to lua
function but |vim.NIL|. This is a serious problem for snipewin when accessing
callbacks and filters. The following features provide a proxy to work around
these problems.
snipewin.select([{callback}]) *snipewin.select()*
The wrapper function for |snipewin#select()|.
It almost same as it, but return `nil` when {callback} is not called.
snipewin.callback.{name} *snipewin.callback*
The proxy table for builtin callbacks (|snipewin-callbacks|).
For example, `callback.goto` is same as |snipewin#callback#goto()|.
snipewin.filter.{name} *snipewin.filter*
The proxy table for builtin filters (|snipewin-filters|).
For example, `filter.floatwin` is same as |snipewin#filter#floatwin()|.
Example: >
local snipewin = require "snipewin"
vim.g.snipewin_filters = {
snipewin.filter.filetype { "fzf", "ctrlp", "ddu-ff" },
snipewin.filter.floatwin,
}
snipewin.select(snipewin.callback.close)
------------------------------------------------------------------------------
HIGHLIGHT GROUPS *snipewin-highlight-groups*
SnipeWinLabel *hl-SnipeWinLabel*
The highlight group used for label of |snipewin#select()|.
It is linked to `Label` (see |group-name|) in default.
==============================================================================
COMPATIBILITY *snipewin-compatibility*
There is a list of breaking changes of the plugin.
2024-02-05~
(`34dfbe36f1680e3ad4c0df12fbc7555032a56f83`)
- Builtin |snipewin-callbacks| and |snipewin-filters| are no longer |Funcref|.
2023-08-31~
(`bfd162ea2e6d556b02ad3cb18a95f03efd38caeb`)
- Invert the meaning of |snipewin-filters| return value.
==============================================================================
ABOUT *snipewin-about*
|snipewin| is developed by Hibiki(4513ECHO) and licensed under the MIT
License. Visit the project page for the latest version:
https://github.com/4513ECHO/vim-snipewin
==============================================================================
vim:tw=78:ts=8:ft=help:norl:noet:fen: