-
-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: split up hide_cursor option (#491)
This revision introduces changes to the 'g:fern#hide_cursor' option. Before these changes, this option forcibly disables 'cursorline' when focus is not on the fern window and unsets 't_ve' to hide the cursor for the fern window. In some configurations, it's desirable to hide the cursor but not change the cursorline configuration. For instance, the user may want to see what item is selected in the fern window when working in other buffers. Although it's relatively trivial to skip 'hide_cursor' altogether and manually update 't_ve', I believe there's value in supporting this in Fern. This revision introduces a new option, 'g:fern#hide_cursorline', which enables/disables the 'cursorline' option on WinEnter/WinLeave, similar to what 'hide_cursor' did before. Documentation has been updated to reflect this change.
- Loading branch information
1 parent
e295f0d
commit 56f8e4c
Showing
5 changed files
with
30 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,14 @@ | ||
function! fern#internal#viewer#hide_cursor#init() abort | ||
if !g:fern#hide_cursor | ||
return | ||
if g:fern#hide_cursor | ||
call s:hide_cursor_init() | ||
endif | ||
call s:hide_cursor_init() | ||
endfunction | ||
|
||
function! s:hide_cursor_init() abort | ||
augroup fern_internal_viewer_smart_cursor_init | ||
autocmd! * <buffer> | ||
autocmd BufEnter,WinEnter,TabLeave,CmdwinLeave,CmdlineLeave <buffer> setlocal cursorline | ||
autocmd BufLeave,WinLeave,TabLeave,CmdwinEnter,CmdlineEnter <buffer> setlocal nocursorline | ||
autocmd BufEnter,WinEnter,TabLeave,CmdwinLeave,CmdlineLeave <buffer> call fern#internal#cursor#hide() | ||
autocmd BufLeave,WinLeave,TabLeave,CmdwinEnter,CmdlineEnter <buffer> call fern#internal#cursor#restore() | ||
autocmd VimLeave <buffer> call fern#internal#cursor#restore() | ||
augroup END | ||
|
||
" Do NOT allow cursorlineopt=number while the cursor is hidden (Fix #182) | ||
if exists('+cursorlineopt') | ||
" NOTE: | ||
" Default value is `number,line` (or `both` prior to patch-8.1.2029) | ||
setlocal cursorlineopt& | ||
endif | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
function! fern#internal#viewer#hide_cursorline#init() abort | ||
if g:fern#hide_cursorline | ||
call s:hide_cursorline_init() | ||
endif | ||
endfunction | ||
|
||
function! s:hide_cursorline_init() abort | ||
augroup fern_internal_viewer_smart_cursor_line_init | ||
autocmd! * <buffer> | ||
autocmd BufEnter,WinEnter,TabLeave,CmdwinLeave,CmdlineLeave <buffer> setlocal cursorline | ||
autocmd BufLeave,WinLeave,TabLeave,CmdwinEnter,CmdlineEnter <buffer> setlocal nocursorline | ||
augroup END | ||
|
||
" Do NOT allow cursorlineopt=number while the cursor is hidden (Fix #182) | ||
if exists('+cursorlineopt') | ||
" NOTE: | ||
" Default value is `number,line` (or `both` prior to patch-8.1.2029) | ||
setlocal cursorlineopt& | ||
endif | ||
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