From 1eb9624666a8478d66e693c7f00fc633a6b1b8ca Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Wed, 29 Jun 2022 18:43:56 +0200 Subject: vim-patch:9.0.0006: not all Visual Basic files are recognized (#19153) Problem: Not all Visual Basic files are recognized. Solution: Change detection of *.cls files. (Doug Kearns) https://github.com/vim/vim/commit/8b5901e2f9466eb6f38f5b251e871f609f65e252 --- runtime/lua/vim/filetype/detect.lua | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'runtime/lua/vim') diff --git a/runtime/lua/vim/filetype/detect.lua b/runtime/lua/vim/filetype/detect.lua index ddef27a0f0..342f947524 100644 --- a/runtime/lua/vim/filetype/detect.lua +++ b/runtime/lua/vim/filetype/detect.lua @@ -83,19 +83,19 @@ function M.bas(bufnr) local fb_keywords = [[\c^\s*\%(extern\|var\|enum\|private\|scope\|union\|byref\|operator\|constructor\|delete\|namespace\|public\|property\|with\|destructor\|using\)\>\%(\s*[:=(]\)\@!]] local fb_preproc = - [[\c^\s*\%(#\a\+\|option\s\+\%(byval\|dynamic\|escape\|\%(no\)\=gosub\|nokeyword\|private\|static\)\>\)]] + [[\c^\s*\%(#\s*\a\+\|option\s\+\%(byval\|dynamic\|escape\|\%(no\)\=gosub\|nokeyword\|private\|static\)\>\|\%(''\|rem\)\s*\$lang\>\|def\%(byte\|longint\|short\|ubyte\|uint\|ulongint\|ushort\)\>\)]] local fb_comment = "^%s*/'" -- OPTION EXPLICIT, without the leading underscore, is common to many dialects local qb64_preproc = [[\c^\s*\%($\a\+\|option\s\+\%(_explicit\|_\=explicitarray\)\>\)]] for _, line in ipairs(getlines(bufnr, 1, 100)) do - if line:find(fb_comment) or matchregex(line, fb_preproc) or matchregex(line, fb_keywords) then + if findany(line:lower(), visual_basic_content) then + return 'vb' + elseif line:find(fb_comment) or matchregex(line, fb_preproc) or matchregex(line, fb_keywords) then return 'freebasic' elseif matchregex(line, qb64_preproc) then return 'qb64' - elseif findany(line:lower(), visual_basic_content) then - return 'vb' end end return 'basic' @@ -172,11 +172,16 @@ function M.class(bufnr) end function M.cls(bufnr) + if vim.g.filetype_cls then + return vim.g.filetype_cls + end local line = getlines(bufnr, 1) if line:find('^%%') then return 'tex' elseif line:find('^#') and line:lower():find('rexx') then return 'rexx' + elseif line == 'VERSION 1.0 CLASS' then + return 'vb' else return 'st' end -- cgit