Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
56 lines (53 sloc) 1.3 KB
--- /usr/share/vim/vim72/filetype.vim 2009-03-19 15:31:04.000000000 +0000
+++ filetype.vim 2009-09-02 16:15:52.882028816 +0000
@@ -1275,7 +1275,7 @@
if l =~ '\<prolog\>' || l =~ '^\s*\(%\+\(\s\|$\)\|/\*\)' || l =~ ':-'
setf prolog
else
- setf perl
+ call s:FTperl5or6()
endif
endif
endfunc
@@ -1287,7 +1287,7 @@
\ elseif getline(1) =~ "XPM" |
\ setf xpm |
\ else |
- \ setf perl |
+ \ call s:FTperl5or6() |
\ endif
" Perl POD
@@ -1923,20 +1923,31 @@
" a Perl file.
func! s:FTperl()
if expand("%:e") == 't' && expand("%:p:h:t") == 't'
- setf perl
+ call s:FTperl5or6()
return 1
endif
if getline(1)[0] == '#' && getline(1) =~ 'perl'
- setf perl
+ call s:FTperl5or6()
return 1
endif
if search('^use\s\s*\k', 'nc', 30)
- setf perl
+ call s:FTperl5or6()
return 1
endif
return 0
endfunc
+" If the first line of code starts with "use v6", "grammar", "module",
+" "class", or "role" then it's Perl 6, otherwise it's Perl 5
+func! s:FTperl5or6()
+ if search('^\s*\%(use\s*v6\|\%(grammar\|module\|class\|role\)\>\)', 'nc', 30)
+ setf perl6
+ return 1
+ endif
+ setf perl
+ return 1
+endfunc
+
" Tads (or Nroff or Perl test file)
au BufNewFile,BufRead *.t
\ if !s:FTnroff() && !s:FTperl() | setf tads | endif
Something went wrong with that request. Please try again.