Skip to content

Instantly share code, notes, and snippets.

@dbernheisel
Created February 23, 2022 17:57
Show Gist options
  • Save dbernheisel/761269f6e1c7a1dc1626105f840e0202 to your computer and use it in GitHub Desktop.
Save dbernheisel/761269f6e1c7a1dc1626105f840e0202 to your computer and use it in GitHub Desktop.
Use fzf.vim to fuzzy-find available mix commands
function! g:MixRun(selection) abort
if !empty(a:selection)
execute "!mix ".a:selection
endif
endfunction
function! g:MixFzf(selection = '') abort
if empty(a:selection)
call fzf#run(fzf#wrap({
\ 'source': 'mix help --names',
\ 'sink': function('g:MixRun'),
\ 'layout' : {
\ 'window': {
\ 'width': 0.95,
\ 'height': 0.9,
\ 'relative': v:true,
\ 'yoffset': 1.0 } },
\ 'options': "--preview 'mix help {}'"}))
else
call MixRun(a:selection)
endif
endfunction
command! -nargs=* Mix call MixFzf(<q-args>)
" Use FZF: :Mix<cr>
" Direct: :Mix compile<cr>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment