Skip to content

Commit d796154

Browse files
committed
💥 Rewrite everything
- Drop JSON configuration and introduce TypeScript based configuration - Completely rewritten internal logics and extensions - Introduce "processor" to improve latency - Introduce "layout" and "theme" for custom appearance - Introduce "curator" extension for live-grep - Introduce "submatch" action for fine-grained selection - Drop "FallResume" for now
1 parent a53921b commit d796154

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+8079
-2
lines changed

autoload/fall.vim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
function! fall#action(name) abort
2+
call fall#internal#dispatch(#{type: 'action-invoke', name: a:name})
3+
endfunction

autoload/fall/command/Fall.vim

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
function! fall#command#Fall#call(args) abort
2+
if denops#plugin#wait('fall') isnot# 0
3+
return
4+
endif
5+
let l:laststatus_saved = &laststatus
6+
augroup fall_command_Fall
7+
autocmd!
8+
autocmd CmdlineEnter * call s:hide()
9+
autocmd CmdlineLeave * call s:show()
10+
augroup END
11+
try
12+
set laststatus=0
13+
call fall#internal#mapping#store()
14+
call denops#request('fall', 'picker:start:command', [a:args])
15+
finally
16+
augroup fall_command_Fall
17+
autocmd!
18+
augroup END
19+
call fall#internal#tolerant#call({ -> fall#internal#mapping#restore() })
20+
call fall#internal#tolerant#call({ -> fall#internal#popup#closeall() })
21+
let &laststatus = l:laststatus_saved
22+
endtry
23+
endfunction
24+
25+
function! fall#command#Fall#complete(arglead, cmdline, cursorpos) abort
26+
if denops#plugin#wait('fall') == 0
27+
return []
28+
endif
29+
return []
30+
endfunction
31+
32+
function! s:hide() abort
33+
call fall#internal#tolerant#call({ -> fall#internal#msgarea#hide() })
34+
call fall#internal#tolerant#call({ -> fall#internal#cursor#hide() })
35+
endfunction
36+
37+
function! s:show() abort
38+
call fall#internal#tolerant#call({ -> fall#internal#msgarea#show() })
39+
call fall#internal#tolerant#call({ -> fall#internal#cursor#show() })
40+
endfunction
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
let s:sep = has('win32') ? '\' : '/'
2+
let s:fall_config_template = join([
3+
\ expand('<sfile>:p:h:h:h:h'),
4+
\ 'denops',
5+
\ 'fall',
6+
\ '_assets',
7+
\ 'default.config.ts',
8+
\], s:sep)
9+
10+
function! fall#command#FallConfig#call() abort
11+
let l:path = fnamemodify(expand(g:fall_config_path), ':p')
12+
if !filereadable(l:path)
13+
call mkdir(fnamemodify(l:path, ':h'), 'p')
14+
call writefile(readfile(s:fall_config_template), l:path)
15+
endif
16+
execute 'vsplit' fnameescape(l:path)
17+
endfunction

autoload/fall/internal.vim

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
function! fall#internal#dispatch(event) abort
2+
if denops#plugin#wait('fall') isnot# 0
3+
return
4+
endif
5+
call denops#request('fall', 'event:dispatch', [a:event])
6+
endfunction

autoload/fall/internal/cursor.vim

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
let s:t_ve_saved = &t_ve
2+
3+
function! fall#internal#cursor#hide() abort
4+
call s:hide_cursor()
5+
endfunction
6+
7+
function! fall#internal#cursor#show() abort
8+
call s:show_cursor()
9+
endfunction
10+
11+
if has('nvim-0.5.0')
12+
function! s:hide_cursor() abort
13+
set guicursor+=a:FallTransparentCursor/lCursor
14+
endfunction
15+
16+
function! s:show_cursor() abort
17+
set guicursor-=a:FallTransparentCursor/lCursor
18+
endfunction
19+
20+
function! s:highlight() abort
21+
highlight FallTransparentCursor gui=strikethrough blend=100
22+
endfunction
23+
call s:highlight()
24+
25+
augroup fall_internal_cursor
26+
autocmd!
27+
autocmd ColorScheme * call s:highlight()
28+
augroup END
29+
elseif has('nvim') || has('gui_running')
30+
function! s:hide_cursor() abort
31+
set guicursor+=a:ver1
32+
endfunction
33+
34+
function! s:show_cursor() abort
35+
let &guicursor = s:guicursor_saved
36+
endfunction
37+
else
38+
function! s:hide_cursor() abort
39+
set t_ve=
40+
endfunction
41+
42+
function! s:show_cursor() abort
43+
let &t_ve = s:t_ve_saved
44+
endfunction
45+
endif
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
function! fall#internal#highlight#fast(filetype)
2+
let l:eventignore_saved = &eventignore
3+
try
4+
set eventignore+=FileType
5+
call fall#internal#highlight#real(a:filetype)
6+
finally
7+
let &eventignore = l:eventignore_saved
8+
endtry
9+
silent! execute printf('runtime syntax/%s.vim', fnameescape(&filetype))
10+
endfunction
11+
12+
function! fall#internal#highlight#real(filetype)
13+
if empty(a:filetype)
14+
silent! unlet! b:ftdetect
15+
silent! filetype detect
16+
else
17+
let &filetype = a:filetype
18+
endif
19+
endfunction

