Skip to content

Instantly share code, notes, and snippets.

@VernonGrant
Last active March 19, 2021 03:09
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 VernonGrant/e7db971f637874bec7c14a6c98d40de6 to your computer and use it in GitHub Desktop.
Save VernonGrant/e7db971f637874bec7c14a6c98d40de6 to your computer and use it in GitHub Desktop.
Vim run tasks
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" TASKS "
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" holds the global tasks
let g:GlobalTasks = {'Git Status:': '!git status'}
fun GetNumberedDictKeys(taskDict)
" Extracts the task keys and returns them as a numbered list.
let counter = 1
let taskList = ['Run Task:']
for key in sort(keys(a:taskDict))
let taskList = add(l:taskList, l:counter . ': ' . key)
let counter+=1
endfor
return l:taskList
endf
fun RunGlobalTask()
" Runs the given task number.
let selection = inputlist(GetNumberedDictKeys(g:GlobalTasks))
if (l:selection != 0 && l:selection <= len(g:GlobalTasks))
let taskKeys = sort(keys(g:GlobalTasks))
execute(g:GlobalTasks[l:taskKeys[l:selection - 1]])
endif
endf
nnoremap <leader>t :call RunGlobalTask()<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment