From 79b92da0d289d1adcd0bb27c7ee5786be460c166 Mon Sep 17 00:00:00 2001 From: Christian Clason Date: Mon, 31 Jan 2022 15:27:01 +0100 Subject: vim-patch:partial:f10911e5db16 (#17248) Update runtime files https://github.com/vim/vim/commit/f10911e5db16f1fe6ab519c5d091ad0c1df0d063 --- runtime/autoload/dist/ft.vim | 2 +- runtime/autoload/freebasic.vim | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 runtime/autoload/freebasic.vim (limited to 'runtime/autoload') diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim index 86c71fa52d..f6ef9be891 100644 --- a/runtime/autoload/dist/ft.vim +++ b/runtime/autoload/dist/ft.vim @@ -1,7 +1,7 @@ " Vim functions for file type detection " " Maintainer: Bram Moolenaar -" Last Change: 2022 Jan 11 +" Last Change: 2022 Jan 28 " These functions are moved here from runtime/filetype.vim to make startup " faster. diff --git a/runtime/autoload/freebasic.vim b/runtime/autoload/freebasic.vim new file mode 100644 index 0000000000..fe6d2745be --- /dev/null +++ b/runtime/autoload/freebasic.vim @@ -0,0 +1,42 @@ +" Vim filetype plugin file +" Language: FreeBASIC +" Maintainer: Doug Kearns +" Last Change: 2021 Mar 16 + +" Dialects can be one of fb, qb, fblite, or deprecated +" Precedence is forcelang > #lang > lang +function! freebasic#GetDialect() abort + if exists("g:freebasic_forcelang") + return g:freebasic_forcelang + endif + + if exists("g:freebasic_lang") + let dialect = g:freebasic_lang + else + let dialect = "fb" + endif + + " override with #lang directive or metacommand + + let skip = "has('syntax_items') && synIDattr(synID(line('.'), col('.'), 1), 'name') =~ 'Comment$'" + let pat = '\c^\s*\%(#\s*lang\s\+\|''\s*$lang\s*:\s*\)"\([^"]*\)"' + + let save_cursor = getcurpos() + call cursor(1, 1) + " let lnum = search(pat, 'n', '', '', skip) " 'skip' needs 8.2.0915 + let lnum = search(pat, 'n', '', '') + call setpos('.', save_cursor) + + if lnum + let word = matchlist(getline(lnum), pat)[1] + if word =~? '\%(fb\|deprecated\|fblite\|qb\)' + let dialect = word + else + echomsg "freebasic#GetDialect: Invalid lang, found '" .. word .. "' at line " .. lnum .. " " .. getline(lnum) + endif + endif + + return dialect +endfunction + +" vim: nowrap sw=2 sts=2 ts=8 noet fdm=marker: -- cgit