Skip to content

Instantly share code, notes, and snippets.

@osyo-manga
Created December 4, 2016 12:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save osyo-manga/4154a7357498740831a2a7023f411853 to your computer and use it in GitHub Desktop.
Save osyo-manga/4154a7357498740831a2a7023f411853 to your computer and use it in GitHub Desktop.
let s:V = vital#of("vital")
let s:Buffer = s:V.import("Coaster.Buffer")
let s:cmdline = s:V.import("Over.Commandline")
function! Start()
let cmdline = s:cmdline.make_standard(":")
let cmdline.buffer = s:Buffer.open("botright new")
setlocal bufhidden=hide buftype=nofile noswapfile nobuflisted nonumber cursorline
let cmdline.list = glob("**/*", 1, 1)
let cmdline.buffer.setline(1, cmdline.list, 1)
function! cmdline.on_char_pre(...)
if self.is_input("\<A-n>")
silent! normal! j
call self.setchar("")
endif
if self.is_input("\<A-p>")
silent! normal! k
call self.setchar("")
endif
endfunction
function! cmdline.on_char(...)
let pat = self.getline()
let list = pat == "" ? self.list : filter(deepcopy(self.list), { -> v:val =~ pat })
let pos = getcurpos()
call self.buffer.clear(1)
call self.buffer.setline(1, list, 1)
call setpos(".", pos)
endfunction
function! cmdline.on_execute(...)
echom getline(".")
endfunction
function! cmdline.on_leave(...)
call self.buffer.close()
endfunction
call cmdline.start()
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment