diff options
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/autoload/dist/ft.vim | 24 | ||||
-rw-r--r-- | runtime/filetype.vim | 2 | ||||
-rw-r--r-- | runtime/lua/vim/filetype.lua | 2 |
3 files changed, 22 insertions, 6 deletions
diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim index f513a2ac8f..5d8734a625 100644 --- a/runtime/autoload/dist/ft.vim +++ b/runtime/autoload/dist/ft.vim @@ -67,7 +67,10 @@ func dist#ft#FTasmsyntax() endif endfunc -func dist#ft#FTbas(alt = '') +let s:ft_visual_basic_content = '\cVB_Name\|Begin VB\.\(Form\|MDIForm\|UserControl\)' + +" See FTfrm() for Visual Basic form file detection +func dist#ft#FTbas() if exists("g:filetype_bas") exe "setf " . g:filetype_bas return @@ -86,10 +89,8 @@ func dist#ft#FTbas(alt = '') setf freebasic elseif match(lines, qb64_preproc) > -1 setf qb64 - elseif match(lines, '\cVB_Name\|Begin VB\.\(Form\|MDIForm\|UserControl\)') > -1 + elseif match(lines, s:ft_visual_basic_content) > -1 setf vb - elseif a:alt != '' - exe 'setf ' .. a:alt else setf basic endif @@ -237,6 +238,21 @@ func dist#ft#FTe() endif endfunc +func dist#ft#FTfrm() + if exists("g:filetype_frm") + exe "setf " . g:filetype_frm + return + endif + + let lines = getline(1, min([line("$"), 5])) + + if match(lines, s:ft_visual_basic_content) > -1 + setf vb + else + setf form + endif +endfunc + " Distinguish between Forth and F#. " Provided by Doug Kearns. func dist#ft#FTfs() diff --git a/runtime/filetype.vim b/runtime/filetype.vim index 7c86809cb8..8b40b43a04 100644 --- a/runtime/filetype.vim +++ b/runtime/filetype.vim @@ -2050,7 +2050,7 @@ au BufRead,BufNewFile *.hw,*.module,*.pkg \ endif " Visual Basic (also uses *.bas) or FORM -au BufNewFile,BufRead *.frm call dist#ft#FTbas('form') +au BufNewFile,BufRead *.frm call dist#ft#FTfrm() " SaxBasic is close to Visual Basic au BufNewFile,BufRead *.sba setf vb diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index ff44f48195..e2cf408f3b 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -789,7 +789,7 @@ local extension = { ex = function() vim.fn["dist#ft#ExCheck"]() end, exu = function() vim.fn["dist#ft#EuphoriaCheck"]() end, exw = function() vim.fn["dist#ft#EuphoriaCheck"]() end, - frm = function() vim.fn["dist#ft#FTbas"]("form") end, + frm = function() vim.fn["dist#ft#FTfrm"]() end, fs = function() vim.fn["dist#ft#FTfs"]() end, h = function() vim.fn["dist#ft#FTheader"]() end, htm = function() vim.fn["dist#ft#FThtml"]() end, |