Search asynchronously and preview file/symbol/word under cursor in the floating window.
File searching is initially inspired by vim's gf
. It fundamentally works by
invoking the build-in function findfile()
to perform upward (up to the root
directory) and downward searching but asynchronously. It will never block your
actions.
Symbol searching basically invokes taglist()
function asynchronously to
search for the pattern from pre-generated tag files. In addition, the plugin
can also use LSP for searching symbols (both definition and references).
Therefore it would be better to have an LSP client (only support coc.nvim
by now) installed.
Word searching will search for the <cword>
in the current buffer.
Plug 'voldikss/vim-skylight'
Only works in NVIM >= 0.4.3
-
If
!
is given, perform live previewing for multiple entries -
If use with an optional argument:
:Skylight file
regard the text under cursor as a filepath and search:Skylight symbol
regard the text under cursor as a symbol and search:Skylight word
search for the<cword>
in the current buffer
-
If without arguments (i.e.,
:Skylight
), it firstly suppose the text is a filename and search. If failing to search then treat the text as a symbol and search again -
In the drop-down menu, you can use:
j
ork
to move (and perform live previewing if the menu is opened by: Skylight!
)<CR>
for previewing or jumping to<Esc>
orq
for closing- number keys(
1
,2
, ...) to quickly jump to the corresponding entry <C-w>p
to jump to the skylight window and jump back
This command can also be used with a range, e.g., visual select and '<,'>:Skylight! file
.
-
g:skylight_width
Type
Number
(number of columns) orFloat
(between 0 and 1). IfFloat
, the width is relative to&columns
.Default:
0.5
-
g:skylight_height
Type
Number
(number of lines) orFloat
(between 0 and 1). IfFloat
, the height is relative to&lines
.Default:
0.5
-
g:skylight_position
Type
String
. The position of the floating window.Available:
'top'
,'right'
,'bottom'
,'left'
,'center'
,'topleft'
,'topright'
,'bottomleft'
,'bottomright'
,'auto'(at the cursor place)
.Default:
'topright'
(recommended) -
g:skylight_borderchars
Type
List
ofString
. Characters for the border.Default:
['─', '│', '─', '│', 'â•', 'â•®', '╯', 'â•°']
-
g:skylight_opener
Type
String
. Command used for jumping toAvailable:
'edit'
,'split'
,'vsplit'
,'tabe'
,'drop'
.Default:
'edit'
" Configuration example
nnoremap <silent> gp :Skylight!<CR>
vnoremap <silent> gp :Skylight!<CR>
In the skylight-menu window, use <C-f>
to scroll forward and <C-b>
to
scroll backward.
SkylightBorder
, which is linked to Normal
by default, can be used to
specify the border style.
" Configuration example
hi SkylightBorder guibg=orange guifg=cyan
For a long time I was hoping to preview file under cursor in a disposable
floating window without actually opening it. Then I dug into the web and found
some awesome projects, which, however, only support previewing files that are
listed only in the quickfix window. What I want is to preview the file that is
given by either relative or absolute path and occurs anywhere in vim, even
those in the builtin terminal window (when I am using gdb's bt
command).
The codes were initially buildup in my personal dotfiles. After the whole feature was almost implemented, I decided to detach them from the dotfiles and reorganize them into a plugin in case of someone who has the same requirement needs it.
Sometimes can not find the files in the hidden folders when performing downward searching. That is because vim's file searching doesn't include hidden directories, I am considering using another suitable file-finder cli tool for the plugin but this will not come out in the short term.
Note that the plugin is developed with pure vimscript. Therefore, until the
whole file content has been loaded into memory could it be previewed in the
skylight window, so it's not recommended to perform :Skylight[!]
on large
size files as it will cost more time for nvim to open that file.