-
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #113 from lambdalisue/ferndo
Add :FernDo command and deprecate :FernFocus command
- Loading branch information
Showing
5 changed files
with
71 additions
and
42 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
function! fern#internal#command#do#command(mods, fargs) abort | ||
let winid_saved = win_getid() | ||
try | ||
let stay = fern#internal#args#pop(a:fargs, 'stay', v:false) | ||
let drawer = fern#internal#args#pop(a:fargs, 'drawer', v:false) | ||
|
||
if len(a:fargs) is# 0 | ||
\ || type(stay) isnot# v:t_bool | ||
\ || type(drawer) isnot# v:t_bool | ||
throw 'Usage: FernDo {expr...} [-drawer] [-stay]' | ||
endif | ||
|
||
" Does all options are handled? | ||
call fern#internal#args#throw_if_dirty(a:fargs) | ||
|
||
let found = fern#internal#window#find( | ||
\ funcref('s:predicator', [drawer]), | ||
\ winnr() + 1, | ||
\) | ||
if !found | ||
return | ||
endif | ||
call win_gotoid(win_getid(found)) | ||
execute join([a:mods] + a:fargs, ' ') | ||
catch | ||
echohl ErrorMsg | ||
echo v:exception | ||
echohl None | ||
call fern#logger#debug(v:exception) | ||
call fern#logger#debug(v:throwpoint) | ||
finally | ||
if stay | ||
call win_gotoid(winid_saved) | ||
endif | ||
endtry | ||
endfunction | ||
|
||
function! fern#internal#command#do#complete(arglead, cmdline, cursorpos) abort | ||
return fern#internal#complete#options(a:arglead, a:cmdline, a:cursorpos) | ||
endfunction | ||
|
||
function! s:predicator(drawer, winnr) abort | ||
let bufname = bufname(winbufnr(a:winnr)) | ||
let fri = fern#fri#parse(bufname) | ||
return fri.scheme ==# 'fern' | ||
\ && (!a:drawer || fri.authority =~# '\<drawer\>') | ||
endfunction |
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 |
---|---|---|
@@ -1,38 +1,15 @@ | ||
function! fern#internal#command#focus#command(mods, fargs) abort | ||
try | ||
let drawer = fern#internal#args#pop(a:fargs, 'drawer', v:false) | ||
|
||
if len(a:fargs) isnot# 0 | ||
\ || type(drawer) isnot# v:t_bool | ||
throw 'Usage: FernFocus [-drawer]' | ||
endif | ||
|
||
" Does all options are handled? | ||
call fern#internal#args#throw_if_dirty(a:fargs) | ||
|
||
let found = fern#internal#window#find( | ||
\ funcref('s:predicator', [drawer]), | ||
\ winnr() + 1, | ||
\) | ||
if found | ||
call win_gotoid(win_getid(found)) | ||
endif | ||
catch | ||
echohl ErrorMsg | ||
echo v:exception | ||
echohl None | ||
call fern#logger#debug(v:exception) | ||
call fern#logger#debug(v:throwpoint) | ||
endtry | ||
call fern#util#deprecated( | ||
\ '":FernFocus"', | ||
\ '":FernDo :"' | ||
\) | ||
if fern#internal#args#pop(a:fargs, 'drawer', v:false) | ||
FernDo : -drawer | ||
else | ||
FernDo : | ||
endif | ||
endfunction | ||
|
||
function! fern#internal#command#focus#complete(arglead, cmdline, cursorpos) abort | ||
return fern#internal#complete#options(a:arglead, a:cmdline, a:cursorpos) | ||
endfunction | ||
|
||
function! s:predicator(drawer, winnr) abort | ||
let bufname = bufname(winbufnr(a:winnr)) | ||
let fri = fern#fri#parse(bufname) | ||
return fri.scheme ==# 'fern' | ||
\ && (!a:drawer || fri.authority =~# '\<drawer\>') | ||
endfunction |
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