From 2b0f967b7704dcc782aebc99ec79482c20b5feef Mon Sep 17 00:00:00 2001 From: brianhuster Date: Sat, 1 Mar 2025 01:27:40 +0700 Subject: vim-patch:00a00f5: runtime(lua): Update lua ftplugin and documentation Problem: - The doc says the default `g:lua_subversion` is 2, but in fact it is 3 (see `runtime/syntax/lua.vim`) - `includeexpr` doesn't work with module in `init.lua` Solution: - Update documentation - Assign value to option `&include` - Add function `LuaInclude` and assign it to `l:&includeexpr` closes: vim/vim#16655 https://github.com/vim/vim/commit/00a00f5d3fc8dcf08e959c207a90f5902abc6a08 Co-authored-by: brianhuster Co-authored-by: dkearns --- runtime/doc/filetype.txt | 11 +++++++++++ runtime/doc/syntax.txt | 10 +++------- runtime/ftplugin/lua.vim | 41 ++++++++++++++++++++++++++++++++++------- runtime/syntax/lua.vim | 3 ++- 4 files changed, 50 insertions(+), 15 deletions(-) diff --git a/runtime/doc/filetype.txt b/runtime/doc/filetype.txt index b3fe13bfbd..f1d287b1bb 100644 --- a/runtime/doc/filetype.txt +++ b/runtime/doc/filetype.txt @@ -695,7 +695,18 @@ To enable the recognition of Markdown comments each time after removing re-source "javaformat.vim" for Vim versions greater than `8.2.1397`: > runtime autoload/javaformat.vim < +LUA *ft-lua-plugin* + *g:lua_version* *g:lua_subversion* +Lua filetype's 'includeexpr' and |ft-lua-syntax| highlighting use the global +variables "g:lua_version" and "g:lua_subversion" to determine the version of +Lua to use (5.3 is the default) + +For example, to use Lua 5.1, set the variables like this: > + + let g:lua_version = 5 + let g:lua_subversion = 1 +< MAIL *ft-mail-plugin* Options: diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt index 75d6d85183..3a19ee55c3 100644 --- a/runtime/doc/syntax.txt +++ b/runtime/doc/syntax.txt @@ -1870,13 +1870,9 @@ instead, and the name of your source file should be `*.pike` LUA *lua.vim* *ft-lua-syntax* -The Lua syntax file can be used for versions 4.0, 5.0, 5.1 and 5.2 (5.2 is -the default). You can select one of these versions using the global variables -lua_version and lua_subversion. For example, to activate Lua -5.1 syntax highlighting, set the variables like this: > - - :let lua_version = 5 - :let lua_subversion = 1 +The Lua syntax file can be used for versions 4.0, 5.0+. You can select one of +these versions using the global variables |g:lua_version| and +|g:lua_subversion|. MAIL *mail.vim* *ft-mail.vim* diff --git a/runtime/ftplugin/lua.vim b/runtime/ftplugin/lua.vim index 80cbba78a2..914e7ab6db 100644 --- a/runtime/ftplugin/lua.vim +++ b/runtime/ftplugin/lua.vim @@ -4,14 +4,24 @@ " Previous Maintainer: Max Ischenko " Contributor: Dorai Sitaram " C.D. MacEachern -" Tyler Miller -" Last Change: 2024 Jan 14 +" Phạm Bình An +" Last Change: 2025 Feb 25 if exists("b:did_ftplugin") finish endif let b:did_ftplugin = 1 +" keep in sync with syntax/lua.vim +if !exists("lua_version") + " Default is lua 5.3 + let lua_version = 5 + let lua_subversion = 3 +elseif !exists("lua_subversion") + " lua_version exists, but lua_subversion doesn't. In this case set it to 0 + let lua_subversion = 0 +endif + let s:cpo_save = &cpo set cpo&vim @@ -21,11 +31,11 @@ setlocal formatoptions-=t formatoptions+=croql let &l:define = '\= 5.03 ? [ fname.'.lua', fname.'/init.lua' ] : [ fname.'.lua' ] + for path in paths + if filereadable(path) + return path + endif + endfor + return fname +endfunction " vim: nowrap sw=2 sts=2 ts=8 noet: diff --git a/runtime/syntax/lua.vim b/runtime/syntax/lua.vim index 9c5a490582..f5851d024f 100644 --- a/runtime/syntax/lua.vim +++ b/runtime/syntax/lua.vim @@ -2,7 +2,7 @@ " Language: Lua 4.0, Lua 5.0, Lua 5.1, Lua 5.2 and Lua 5.3 " Maintainer: Marcus Aurelius Farias " First Author: Carlos Augusto Teixeira Mendes -" Last Change: 2022 Sep 07 +" Last Change: 2025 Feb 25 " Options: lua_version = 4 or 5 " lua_subversion = 0 (for 4.0 or 5.0) " or 1, 2, 3 (for 5.1, 5.2 or 5.3) @@ -16,6 +16,7 @@ endif let s:cpo_save = &cpo set cpo&vim +" keep in sync with ftplugin/lua.vim if !exists("lua_version") " Default is lua 5.3 let lua_version = 5 -- cgit