Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions autoload/fern.vim
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,14 @@ call s:Config.config(expand('<sfile>:p'), {
\ 'logfile': v:null,
\ 'loglevel': g:fern#INFO,
\ 'opener': 'edit',
\ 'smart_cursor': 'stick',
\ 'hide_cursor': 0,
\ 'keepalt_on_edit': 0,
\ 'keepjumps_on_edit': 0,
\ 'disable_auto_buffer_delete': 0,
\ 'disable_auto_buffer_rename': 0,
\ 'disable_default_mappings': 0,
\ 'disable_viewer_spinner': has('win32') && !has('gui_running'),
\ 'disable_viewer_auto_duplication': 0,
\ 'disable_viewer_smart_cursor': 0,
\ 'disable_drawer_auto_winfixwidth': 0,
\ 'disable_drawer_auto_resize': 0,
\ 'disable_drawer_smart_quit': get(g:, 'disable_drawer_auto_quit', 0),
Expand Down Expand Up @@ -71,3 +70,9 @@ if exists('g:fern#disable_drawer_auto_quit')
\ 'g:fern#disable_drawer_smart_quit',
\)
endif
if exists('g:fern#smart_cursor')
call fern#util#deprecated('g:fern#smart_cursor', 'g:fern#hide_cursor')
endif
if exists('g:fern#disable_viewer_smart_cursor')
call fern#util#deprecated('g:fern#disable_viewer_smart_cursor')
endif
2 changes: 0 additions & 2 deletions autoload/fern/helper/async.vim
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ function! s:async_redraw() abort dict
let l:Profile = fern#profile#start('fern#helper:helper.async.redraw')
let helper = self.helper
let fern = helper.fern
let prefix = !g:fern#disable_viewer_smart_cursor && g:fern#smart_cursor ==# 'stick' ? ' ' : ''
return s:Promise.resolve()
\.then({ -> fern.renderer.render(fern.visible_nodes) })
\.then({ v -> map(v, { -> prefix . v:val }) })
\.then({ v -> fern#internal#buffer#replace(helper.bufnr, v) })
\.then({ -> helper.async.remark() })
\.then({ -> fern#hook#emit('viewer:redraw', helper) })
Expand Down
2 changes: 1 addition & 1 deletion autoload/fern/internal/viewer.vim
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function! s:init() abort
autocmd CursorMoved,CursorMovedI,BufLeave <buffer> let b:fern_cursor = getcurpos()[1:2]
augroup END
call fern#internal#viewer#auto_duplication#init()
call fern#internal#viewer#smart_cursor#init()
call fern#internal#viewer#hide_cursor#init()

" Add unique fragment to make each buffer uniq
let bufname = bufname('%')
Expand Down
22 changes: 22 additions & 0 deletions autoload/fern/internal/viewer/hide_cursor.vim
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
function! fern#internal#viewer#hide_cursor#init() abort
if !g:fern#hide_cursor
return
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,CmdwinLeave,CmdlineLeave <buffer> setlocal cursorline
autocmd BufLeave,WinLeave,CmdwinEnter,CmdlineEnter <buffer> setlocal nocursorline
autocmd BufEnter,WinEnter,CmdwinLeave,CmdlineLeave <buffer> call fern#internal#cursor#hide()
autocmd BufLeave,WinLeave,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')
setlocal cursorlineopt=number,line
endif
endfunction
39 changes: 0 additions & 39 deletions autoload/fern/internal/viewer/smart_cursor.vim

This file was deleted.

11 changes: 3 additions & 8 deletions autoload/fern/renderer/default.vim
Original file line number Diff line number Diff line change
Expand Up @@ -38,25 +38,20 @@ function! s:lnum(index) abort
endfunction

function! s:syntax() abort
let prefix = !g:fern#disable_viewer_smart_cursor && g:fern#smart_cursor ==# 'stick' ? ' ' : ''

syntax match FernLeaf /^.*[^/].*$/ transparent contains=FernLeafSymbol
syntax match FernBranch /^.*\/.*$/ transparent contains=FernBranchSymbol
syntax match FernRoot /\%1l.*/ transparent contains=FernRootText
execute printf(
\ 'syntax match FernRootSymbol /%s%s/ contained nextgroup=FernRootText',
\ prefix,
\ 'syntax match FernRootSymbol /%s/ contained nextgroup=FernRootText',
\ escape(g:fern#renderer#default#root_symbol, s:ESCAPE_PATTERN),
\)
execute printf(
\ 'syntax match FernLeafSymbol /^%s\%%(%s\)*%s/ contained nextgroup=FernLeafText',
\ prefix,
\ 'syntax match FernLeafSymbol /^\%%(%s\)*%s/ contained nextgroup=FernLeafText',
\ escape(g:fern#renderer#default#leading, s:ESCAPE_PATTERN),
\ escape(g:fern#renderer#default#leaf_symbol, s:ESCAPE_PATTERN),
\)
execute printf(
\ 'syntax match FernBranchSymbol /^%s\%%(%s\)*\%%(%s\|%s\)/ contained nextgroup=FernBranchText',
\ prefix,
\ 'syntax match FernBranchSymbol /^\%%(%s\)*\%%(%s\|%s\)/ contained nextgroup=FernBranchText',
\ escape(g:fern#renderer#default#leading, s:ESCAPE_PATTERN),
\ escape(g:fern#renderer#default#collapsed_symbol, s:ESCAPE_PATTERN),
\ escape(g:fern#renderer#default#expanded_symbol, s:ESCAPE_PATTERN),
Expand Down
28 changes: 10 additions & 18 deletions doc/fern.txt
Original file line number Diff line number Diff line change
Expand Up @@ -330,22 +330,16 @@ VARIABLE *fern-variable*
windows style.
Default: 'edit'

*g:fern#hide_cursor*
Set 1 to hide cursor and forcedly enable |cursorline| to visualize the
cursor node. The |cursorline| is automatically enabled when the focus
is on the buffer and automatically disabled when the cursor is out of
the buffer.
Note that Neovim prior to 0.5.0 cannot hide the cursor thus faint
vertical bar is used instead.

*g:fern#smart_cursor*
A type |String| of the smart cursor. Available values are

"stick" Stick the cursor to the first column to visualize the
cursor node. In this mode, single whitespace is
prefixed as a padding for better looks.

"hide" Hide the cursor and forcedly enable |cursorline| to
visualize the cursor node. In this mode, |cursorline|
is automatically enabled when the focus is on the
buffer and automatically disabled when the cursor is
out of the buffer.
Note that Neovim prior to 0.5.0 cannot hide the cursor
thus faint vertical bar is used instead.

Default: "stick"
DEPRECATED: Use |g:fern#hide_cursor| instead.

*g:fern#keepalt_on_edit*
Set 1 to apply |keepalt| on the "open:edit" action to keep an
Expand Down Expand Up @@ -418,11 +412,9 @@ VARIABLE *fern-variable*

*g:fern#disable_viewer_hide_cursor*
DEPRECATED: The cursor is not hidden any longer in default.
See |g:fern#smart_cursor| for detail.

*g:fern#disable_viewer_smart_cursor*
Set 1 to disable viewer smart cursor feature.
See |g:fern#smart_cursor| for detail.
DEPRECATED: The smart cursor feature has obsoleted.

*g:fern#disable_drawer_auto_winfixwidth*
Set 1 to disable automatically enable 'winfixwidth' to drawer on
Expand Down
3 changes: 0 additions & 3 deletions test/.themisrc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,3 @@ call themis#log('-----------------------------------------------------------')

" Add test utilities
set runtimepath+=./test/util

" Disable 'smart_cursor' which slightly change the viewer content
let g:fern#disable_viewer_smart_cursor = 1