-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add preview support for grep provider (#138)
* Add preview support for grep provider * Nits * Return directly if meeting any expection when on_move * Rename to g:clap.preview.add_highlight() * .
- Loading branch information
1 parent
4c5affe
commit dfffb5e
Showing
8 changed files
with
139 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
" Author: liuchengxu <xuliuchengxlc@gmail.com> | ||
" Description: Get filetype based on the fname's extension. | ||
|
||
let s:save_cpo = &cpoptions | ||
set cpoptions&vim | ||
|
||
" This is not complete, but should be enough to cover the most extensions. | ||
" https://vi.stackexchange.com/questions/9962/get-filetype-by-extension-or-filename-in-vimscript | ||
function! s:init_ext2ft() abort | ||
let matched = [] | ||
for line in split(execute('autocmd filetypedetect'), "\n") | ||
if line =~? '\*\.\a\+\s*setf' | ||
call add(matched, line) | ||
endif | ||
endfor | ||
|
||
let s:ext2ft = {} | ||
for line in matched | ||
let splitted = split(line) | ||
let ext = split(splitted[0], '\.')[-1] | ||
let ft = splitted[-1] | ||
let s:ext2ft[ext] = ft | ||
endfor | ||
endfunction | ||
|
||
if !exists('s:ext2ft') | ||
call s:init_ext2ft() | ||
endif | ||
|
||
function! clap#ext#into_filetype(fname) abort | ||
let ext = fnamemodify(a:fname, ':e') | ||
if !empty(ext) && has_key(s:ext2ft, ext) | ||
return s:ext2ft[ext] | ||
else | ||
return '' | ||
endif | ||
endfunction | ||
|
||
let &cpoptions = s:save_cpo | ||
unlet s:save_cpo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters