Last active
March 19, 2021 03:09
-
-
Save VernonGrant/e7db971f637874bec7c14a6c98d40de6 to your computer and use it in GitHub Desktop.
Vim run tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" | |
" 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