From d39b7b014de553e142b8c619892a2ac1110186ed Mon Sep 17 00:00:00 2001 From: Kien N Date: Thu, 19 Apr 2012 16:38:52 +0700 Subject: [PATCH] Insert filename under the cursor (like gf) --- autoload/ctrlp.vim | 11 +++++++---- doc/ctrlp.txt | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim index 88f955a..0f0bb7d 100644 --- a/autoload/ctrlp.vim +++ b/autoload/ctrlp.vim @@ -93,6 +93,7 @@ fu! s:opts() \ 'PrtInsert("s")': [''], \ 'PrtInsert("v")': [''], \ 'PrtInsert("+")': ['', ''], + \ 'PrtInsert("gf")': [''], \ 'PrtCurStart()': [''], \ 'PrtCurEnd()': [''], \ 'PrtCurLeft()': ['', '', ''], @@ -150,6 +151,7 @@ let s:prtunmaps = [ \ 'PrtInsert("s")', \ 'PrtInsert("v")', \ 'PrtInsert("+")', + \ 'PrtInsert("gf")', \ ] " Keypad @@ -466,7 +468,7 @@ endf " - SetDefTxt() {{{1 fu! s:SetDefTxt() if s:deftxt == '0' || !s:ispath | retu | en - let txt = s:deftxt + let txt = expand(s:deftxt, 1) if !type(txt) let txt = txt && !stridx(s:crfpath, s:dyncwd) \ ? ctrlp#rmbasedir([s:crfpath])[0] : '' @@ -521,7 +523,8 @@ fu! s:PrtInsert(type) let s:prompt[0] .= a:type == 'w' ? s:crword \ : a:type == 's' ? getreg('/') \ : a:type == 'v' ? s:crvisual - \ : a:type == '+' ? substitute(getreg('+'), '\n', '\\n', 'g') : s:prompt[0] + \ : a:type == '+' ? substitute(getreg('+'), '\n', '\\n', 'g') + \ : a:type == 'gf' ? s:crgfile : s:prompt[0] cal s:BuildPrompt(1) unl s:act_add endf @@ -1490,13 +1493,13 @@ endf fu! s:getenv() let [s:cwd, s:winres] = [getcwd(), [winrestcmd(), &lines, winnr('$')]] let [s:crfile, s:crfpath] = [expand('%:p', 1), expand('%:p:h', 1)] - let [s:crword, s:crline] = [expand(''), getline('.')] + let [s:crword, s:crline] = [expand('', 1), getline('.')] let [s:winh, s:crcursor] = [min([s:mxheight, &lines]), getpos('.')] let [s:crbufnr, s:crvisual] = [bufnr('%'), s:lastvisual()] let s:currwin = s:mwbottom ? winnr() : winnr() + has('autocmd') let s:wpmode = exists('b:ctrlp_working_path_mode') \ ? b:ctrlp_working_path_mode : s:pathmode - let s:mrbs = ctrlp#mrufiles#bufs() + let [s:mrbs, s:crgfile] = [ctrlp#mrufiles#bufs(), expand('', 1)] endf fu! s:lastvisual() diff --git a/doc/ctrlp.txt b/doc/ctrlp.txt index 6560364..08e5799 100644 --- a/doc/ctrlp.txt +++ b/doc/ctrlp.txt @@ -372,6 +372,7 @@ only need to keep the lines that you’ve changed the values (inside []): > \ 'PrtInsert("s")': [''], \ 'PrtInsert("v")': [''], \ 'PrtInsert("+")': ['', ''], + \ 'PrtInsert("gf")': [''], \ 'PrtCurStart()': [''], \ 'PrtCurEnd()': [''], \ 'PrtCurLeft()': ['', '', ''],