autoload/fall/internal/mapping.vim

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
function! fall#internal#mapping#store() abort
2+
if exists('s:saved_maps')
3+
return
4+
endif
5+
let s:saved_maps = maplist()->filter({ _, m -> m.mode ==# 'c' || m.mode ==# '!' })
6+
endfunction
7+
8+
" NOTE:
9+
"
10+
" It seems restore step must be called twice to restore the mappings correctly.
11+
" Otherwise, mappings with recursive references are not restored correctly.
12+
"
13+
" For example:
14+
"
15+
" cnoremap <Up> <C-p>
16+
" cnoremap <C-p> <Up>
17+
"
18+
function! fall#internal#mapping#restore()
19+
if !exists('s:saved_maps')
20+
return
21+
endif
22+
cmapclear
23+
call foreach(s:saved_maps, {_, m -> mapset(m)})
24+
call foreach(s:saved_maps, {_, m -> mapset(m)})
25+
unlet s:saved_maps
26+
endfunction

autoload/fall/internal/msgarea.vim

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
function! fall#internal#msgarea#hide() abort
2+
call s:hide_msgarea()
3+
redraw
4+
endfunction
5+
6+
function! fall#internal#msgarea#show() abort
7+
call s:show_msgarea()
8+
redraw
9+
endfunction
10+
11+
if has('nvim')
12+
function! s:hide_msgarea() abort
13+
if exists('s:hl_msgarea')
14+
return
15+
endif
16+
let s:hl_msgarea = nvim_get_hl(0, #{ name: 'MsgArea' })
17+
let l:hl_normal = nvim_get_hl(0, #{ name: 'Normal' })
18+
if !has_key(l:hl_normal, 'bg')
19+
" guifg=NONE is not supported
20+
unlet! s:hl_msgarea
21+
return
22+
endif
23+
call nvim_set_hl(0, 'MsgArea', #{ fg: l:hl_normal.bg, bg: l:hl_normal.bg })
24+
endfunction
25+
26+
function! s:show_msgarea() abort
27+
if !exists('s:hl_msgarea')
28+
return
29+
endif
30+
call nvim_set_hl(0, 'MsgArea', s:hl_msgarea)
31+
unlet s:hl_msgarea
32+
endfunction
33+
else
34+
function! s:hide_msgarea() abort
35+
if exists('s:hl_msgarea')
36+
return
37+
endif
38+
let s:hl_msgarea = hlget('MsgArea')
39+
let l:hl_normal = hlget('Normal')
40+
if !has_key(l:hl_normal[0], 'guibg')
41+
" guifg=NONE is not supported
42+
unlet! s:hl_msgarea
43+
return
44+
endif
45+
call hlset([#{ name: 'MsgArea', guifg: l:hl_normal[0].guibg, guibg: l:hl_normal[0].guibg }])
46+
endfunction
47+
48+
function! s:show_msgarea() abort
49+
if !exists('s:hl_msgarea')
50+
return
51+
endif
52+
call hlset([extend(#{ force: 1 }, s:hl_msgarea[0])])
53+
unlet s:hl_msgarea
54+
endfunction
55+
endif

autoload/fall/internal/popup.vim

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
function! fall#internal#popup#closeall() abort
2+
let l:winids = range(1, winnr('$'))
3+
\ ->map({_, v -> win_getid(v)})
4+
\ ->filter({_, v -> win_gettype(v) ==# 'popup'})
5+
call foreach(l:winids, {_, v -> s:close(v)})
6+
endfunction
7+
8+
if has('nvim')
9+
function! s:close(winid) abort
10+
call nvim_win_close(a:winid, v:true)
11+
endfunction
12+
else
13+
function! s:close(winid) abort
14+
call popup_close(a:winid)
15+
endfunction
16+
endif
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
function! fall#internal#tolerant#call(calback) abort
2+
try
3+
call a:calback()
4+
catch
5+
if &verbose
6+
echohl WarningMsg
7+
echomsg printf('[fall] Error on tolerant call: %s', v:exception)
8+
echohl None
9+
endif
10+
endtry
11+
endfunction

0 commit comments

Comments
 (0)