Skip to content

Commit

Permalink
Merge pull request ctrlpvim#454 from ctrlpvim/fix-filetype-detection
Browse files Browse the repository at this point in the history
Fix filetype detection mechanism
  • Loading branch information
mattn authored Jun 23, 2018
2 parents e66b5b5 + fd327db commit 6037820
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion autoload/ctrlp.vim
Original file line number Diff line number Diff line change
Expand Up @@ -2595,6 +2595,20 @@ fu! s:ExitIfSingleCandidate()
return 0
endfu

fu! s:IsBuiltin()
let builtins = ['tag', 'dir', 'bft', 'rts', 'bkd', 'lns', 'chs', 'mix', 'udo', 'qfx']
let curtype = s:getextvar('sname')
return s:itemtype < len(s:coretypes) || index(builtins, curtype) > -1
endfu

fu! s:DetectFileType(type, ft)
if s:IsBuiltin() || empty(a:ft)
retu 'ctrlp'
el
retu 'ctrlp.' . a:ft
en
endfu

fu! ctrlp#init(type, ...)
if exists('s:init') || s:iscmdwin() | retu | en
let [s:ermsg, v:errmsg] = [v:errmsg, '']
Expand All @@ -2618,7 +2632,7 @@ fu! ctrlp#init(type, ...)
en
en
cal ctrlp#setlines(s:settype(type))
let &filetype = empty(&filetype) ? 'ctrlp' : 'ctrlp.' . &filetype
let &filetype = s:DetectFileType(type, &filetype)
cal ctrlp#syntax()
cal s:SetDefTxt()
let curName = s:CurTypeName()
Expand Down

0 comments on commit 6037820

Please sign in to comment.