/
glance.txt
250 lines (195 loc) · 7.51 KB
/
glance.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
*glance.txt* For NVIM v0.5.0 Last change: 2022 November 29
==============================================================================
Table of Contents *glance-table-of-contents*
1. Glance |glance-glance|
- Requirements |glance-requirements|
- Install |glance-install|
- Configuration |glance-configuration|
- Hooks |glance-hooks|
- Usage |glance-usage|
- Highlights |glance-highlights|
- Alternatives |glance-alternatives|
==============================================================================
1. Glance *glance-glance*
A pretty window for previewing, navigating and editing your LSP locations in
one place, inspired by vscode’s peek preview.
<div class="figure">
<img src="https://i.imgur.com/86K5ljv.png" title="fig:"/>
<p class="caption">Glance references screenshot</p>
</div>
REQUIREMENTS *glance-requirements*
- Properly configured LSP client
- Neovim >= 0.7.0
INSTALL *glance-install*
Install the plugin with your preferred plugin manager.
VIM PLUG ~
>
Plug 'dnlhc/glance.nvim'
<
PACKER ~
>
use({
"dnlhc/glance.nvim",
config = function()
require('glance').setup({
-- your configuration
})
end,
})
<
CONFIGURATION *glance-configuration*
The following is the default configuration:
>
-- Lua configuration
local glance = require('glance')
local actions = glance.actions
glance.setup({
height = 18, -- Height of the window
zindex = 45,
border = {
enable = false, -- Show window borders. Only horizontal borders allowed
top_char = '―',
bottom_char = '―',
},
list = {
position = 'right', -- Position of the list window 'left'|'right'
width = 0.33, -- 33% width relative to the active window, min 0.1, max 0.5
},
theme = { -- This feature might not work properly in nvim-0.7.2
enable = true, -- Will generate colors for the plugin based on your current colorscheme
mode = 'auto', -- 'brighten'|'darken'|'auto', 'auto' will set mode based on the brightness of your colorscheme
},
mappings = {
list = {
['j'] = actions.next, -- Bring the cursor to the next item in the list
['k'] = actions.previous, -- Bring the cursor to the previous item in the list
['<Down>'] = actions.next,
['<Up>'] = actions.previous,
['<Tab>'] = actions.next_location, -- Bring the cursor to the next location skipping groups in the list
['<S-Tab>'] = actions.previous_location, -- Bring the cursor to the previous location skipping groups in the list
['<C-u>'] = actions.preview_scroll_win(5),
['<C-d>'] = actions.preview_scroll_win(-5),
['v'] = actions.jump_vsplit,
['s'] = actions.jump_split,
['t'] = actions.jump_tab,
['<CR>'] = actions.jump,
['o'] = actions.jump,
['<leader>l'] = actions.enter_win('preview'), -- Focus preview window
['q'] = actions.close,
['Q'] = actions.close,
['<Esc>'] = actions.close,
-- ['<Esc>'] = false -- disable a mapping
},
preview = {
['Q'] = actions.close,
['<Tab>'] = actions.next_location,
['<S-Tab>'] = actions.previous_location,
['<leader>l'] = actions.enter_win('list'), -- Focus list window
},
},
hooks = {},
folds = {
fold_closed = '',
fold_open = '',
folded = true, -- Automatically fold list on startup
},
indent_lines = {
enable = true,
icon = '│',
},
winbar = {
enable = true, -- Available strating from nvim-0.8+
},
})
<
HOOKS *glance-hooks*
BEFORE_OPEN ~
Runs after getting the results and before opening the window. Can be used to
alter the default opening behavior or to modify the results like filter out the
unwanted locations
**Important**: This is a blocking hook which means glance will not open unless
you call the `open` callback.
Examples:
Don’t open glance when there is only one result but jump directly to that
location instead
>
hooks = {
before_open = function(results, open, jump, method)
if #results == 1 then
jump(results[1]) -- argument is optional
else
open(results) -- argument is optional
end
end,
}
<
Don’t open glance when there is one result and it is located in the current
buffer, open otherwise
>
hooks = {
before_open = function(results, open, jump, method)
local uri = vim.uri_from_bufnr(0)
if #results == 1 then
local target_uri = results[1].uri or results[1].targetUri
if target_uri == uri then
jump(results[1])
else
open(results)
end
else
open(results)
end
end,
}
<
USAGE *glance-usage*
COMMANDS ~
- `:Glance references` show references of the word under the cursor from the LSP server
- `:Glance definitions` show definitions of the word under the cursor from the LSP server
- `:Glance type_definitions` show type definitions of the word under the cursor from the LSP server
- `:Glance implementations` show implementations of the word under the cursor from the LSP server
EXAMPLE KEYBINDINGS ~
>
" VimScript
nnoremap gR <CMD>Glance references<CR>
nnoremap gD <CMD>Glance definitions<CR>
nnoremap gY <CMD>Glance type_definitions<CR>
nnoremap gM <CMD>Glance implementations<CR>
<
>
-- Lua
vim.keymap.set('n', 'gD', '<CMD>Glance definitions<CR>')
vim.keymap.set('n', 'gR', '<CMD>Glance references<CR>')
vim.keymap.set('n', 'gY', '<CMD>Glance type_definitions<CR>')
vim.keymap.set('n', 'gM', '<CMD>Glance implementations<CR>')
<
HIGHLIGHTS *glance-highlights*
The following list shows all the highlight groups defined for glance.nvim
- `GlancePreviewNormal`
- `GlancePreviewMatch`
- `GlancePreviewCursorLine`
- `GlancePreviewSignColumn`
- `GlancePreviewEndOfBuffer`
- `GlancePreviewLineNr`
- `GlancePreviewBorderBottom`
- `GlanceWinBarFilename`
- `GlanceWinBarFilepath`
- `GlanceWinBarTitle`
- `GlanceListNormal`
- `GlanceListFilename`
- `GlanceListFilepath`
- `GlanceListCount`
- `GlanceListMatch`
- `GlanceListCursorLine`
- `GlanceListEndOfBuffer`
- `GlanceListBorderBottom`
- `GlanceFoldIcon`
- `GlanceIndent`
- `GlanceBorderTop`
ALTERNATIVES *glance-alternatives*
- nvim-telescope/telescope.nvim <https://github.com/nvim-telescope/telescope.nvim>
- glepnir/lspsaga.nvim <https://github.com/glepnir/lspsaga.nvim>
- folke/trouble.nvim <https://github.com/folke/trouble.nvim>
- rmagatti/goto-preview <https://github.com/rmagatti/goto-preview>
Generated by panvimdoc <https://github.com/kdheepak/panvimdoc>
vim:tw=78:ts=8:noet:ft=help:norl: