Skip to content

Commit 607d673

Browse files
committed
Deprecate 'stick' feature of the 'smart_cursor'
There is 'hide' feature so that I've decided to provide only that as 'hide_cursor'. Rel: #307, #308, #312
1 parent c09eb24 commit 607d673

File tree

8 files changed

+43
-73
lines changed

8 files changed

+43
-73
lines changed

autoload/fern.vim

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,14 @@ call s:Config.config(expand('<sfile>:p'), {
2424
\ 'logfile': v:null,
2525
\ 'loglevel': g:fern#INFO,
2626
\ 'opener': 'edit',
27-
\ 'smart_cursor': 'stick',
27+
\ 'hide_cursor': 0,
2828
\ 'keepalt_on_edit': 0,
2929
\ 'keepjumps_on_edit': 0,
3030
\ 'disable_auto_buffer_delete': 0,
3131
\ 'disable_auto_buffer_rename': 0,
3232
\ 'disable_default_mappings': 0,
3333
\ 'disable_viewer_spinner': has('win32') && !has('gui_running'),
3434
\ 'disable_viewer_auto_duplication': 0,
35-
\ 'disable_viewer_smart_cursor': 0,
3635
\ 'disable_drawer_auto_winfixwidth': 0,
3736
\ 'disable_drawer_auto_resize': 0,
3837
\ 'disable_drawer_smart_quit': get(g:, 'disable_drawer_auto_quit', 0),
@@ -71,3 +70,9 @@ if exists('g:fern#disable_drawer_auto_quit')
7170
\ 'g:fern#disable_drawer_smart_quit',
7271
\)
7372
endif
73+
if exists('g:fern#smart_cursor')
74+
call fern#util#deprecated('g:fern#smart_cursor', 'g:fern#hide_cursor')
75+
endif
76+
if exists('g:fern#disable_viewer_smart_cursor')
77+
call fern#util#deprecated('g:fern#disable_viewer_smart_cursor')
78+
endif

autoload/fern/helper/async.vim

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,8 @@ function! s:async_redraw() abort dict
1717
let l:Profile = fern#profile#start('fern#helper:helper.async.redraw')
1818
let helper = self.helper
1919
let fern = helper.fern
20-
let prefix = !g:fern#disable_viewer_smart_cursor && g:fern#smart_cursor ==# 'stick' ? ' ' : ''
2120
return s:Promise.resolve()
2221
\.then({ -> fern.renderer.render(fern.visible_nodes) })
23-
\.then({ v -> map(v, { -> prefix . v:val }) })
2422
\.then({ v -> fern#internal#buffer#replace(helper.bufnr, v) })
2523
\.then({ -> helper.async.remark() })
2624
\.then({ -> fern#hook#emit('viewer:redraw', helper) })

autoload/fern/internal/viewer.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function! s:init() abort
5757
autocmd CursorMoved,CursorMovedI,BufLeave <buffer> let b:fern_cursor = getcurpos()[1:2]
5858
augroup END
5959
call fern#internal#viewer#auto_duplication#init()
60-
call fern#internal#viewer#smart_cursor#init()
60+
call fern#internal#viewer#hide_cursor#init()
6161

6262
" Add unique fragment to make each buffer uniq
6363
let bufname = bufname('%')
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
function! fern#internal#viewer#hide_cursor#init() abort
2+
if !g:fern#hide_cursor
3+
return
4+
endif
5+
call s:hide_cursor_init()
6+
endfunction
7+
8+
function! s:hide_cursor_init() abort
9+
augroup fern_internal_viewer_smart_cursor_init
10+
autocmd! * <buffer>
11+
autocmd BufEnter,WinEnter,CmdwinLeave,CmdlineLeave <buffer> setlocal cursorline
12+
autocmd BufLeave,WinLeave,CmdwinEnter,CmdlineEnter <buffer> setlocal nocursorline
13+
autocmd BufEnter,WinEnter,CmdwinLeave,CmdlineLeave <buffer> call fern#internal#cursor#hide()
14+
autocmd BufLeave,WinLeave,CmdwinEnter,CmdlineEnter <buffer> call fern#internal#cursor#restore()
15+
autocmd VimLeave <buffer> call fern#internal#cursor#restore()
16+
augroup END
17+
18+
" Do NOT allow cursorlineopt=number while the cursor is hidden (Fix #182)
19+
if exists('+cursorlineopt')
20+
setlocal cursorlineopt=number,line
21+
endif
22+
endfunction

autoload/fern/internal/viewer/smart_cursor.vim

Lines changed: 0 additions & 39 deletions
This file was deleted.

autoload/fern/renderer/default.vim

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,25 +38,20 @@ function! s:lnum(index) abort
3838
endfunction
3939

4040
function! s:syntax() abort
41-
let prefix = !g:fern#disable_viewer_smart_cursor && g:fern#smart_cursor ==# 'stick' ? ' ' : ''
42-
4341
syntax match FernLeaf /^.*[^/].*$/ transparent contains=FernLeafSymbol
4442
syntax match FernBranch /^.*\/.*$/ transparent contains=FernBranchSymbol
4543
syntax match FernRoot /\%1l.*/ transparent contains=FernRootText
4644
execute printf(
47-
\ 'syntax match FernRootSymbol /%s%s/ contained nextgroup=FernRootText',
48-
\ prefix,
45+
\ 'syntax match FernRootSymbol /%s/ contained nextgroup=FernRootText',
4946
\ escape(g:fern#renderer#default#root_symbol, s:ESCAPE_PATTERN),
5047
\)
5148
execute printf(
52-
\ 'syntax match FernLeafSymbol /^%s\%%(%s\)*%s/ contained nextgroup=FernLeafText',
53-
\ prefix,
49+
\ 'syntax match FernLeafSymbol /^\%%(%s\)*%s/ contained nextgroup=FernLeafText',
5450
\ escape(g:fern#renderer#default#leading, s:ESCAPE_PATTERN),
5551
\ escape(g:fern#renderer#default#leaf_symbol, s:ESCAPE_PATTERN),
5652
\)
5753
execute printf(
58-
\ 'syntax match FernBranchSymbol /^%s\%%(%s\)*\%%(%s\|%s\)/ contained nextgroup=FernBranchText',
59-
\ prefix,
54+
\ 'syntax match FernBranchSymbol /^\%%(%s\)*\%%(%s\|%s\)/ contained nextgroup=FernBranchText',
6055
\ escape(g:fern#renderer#default#leading, s:ESCAPE_PATTERN),
6156
\ escape(g:fern#renderer#default#collapsed_symbol, s:ESCAPE_PATTERN),
6257
\ escape(g:fern#renderer#default#expanded_symbol, s:ESCAPE_PATTERN),

doc/fern.txt

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -330,22 +330,16 @@ VARIABLE *fern-variable*
330330
windows style.
331331
Default: 'edit'
332332

333+
*g:fern#hide_cursor*
334+
Set 1 to hide cursor and forcedly enable |cursorline| to visualize the
335+
cursor node. The |cursorline| is automatically enabled when the focus
336+
is on the buffer and automatically disabled when the cursor is out of
337+
the buffer.
338+
Note that Neovim prior to 0.5.0 cannot hide the cursor thus faint
339+
vertical bar is used instead.
340+
333341
*g:fern#smart_cursor*
334-
A type |String| of the smart cursor. Available values are
335-
336-
"stick" Stick the cursor to the first column to visualize the
337-
cursor node. In this mode, single whitespace is
338-
prefixed as a padding for better looks.
339-
340-
"hide" Hide the cursor and forcedly enable |cursorline| to
341-
visualize the cursor node. In this mode, |cursorline|
342-
is automatically enabled when the focus is on the
343-
buffer and automatically disabled when the cursor is
344-
out of the buffer.
345-
Note that Neovim prior to 0.5.0 cannot hide the cursor
346-
thus faint vertical bar is used instead.
347-
348-
Default: "stick"
342+
DEPRECATED: Use |g:fern#hide_cursor| instead.
349343

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

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

423416
*g:fern#disable_viewer_smart_cursor*
424-
Set 1 to disable viewer smart cursor feature.
425-
See |g:fern#smart_cursor| for detail.
417+
DEPRECATED: The smart cursor feature has obsoleted.
426418

427419
*g:fern#disable_drawer_auto_winfixwidth*
428420
Set 1 to disable automatically enable 'winfixwidth' to drawer on

test/.themisrc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,3 @@ call themis#log('-----------------------------------------------------------')
3737

3838
" Add test utilities
3939
set runtimepath+=./test/util
40-
41-
" Disable 'smart_cursor' which slightly change the viewer content
42-
let g:fern#disable_viewer_smart_cursor = 1

0 commit comments

Comments
 (0)