aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--autoload/ctrlp.vim13
-rw-r--r--doc/ctrlp.txt8
2 files changed, 20 insertions, 1 deletions
diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim
index c5d721e..b101694 100644
--- a/autoload/ctrlp.vim
+++ b/autoload/ctrlp.vim
@@ -80,6 +80,7 @@ let [s:pref, s:bpref, s:opts, s:new_opts, s:lc_opts] =
\ 'open_func': ['s:openfunc', {}],
\ 'open_multi': ['s:opmul', '1v'],
\ 'open_new_file': ['s:newfop', 'v'],
+ \ 'create_func': ['s:createfunc', {}],
\ 'prompt_mappings': ['s:urprtmaps', 0],
\ 'regexp_search': ['s:regexp', 0],
\ 'root_markers': ['s:rmarkers', []],
@@ -1224,7 +1225,7 @@ fu! s:CreateNewFile(...)
let md = s:argmaps(md, 1)
if md == 'cancel' | retu | en
en
- let str = s:sanstail(str)
+ let [inp, str] = [str, s:sanstail(str)]
let [base, fname] = s:headntail(str)
if fname =~ '^[\/]$' | retu | en
if exists('s:marked') && len(s:marked)
@@ -1237,9 +1238,19 @@ fu! s:CreateNewFile(...)
let optyp = str | en | el | let optyp = fname
en
if !exists('optyp') | retu | en
+
+ if s:createfunc != {} && has_key(s:createfunc, s:ctype)
+ let type = has_key(s:createfunc, 'arg_type') ? s:createfunc['arg_type'] : 'dict'
+ let argms = type == 'dict' ? [{ 'action': md, 'line': inp }]
+ \ : [md, inp]
+ cal s:PrtExit()
+ cal call(s:createfunc[s:ctype], argms, s:createfunc) | retu
+ en
+
let [filpath, tail] = [fnamemodify(optyp, ':p'), s:tail()]
if !stridx(filpath, s:dyncwd) | cal s:insertcache(str) | en
cal s:PrtExit()
+
let cmd = md == 'r' ? ctrlp#normcmd('e') :
\ s:newfop =~ '1\|t' || ( a:0 && a:1 == 't' ) || md == 't' ? 'tabe' :
\ s:newfop =~ '2\|h' || ( a:0 && a:1 == 'h' ) || md == 'h' ? 'new' :
diff --git a/doc/ctrlp.txt b/doc/ctrlp.txt
index 4090e83..4ac46e0 100644
--- a/doc/ctrlp.txt
+++ b/doc/ctrlp.txt
@@ -94,6 +94,7 @@ Overview:~
|ctrlp_status_func|...........Change CtrlP's two statuslines.
|ctrlp_buffer_func|...........Call custom functions in the CtrlP buffer.
|ctrlp_match_func|............Replace the built-in matching algorithm.
+ |ctrlp_create_func|...........Use custom file creating functions.
-------------------------------------------------------------------------------
Detailed descriptions and default values:~
@@ -846,6 +847,13 @@ Example: >
*'g:ctrlp_brief_prompt'*
When this is set to 1, the <bs> on empty prompt exit CtrlP.
+ *'g:ctrlp_create_func'*
+Define a custom function to create the selected file. This is same as
+|ctrlp_open_func|. This function passes string entered by the user as it is.
+And not record to cache file. So you can create function to open URL with
+browser: >
+ let g:ctrlp_create_func = {}
+<
*ctrlp-default-value*
Otherwise, you can use below to change default value.
Example: >