-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathrnvimr.txt
431 lines (333 loc) · 16.2 KB
/
rnvimr.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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
*rnvimr.txt*
Version: 0.4.0
Author : kevinhwang <https://github.com/kevinhwang91>
License: BSD3
================================================================================
CONTENTS *rnvimr-contents*
Introduction |rnvimr-introduction|
Requirements |rnvimr-requirement|
Features |rnvimr-features|
CheckHealth |rnvimr-checkhealth|
Usage |rnvimr-usage|
Variables |rnvimr-variables|
Hightights |rnvimr-highlights|
Commands |rnvimr-commands|
Examples |rnvimr-config-examples|
================================================================================
INTRODUCTION *rnvimr-introduction*
*Rnvimr* is a Neovim plugin that allows you to use Ranger in a floating window.
Different than other Ranger vim-plugins, Rnvimr gives you full control over
Ranger. It uses RPC to communicate with Ranger.
Since Rnvimr requires RPC, this plugin does not support vim for now.
================================================================================
REQUIREMENTS *rnvimr-requirements*
1. *Ranger* (https://github.com/ranger/ranger)
2. *Pynvim* (https://github.com/neovim/pynvim)
3. Python3.6
4. *Ueberzug* (https://github.com/seebye/ueberzug) (optional)
================================================================================
FEATURES *rnvimr-features*
- Replace the built-in Netrw as a default file explorer
- Calibrated preview images for ueberzug
- Attach file automatically when toggling Ranger
- Adjust floating window size automatically after resizing NeoVim
- Adjust view automatically to adapt the size of floating window
- Fully customizable layouts for floating window
- Better experience for Pager view in Ranger
- Wipe out the buffers corresponding to the files deleted by Ranger automatically
- Enhanced border in Ranger
- Synchronize the current working directory of Neovim and Ranger
- Hide the files included in gitignore
- Save Buffer information when the src files are moved from Ranger
================================================================================
CHECKHEALTH *rnvimr-checkhealth*
Run |:checkhealth| |rnvimr|, If everything is OK, it will output like these:
>
health#rnvimr#check
========================================================================
## OS
- OK: Name: Linux
## Ranger
- OK: Version: ranger-master
## Python
- OK: Version: 3.8.3 (default, May 17 2020, 18:15:42) [GCC 10.1.0]
## Pynvim
- OK: Version: 0.4.1
## Ueberzug (optional)
- OK: Ueberzug is ready
## RPC
- OK: RPC echo: Neovim send "Give me five!" and receive "Give me five!"
<
================================================================================
USAGE *rnvimr-usage*
Using |:RnvimrToggle| to create a Ranger process, and if one exists,
|:RnvimrToggle| simply shows or hides the floating window.
Using |:RnvimrResize| to cycle the preset layouts.
Pressing `Enter` to open a file in Ranger.
Rnvimr also supports `CTRL-T`/`CTRL-X`/`CTRL-V` key bindings that allow you to
open up a file in a new tab, a new horizontal split, or in a new vertical split.
Pressing `q` in Ranger simply hides the floating window.
Ranger will attach the file of the current buffer in the next toggle event.
Pressing `yw` in Ranger will emit Ranger's cwd to Neovim's,
`gw` will jump to Neovim's cwd.
================================================================================
VARIABLES *rnvimr-variables*
*g:rnvimr_layout*
g:rnvimr_layout
Default: {dict}
>
{ 'relative': 'editor',
\ 'width': float2nr(round(0.6 * &columns)),
\ 'height': float2nr(round(0.6 * &lines)),
\ 'col': float2nr(round(0.2 * &columns)),
\ 'row': float2nr(round(0.2 * &lines)),
\ 'style': 'minimal' }
<
The dict is a parameter of *nvim_open_win* api named {config}.
*g:rnvimr_presets*
g:rnvimr_presets
Default: {list}
>
[ {},
\ {'width': 0.700, 'height': 0.700},
\ {'width': 0.800, 'height': 0.800},
\ {'width': 0.950, 'height': 0.950} ]
<
The element of list is {dict}, represents the layout of floating window.
If the type of values of 'width', 'height', 'col', 'row' are {number}, the
values are the final result of the layout, such as `{'width': 10}`, the
width of floating window is 10.
If the type of values of 'width', 'height', 'col', 'row' are {float}, the
values must be {0.0-1.0}. It represents the proportion of the columns or
lines of NeoVim.
The values of 'width' and 'col' are the proportion of |&columns|.
The values of 'height' and 'row' are the proportion of |&lines|.
If 'col' is missing but dict contains 'width' k&v, 'col' will be calculated
by format `float2nr(round((&columns - width) / 2))`, 'row' is similar to
'col'.
If the other k&v are missing, it will extend from the |g:rnvimr_layout|.
If the element is an empty dict '{}', it represents the initial element of
|g:rnvimr_presets| while running |:RnvimrToggle|.
*g:rnvimr_action*
g:rnvimr_action
Default: {dict}
>
{
'<C-t>': 'NvimEdit tabedit',
'<C-x>': 'NvimEdit split',
'<C-v>': 'NvimEdit vsplit',
'<C-o>': 'NvimEdit drop',
'gw': 'JumpNvimCwd',
'yw': 'EmitRangerCwd'
}
<
|NvimEdit| : Use Neovim's command to edit the selected file in Ranger.
'edit', 'split', 'vsplit', 'drop' and 'tabedit' are commands of Neovim.
`NvimEdit split true/false`: if the last argument of the action is 'true'
or 'false' that will override |g:rnvimr_enable_picker| variable to split
the file, 'edit', 'vsplit', 'drop' and 'tabedit' are similar to 'split'.
|JumpNvimCwd| : Change Ranger's cwd to Neovim's.
|EmitRangerCwd| : Change Neovim's cwd to Ranger's.
Disable it by using empty dict. The keymap should follow Ranger's format.
*g:rnvimr_edit_cmd*
g:rnvimr_edit_cmd
Default: 'edit'
Replace Ranger's default '$EDITOR' candidate with this command to open the
selected file in Ranger.
'edit', 'split', 'vsplit', 'drop' and 'tabedit' are commands of Neovim.
*g:rnvimr_enable_ex*
g:rnvimr_enable_ex
Default: 0
Enable Ranger to replace builtin Netrw to be a file explorer.
*g:rnvimr_enable_picker*
g:rnvimr_enable_picker
Default: 0
Enable Ranger to be hidden after picking a file.
It will automatically attach a file in next |:RnvimrToggle|.
*g:rnvimr_enable_bw*
g:rnvimr_enable_bw
Default: 0
Make Neovim automatically execute |bwipeout| to wipe out the buffers deleted
by Ranger.
*g:rnvimr_shadow_winblend*
g:rnvimr_shadow_winblend
Default: 100
When value is inside [0, 100) will pass its value to |winblend| as an
window option for a new floating window as shadow.
*g:rnvimr_hide_gitignore*
g:rnvimr_hide_gitignore
Default: 0
Make Ranger to hide the files included in gitignore when show_hidden=False
in Ranger.
*g:rnvimr_draw_border*
g:rnvimr_draw_border
Default: 1
Using builtin curses in Ranger to draw a border for the floating window.
The border is only drawn in curses environment, so leaving curses
environment such as entering $SHELL in Ranger doesn't draw a border no mater
what the value of |g:rnvimr_draw_border| is.
*g:rnvimr_border_attr*
g:rnvimr_border_attr
Default: {dict}
>
{'fg': -1, 'bg': -1}
<
Built-in curses attributes, the range of integer value is [-1, 255]. It maps
the Neovim's terminal color. -1 means the default color attribute of curses
in Ranger.
*g:rnvimr_ranger_cmd*
g:rnvimr_ranger_cmd
Default: {list}
>
['ranger']
<
Use this command to run a process inside the floating window.
It can mix some command of Ranger, such as ['ranger', '--cmd=xxx'].
*g:rnvimr_ranger_views*
g:rnvimr_ranger_views
Default: {null}
Views for Ranger to adapt the size of floating window.
This variable is a list, whose element is {dict}, using 'minwidth',
'maxwidth' and 'ratio' as keys.
The type of values of 'minwidth' , 'maxwidth' are {number}, and 'ratio's
type of value is {list} whose format is `columns_ratios` in Ranger.
'ratio' is used for new view when 'width' of floating window running Ranger
is between 'minwidth' and 'maxwidth'.
If 'minwidth' is ignored, `0` is the default value.
If 'maxwidth' is ignored, `1023` is the default value.
`[]` and ignored in 'ratio' represent initial `columns_ratios` in Ranger.
If length of 'ratio' is `1`, using 'multipane' for new viewmode in Ranger,
its value is meaningless.
If length of 'ratio' is more than `1`, using 'miller' for new viewmode in
Ranger, and then assign its value to `columns_ratios`.
*g:rnvimr_vanilla*
g:rnvimr_vanilla
Default: 0
Disable Rnvimr to import user configuration.
*g:rnvimr_urc_path*
g:rnvimr_urc_path
Default: Default path of Ranger's configuration, depend on *$HOME* and
*$XDG_CONFIG_HOME* environment.
No need to set this option while using default configuration and path.
If you want to extend the plugin of Rnvimr, you will set this variable to
isolate the configuration of Ranger and Rnvimr.
================================================================================
HIGHLIGHTS *rnvimr-highlights*
Here is the default link for highlight groups of Rnvimr.
>
highlight default link RnvimrNormal NormalFloat
highlight default link RnvimrCurses Normal
<
RnvimrNormal is a highlight for the floating window in Rnvimr.
RnvimrCurses will overrule RnvimrNormal for highlight in curses environment
when Rnvimr enables |g:rnvimr_draw_border| to draw a border.
================================================================================
COMMANDS *rnvimr-commands*
*:RnvimrToggle*
:RnvimrToggle
Toggle the Ranger floating window. Reopen Ranger and attach a file
automatically after executing Ranger's command |quit| with only 1 tab.
If run |quit| inside Ranger, Ranger is hidden by closing the floating window
instead of exiting process. You can run |quit!| or |quitall| command to exit
Ranger process.
*:RnvimrResize*
:RnvimrResize {args}
Resize floating window by preset layouts. If {args} is empty, it will
circularly iterate the total |g:rnvimr_presets|. If {args} is single index
or multiple indexes separate by {,} such as {4,2,1,3}, it will circularly
iterate special elements of |g:rnvimr_presets| in order via index.
:RnvimrStartBackground
Start Ranger in the background. The time of first toggling the Ranger
floating window will be greatly improved after called this command.
================================================================================
EXAMPLES *rnvimr-config-examples*
Minimal configuration:
>
Plug 'kevinhwang91/rnvimr'
tnoremap <silent> <M-i> <C-\><C-n>:RnvimrResize<CR>
nnoremap <silent> <M-o> :RnvimrToggle<CR>
tnoremap <silent> <M-o> <C-\><C-n>:RnvimrToggle<CR>
<
Advanced configuration:
>
Plug 'kevinhwang91/rnvimr'
" Make Ranger replace netrw to be a file explorer
let g:rnvimr_enable_ex = 1
" Make Ranger to be hidden after picking a file
let g:rnvimr_enable_picker = 1
" Disable a border for floating window
let g:rnvimr_draw_border = 0
" Hide the files included in gitignore
let g:rnvimr_hide_gitignore = 1
" Change the border's color
let g:rnvimr_border_attr = {'fg': 14, 'bg': -1}
" Make Neovim wipe the buffers corresponding to the files deleted by Ranger
let g:rnvimr_enable_bw = 1
" Add a shadow window, value is equal to 100 will disable shadow
let g:rnvimr_shadow_winblend = 70
" Draw border with both
let g:rnvimr_ranger_cmd = ['ranger', '--cmd=set draw_borders both']
" Link CursorLine into RnvimrNormal highlight in the Floating window
highlight link RnvimrNormal CursorLine
nnoremap <silent> <M-o> :RnvimrToggle<CR>
tnoremap <silent> <M-o> <C-\><C-n>:RnvimrToggle<CR>
" Resize floating window by all preset layouts
tnoremap <silent> <M-i> <C-\><C-n>:RnvimrResize<CR>
" Resize floating window by special preset layouts
tnoremap <silent> <M-l> <C-\><C-n>:RnvimrResize 1,8,9,11,5<CR>
" Resize floating window by single preset layout
tnoremap <silent> <M-y> <C-\><C-n>:RnvimrResize 6<CR>
" Map Rnvimr action
let g:rnvimr_action = {
\ '<C-t>': 'NvimEdit tabedit',
\ '<C-x>': 'NvimEdit split',
\ '<C-v>': 'NvimEdit vsplit',
\ 'gw': 'JumpNvimCwd',
\ 'yw': 'EmitRangerCwd'
\ }
" Add views for Ranger to adapt the size of floating window
let g:rnvimr_ranger_views = [
\ {'minwidth': 90, 'ratio': []},
\ {'minwidth': 50, 'maxwidth': 89, 'ratio': [1,1]},
\ {'maxwidth': 49, 'ratio': [1]}
\ ]
" Customize initial layout
let g:rnvimr_layout = {
\ 'relative': 'editor',
\ 'width': float2nr(round(0.7 * &columns)),
\ 'height': float2nr(round(0.7 * &lines)),
\ 'col': float2nr(round(0.15 * &columns)),
\ 'row': float2nr(round(0.15 * &lines)),
\ 'style': 'minimal'
\ }
" Customize multiple preset layouts
" '{}' represents initial layout
let g:rnvimr_presets = [
\ {'width': 0.600, 'height': 0.600},
\ {},
\ {'width': 0.800, 'height': 0.800},
\ {'width': 0.950, 'height': 0.950},
\ {'width': 0.500, 'height': 0.500, 'col': 0, 'row': 0},
\ {'width': 0.500, 'height': 0.500, 'col': 0, 'row': 0.5},
\ {'width': 0.500, 'height': 0.500, 'col': 0.5, 'row': 0},
\ {'width': 0.500, 'height': 0.500, 'col': 0.5, 'row': 0.5},
\ {'width': 0.500, 'height': 1.000, 'col': 0, 'row': 0},
\ {'width': 0.500, 'height': 1.000, 'col': 0.5, 'row': 0},
\ {'width': 1.000, 'height': 0.500, 'col': 0, 'row': 0},
\ {'width': 1.000, 'height': 0.500, 'col': 0, 'row': 0.5}
\ ]
" Fullscreen for initial layout
" let g:rnvimr_layout = {
" \ 'relative': 'editor',
" \ 'width': &columns,
" \ 'height': &lines - 2,
" \ 'col': 0,
" \ 'row': 0,
" \ 'style': 'minimal'
" \ }
"
" Only use initial preset layout
" let g:rnvimr_presets = [{}]
<
================================================================================
vim:tw=80:ft=help