robin/ivy
my custom neovim config
git clone https://git.robinwobin.dev/robin/ivy
11251ed
main
1if vim . g . loaded_shell then 2return 3end 4 5vim . g . loaded_shell =true 6 7vim . api . nvim_create_user_command ( "Shell" , function ( opts ) 8opts . args =vim . trim ( opts . args ) 9if # opts . args == 0 then 10return vim . notify ( "shell cmd empty" , vim . log . levels . WARN ) 11end 12 13---@type [string,(string|integer)?][] 14local cmdmsg ={ { "command " } , { opts . args , "@markup.raw" } } 15 16local pg ={ 17source ="shell" , 18title ="shell cmd" , 19kind ="progress" , 20status ="running" , 21} 22table . insert ( cmdmsg , { " started" } ) 23pg . id =vim . api . nvim_echo ( cmdmsg , true , pg ) 24 25vim . system ( { vim . o . shell , vim . o . shellcmdflag , opts . args } , {} , function ( o ) 26if not o . code or o . code ~= 0 then 27pg . status ="failed" 28cmdmsg [ 3 ] ={ ( " exited with code %d SIG%d" ): format ( o . code , o . signal ) } 29vim . schedule ( function () 30vim . api . nvim_echo ( cmdmsg , true , pg ) 31end ) 32else 33pg . status ="success" 34cmdmsg [ 3 ] ={ ( " exited succesfully" ): format ( o . code , o . signal ) } 35vim . schedule ( function () 36vim . api . nvim_echo ( cmdmsg , true , pg ) 37end ) 38end 39end ) 40end , { 41nargs ="*" , 42complete ="shellcmd" , 43desc ="run shell command" , 44} )