diff options
| author | Mitermayer Reis <mitermayer.reis@gmail.com> | 2017-09-17 23:48:53 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-09-17 23:48:53 -0700 |
| commit | bfe75968b5b05cb4b31ea08697d62908539e623e (patch) | |
| tree | 6fcd31b6a42cc1fc962b85b8d983467b2cbbc5b8 | |
| parent | 7f3c9f3d92619eedf0593b915dae0e3fd20aaa27 (diff) | |
| parent | 2f5b382087f131c0ab967600b2d9ce2f3201e653 (diff) | |
| download | vim-prettier-bfe75968b5b05cb4b31ea08697d62908539e623e.tar.xz | |
Merge pull request #54 from prettier/adding-extra-commands
feature: Adding more vim-prettier commands
| -rw-r--r-- | README.md | 24 | ||||
| -rw-r--r-- | autoload/prettier.vim | 21 | ||||
| -rw-r--r-- | doc/prettier.txt | 16 | ||||
| -rw-r--r-- | plugin/prettier.vim | 16 |
4 files changed, 77 insertions, 0 deletions
@@ -53,6 +53,30 @@ If your are on vim 8+ you can also trigger async formatting by: :PrettierAsync ``` +You can check what is the `vim-prettier` plugin version by: + +```vim +:PrettierVersion +``` + +You can send commands to the resolved `prettier` cli by: + +``` +:PrettierCli <q-args> +``` + +You can check what is the resolved `prettier` cli path by: + +```vim +:PrettierCliPath +``` + +You can check what is the resolved `prettier` cli version by: + +```vim +:PrettierCliVersion +``` + ### Configuration Change the mapping to run from the default of `<Leader>p` diff --git a/autoload/prettier.vim b/autoload/prettier.vim index 7d6eb08..79b4611 100644 --- a/autoload/prettier.vim +++ b/autoload/prettier.vim @@ -2,6 +2,27 @@ let s:root_dir = fnamemodify(resolve(expand('<sfile>:p')), ':h') let s:prettier_job_running = 0 let s:prettier_quickfix_open = 0 +function! prettier#PrettierCliPath() abort + let l:execCmd = s:Get_Prettier_Exec() + + if l:execCmd != -1 + echom l:execCmd + else + call s:Suggest_Install_Prettier() + endif +endfunction + +function! prettier#PrettierCli(user_input) abort + let l:execCmd = s:Get_Prettier_Exec() + + if l:execCmd != -1 + let l:out = system(l:execCmd. ' ' . a:user_input) + echom l:out + else + call s:Suggest_Install_Prettier() + endif +endfunction + function! prettier#Prettier(...) abort let l:execCmd = s:Get_Prettier_Exec() let l:async = a:0 > 0 ? a:1 : 0 diff --git a/doc/prettier.txt b/doc/prettier.txt index 38fad26..a10f310 100644 --- a/doc/prettier.txt +++ b/doc/prettier.txt @@ -58,6 +58,22 @@ If your are on vim 8+ you can also trigger async formatting by: > :PrettierAsync < +You can check what is the `vim-prettier` plugin version by: +> + :PrettierVersion +< +You can send commands to the resolved `prettier` cli by: +> + :PrettierCli <q-args> +< +You can check what is the resolved `prettier` cli path by: +> + :PrettierCliPath +< +You can check what is the resolved `prettier` cli version by: +> + :PrettierCliVersion +< ============================================================================== CONFIGURATION *vim-prettier-configuration* diff --git a/plugin/prettier.vim b/plugin/prettier.vim index 7688063..c985f7d 100644 --- a/plugin/prettier.vim +++ b/plugin/prettier.vim @@ -63,9 +63,25 @@ command! -nargs=? -range=% Prettier call prettier#Prettier(g:prettier#exec_cmd_a " prettier async command! -nargs=? -range=% PrettierAsync call prettier#Prettier(1, <line1>, <line2>) +" prints vim-prettier version +command! -nargs=? -range=% PrettierVersion echom "0.1.0" + +" call prettier cli +command! -nargs=? -range=% PrettierCli call prettier#PrettierCli(<q-args>) + +" call prettier cli to get its version +command! -nargs=? -range=% PrettierCliVersion call prettier#PrettierCli('--version') + +" prints prettier resolved cli path +command! -nargs=? -range=% PrettierCliPath call prettier#PrettierCliPath() + " map command if !hasmapto('<Plug>(Prettier)') && maparg('<Leader>p', 'n') ==# '' nmap <unique> <Leader>p <Plug>(Prettier) endif nnoremap <silent> <Plug>(Prettier) :Prettier<CR> nnoremap <silent> <Plug>(PrettierAsync) :PrettierAsync<CR> +nnoremap <silent> <Plug>(PrettierVersion) :PrettierVersion<CR> +nnoremap <silent> <Plug>(PrettierCli) :PrettierCli<CR> +nnoremap <silent> <Plug>(PrettierCliVersion) :PrettierCliVersion<CR> +nnoremap <silent> <Plug>(PrettierCliPath) :PrettierCliPath<CR> |
