asynctask.vim 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. let g:asyncrun_open = 6
  2. let g:asynctasks_term_pos = 'bottom'
  3. " let g:asynctasks_term_pos = 'top'
  4. " let g:asynctasks_term_pos = 'tab'
  5. " let g:asynctasks_term_pos = 'external'
  6. let g:asynctasks_extra_config = ['~/.config/nvim/utils/tasks.ini']
  7. " let current_tasks = asynctasks#list("")
  8. function! s:fzf_sink(what)
  9. let p1 = stridx(a:what, '<')
  10. if p1 >= 0
  11. let name = strpart(a:what, 0, p1)
  12. let name = substitute(name, '^\s*\(.\{-}\)\s*$', '\1', '')
  13. if name != ''
  14. exec "AsyncTask ". fnameescape(name)
  15. endif
  16. endif
  17. endfunction
  18. function! s:fzf_task()
  19. let rows = asynctasks#source(&columns * 48 / 100)
  20. let source = []
  21. for row in rows
  22. let name = row[0]
  23. let source += [name . ' ' . row[1] . ' : ' . row[2]]
  24. endfor
  25. let opts = { 'source': source, 'sink': function('s:fzf_sink'),
  26. \ 'options': '+m --nth 1 --inline-info --tac' }
  27. if exists('g:fzf_layout')
  28. for key in keys(g:fzf_layout)
  29. let opts[key] = deepcopy(g:fzf_layout[key])
  30. endfor
  31. endif
  32. call fzf#run(opts)
  33. endfunction
  34. command! -nargs=0 AsyncTaskFzf call s:fzf_task()
  35. " Available Variables
  36. " $(VIM_FILEPATH) # File name of current buffer with full path.
  37. " $(VIM_FILENAME) # File name of current buffer without path.
  38. " $(VIM_FILEDIR) # Full path of current buffer without the file name.
  39. " $(VIM_FILEEXT) # File extension of current buffer.
  40. " $(VIM_FILETYPE) # File type (value of &ft in vim)
  41. " $(VIM_FILENOEXT) # File name of current buffer without path and extension.
  42. " $(VIM_PATHNOEXT) # Current file name with full path but without extension.
  43. " $(VIM_CWD) # Current directory (which :pwd returns).
  44. " $(VIM_RELDIR) # File path relativize to current directory.
  45. " $(VIM_RELNAME) # File name relativize to current directory.
  46. " $(VIM_ROOT) # Project root directory.
  47. " $(VIM_CWORD) # Word under cursor.
  48. " $(VIM_CFILE) # File name under cursor.
  49. " $(VIM_CLINE) # Cursor line number in current buffer
  50. " $(VIM_GUI) # has('gui_runnin')?
  51. " $(VIM_VERSION) # Value of v:version.
  52. " $(VIM_COLUMNS) # Current screen width.
  53. " $(VIM_LINES) # Current screen height.
  54. " $(VIM_SVRNAME) # Value of v:servername.
  55. " $(VIM_PRONAME) # Name of current project root directory
  56. " $(VIM_DIRNAME) # Name of current directory
  57. " $(VIM_INIFILE) # Full path name of current ini (.tasks) file.
  58. " $(VIM_INIHOME) # Where the ini file locates.