aboutsummaryrefslogtreecommitdiff
path: root/runtime/autoload
diff options
context:
space:
mode:
authorChristian Clason <c.clason@uni-graz.at>2022-01-21 16:45:32 +0100
committerGitHub <noreply@github.com>2022-01-21 16:45:32 +0100
commit9d02fc4c00f61724610224f91950c51bd2700c97 (patch)
tree668058cd83c4d76c59717ca04b1a6e0c6d5fb0ee /runtime/autoload
parentc977d8b43cd6ecf7ad756f9b064eadea79fbd604 (diff)
downloadrneovim-9d02fc4c00f61724610224f91950c51bd2700c97.tar.gz
rneovim-9d02fc4c00f61724610224f91950c51bd2700c97.tar.bz2
rneovim-9d02fc4c00f61724610224f91950c51bd2700c97.zip
vim-patch:8.2.4172: filetype detection for BASIC is not optimal (#17161)
Problem: Filetype detection for BASIC is not optimal. Solution: Improve BASIC filetype detection. (Doug Kearns) https://github.com/vim/vim/commit/6517f14165cdebf83a07ab9d4aeeb102b4e16e92
Diffstat (limited to 'runtime/autoload')
-rw-r--r--runtime/autoload/dist/ft.vim26
1 files changed, 21 insertions, 5 deletions
diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim
index 0d6841a35b..69712046a5 100644
--- a/runtime/autoload/dist/ft.vim
+++ b/runtime/autoload/dist/ft.vim
@@ -67,13 +67,29 @@ func dist#ft#FTasmsyntax()
endif
endfunc
-" Check if one of the first five lines contains "VB_Name". In that case it is
-" probably a Visual Basic file. Otherwise it's assumed to be "alt" filetype.
-func dist#ft#FTVB(alt)
- if getline(1).getline(2).getline(3).getline(4).getline(5) =~? 'VB_Name\|Begin VB\.\(Form\|MDIForm\|UserControl\)'
+func dist#ft#FTbas()
+ if exists("g:filetype_bas")
+ exe "setf " . g:filetype_bas
+ return
+ endif
+
+ " most frequent FreeBASIC-specific keywords in distro files
+ let fb_keywords = '\c^\s*\%(extern\|var\|enum\|private\|scope\|union\|byref\|operator\|constructor\|delete\|namespace\|public\|property\|with\|destructor\|using\)\>\%(\s*[:=(]\)\@!'
+ let fb_preproc = '\c^\s*\%(#\a\+\|option\s\+\%(byval\|dynamic\|escape\|\%(no\)\=gosub\|nokeyword\|private\|static\)\>\)'
+ let fb_comment = "^\\s*/'"
+ " OPTION EXPLICIT, without the leading underscore, is common to many dialects
+ let qb64_preproc = '\c^\s*\%($\a\+\|option\s\+\%(_explicit\|_\=explicitarray\)\>\)'
+
+ let lines = getline(1, min([line("$"), 100]))
+
+ if match(lines, fb_preproc) > -1 || match(lines, fb_comment) > -1 || match(lines, fb_keywords) > -1
+ setf freebasic
+ elseif match(lines, qb64_preproc) > -1
+ setf qb64
+ elseif match(lines, '\cVB_Name\|Begin VB\.\(Form\|MDIForm\|UserControl\)') > -1
setf vb
else
- exe "setf " . a:alt
+ setf basic
endif
endfunc