diff --git a/README.md b/README.md index e883760..91589cf 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,10 @@ This is a fork of the popular taglist.vim plugin. Taglist-plus provides excellent Javascript support via jsctags. See [here][1] for examples. +The filetype detection has also been improved: it now supports composed filetypes. +For instance, the _php.symfony_ filetype will be split and only its first part will +be considered. + This plugin can also be obtained through [vim.org][2]. Installation diff --git a/plugin/taglist-plus.vim b/plugin/taglist-plus.vim index 7eac1de..406a7d6 100644 --- a/plugin/taglist-plus.vim +++ b/plugin/taglist-plus.vim @@ -952,6 +952,17 @@ function! s:Tlist_FileType_Init(ftype) return 1 endfunction +" Tlist_Fix_Ftype +" If the filetype is composed (foo.bar), only the part before the dot +" will be returned +function! s:Tlist_Fix_Ftype(raw_ftype) + if match(a:raw_ftype, '\.') + return split(a:raw_ftype, '\.')[0] + else + return a:raw_ftype + endif +endfunction + " Tlist_Detect_Filetype " Determine the filetype for the specified file using the filetypedetect " autocmd. @@ -974,7 +985,7 @@ function! s:Tlist_Detect_Filetype(fname) let &filetype = old_filetype let &eventignore = old_eventignore - return ftype + return s:Tlist_Fix_Ftype(ftype) endfunction " Tlist_Get_Buffer_Filetype @@ -984,12 +995,12 @@ function! s:Tlist_Get_Buffer_Filetype(bnum) if bufloaded(a:bnum) " For loaded buffers, the 'filetype' is already determined - return buf_ft + return s:Tlist_Fix_Ftype(buf_ft) endif " For unloaded buffers, if the 'filetype' option is set, return it if buf_ft != '' - return buf_ft + return s:Tlist_Fix_Ftype(buf_ft) endif " Skip non-existent buffers