diff --git a/doc/surround.txt b/doc/surround.txt index f39efb2..40c583f 100644 --- a/doc/surround.txt +++ b/doc/surround.txt @@ -148,6 +148,12 @@ function name inside the parentheses. If s is used, a leading but not trailing space is added. This is useful for removing parentheses from a function call with csbs. +If you prefer entering function name inside the buffer (possibly with a help +from lsp completion). You can enable this behaviour with an option. +> + let g:surround_insert_func_name_interactivly = "1" +< + CUSTOMIZING *surround-customizing* The following adds a potential replacement on "-" (ASCII 45) in PHP files. diff --git a/plugin/surround.vim b/plugin/surround.vim index 8a4016e..de4136c 100644 --- a/plugin/surround.vim +++ b/plugin/surround.vim @@ -221,15 +221,25 @@ function! s:wrap(string,char,type,removed,special) let after = '\end'.matchstr(env,'[^}]*').'}' endif elseif newchar ==# 'f' || newchar ==# 'F' - let fnc = input('function: ') - if fnc != "" - let s:input = fnc."\" - let before = substitute(fnc,'($','','').'(' + if !exists("g:surround_insert_func_name_interactivly") + let fnc = input('function: ') + if fnc != "" + let s:input = fnc."\" + let before = substitute(fnc,'($','','').'(' + let after = ')' + if newchar ==# 'F' + let before .= ' ' + let after = ' ' . after + endif + endif + else + let before = '(' let after = ')' if newchar ==# 'F' let before .= ' ' let after = ' ' . after endif + startinsert endif elseif newchar ==# "\" let fnc = input('function: ')