From 79c5971c82d44ff40067677236fa3d8880a218be Mon Sep 17 00:00:00 2001 From: nilsboy Date: Wed, 6 May 2020 19:52:30 +0200 Subject: [PATCH 1/2] add option vrc_show_command_in_quickfix and vrc_show_command_in_result_buffer --- doc/vim-rest-console.txt | 17 +++++++++++++++++ ftplugin/rest.vim | 19 +++++++++++++++---- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/doc/vim-rest-console.txt b/doc/vim-rest-console.txt index 0b11483..bdf7f15 100644 --- a/doc/vim-rest-console.txt +++ b/doc/vim-rest-console.txt @@ -39,6 +39,8 @@ CONTENTS *VrcContents* vrc_response_default_content_type.. |vrc_response_default_content_type| vrc_set_default_mapping...................... |vrc_set_default_mapping| vrc_show_command.....................................|vrc_show_command| + vrc_show_command_in_quickfix.............|vrc_show_command_in_quickfix| + vrc_show_command_in_result_buffer...|vrc_show_command_in_result_buffer| vrc_split_request_body........................ |vrc_split_request_body| vrc_syntax_highlight_response...........|vrc_syntax_highlight_response| vrc_trigger.............................................. |vrc_trigger| @@ -576,6 +578,21 @@ pane. It's disabled by default. To enable: let g:vrc_show_command = 1 < ------------------------------------------------------------------------------ +*vrc_show_command_in_quickfix* + +This option disables the printing of the executed curl command in the quickfix +list. It's enabled by default. To disable: +> + let g:vrc_show_command_in_quickfix = 0 + +------------------------------------------------------------------------------ +*vrc_show_command_in_result_buffer* + +This option enables the printing of the executed curl command in the output +pane. It's disabled by default. To enable: +> + let g:vrc_show_command_in_result_buffer = 1 +------------------------------------------------------------------------------ *vrc_split_request_body* Determine if the request body should be processed line by line. Default: 0. diff --git a/ftplugin/rest.vim b/ftplugin/rest.vim index 7decc96..02e0504 100644 --- a/ftplugin/rest.vim +++ b/ftplugin/rest.vim @@ -640,10 +640,12 @@ function! s:DisplayOutput(tmpBufName, outputInfo, config) call setline('.', split(substitute(output, '[[:return:]]', '', 'g'), '\v\n')) """ Display commands in quickfix window if any. - if (!empty(a:outputInfo['commands'])) - execute 'cgetexpr' string(a:outputInfo['commands']) - copen - execute outputWin 'wincmd w' + if s:GetOpt('vrc_show_command_in_quickfix', 1) + if (!empty(a:outputInfo['commands'])) + execute 'cgetexpr' string(a:outputInfo['commands']) + copen + execute outputWin 'wincmd w' + endif endif """ Detect content-type based on the returned header. @@ -705,6 +707,15 @@ function! s:DisplayOutput(tmpBufName, outputInfo, config) endif endif + """ Display commands in result buffer if any. + if s:GetOpt('vrc_show_command_in_result_buffer', 0) + if (!empty(a:outputInfo['commands'])) + let prefixedList = map(copy(a:outputInfo['commands']), '"REQUEST: " . v:val . "\t"') + call append(0, prefixedList) + call append(1, '') + endif + endif + """ Finalize view. setlocal nomodifiable execute origWin . 'wincmd w' From 308b197d9e5ae97b8c612512faa373d27207e7e8 Mon Sep 17 00:00:00 2001 From: Nils Boysen Date: Thu, 25 Jun 2020 15:30:19 +0200 Subject: [PATCH 2/2] add g:vrc_curl_timeout option --- doc/vim-rest-console.txt | 8 ++++++++ ftplugin/rest.vim | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/doc/vim-rest-console.txt b/doc/vim-rest-console.txt index bdf7f15..ebf68f4 100644 --- a/doc/vim-rest-console.txt +++ b/doc/vim-rest-console.txt @@ -585,6 +585,14 @@ list. It's enabled by default. To disable: > let g:vrc_show_command_in_quickfix = 0 +------------------------------------------------------------------------------ +*vrc_curl_timeout* + +Kill curl after this timeout - default 1m. +See man timeout for details. +> + let g:vrc_curl_timeout = '5s' + ------------------------------------------------------------------------------ *vrc_show_command_in_result_buffer* diff --git a/ftplugin/rest.vim b/ftplugin/rest.vim index 02e0504..c7a803c 100644 --- a/ftplugin/rest.vim +++ b/ftplugin/rest.vim @@ -492,8 +492,9 @@ function! s:GetCurlCommand(request) if !empty(a:request.dataBody) call add(curlArgs, s:GetCurlDataArgs(a:request)) endif + let vrcCurlTimeout = s:GetOpt('vrc_curl_timeout', '1m') return [ - \ 'curl ' . join(curlArgs) . ' ' . s:Shellescape(a:request.host . a:request.requestPath), + \ 'timeout ' . vrcCurlTimeout . ' curl ' . join(curlArgs) . ' ' . s:Shellescape(a:request.host . a:request.requestPath), \ curlOpts \] endfunction