aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrianhuster <phambinhanctb2004@gmail.com>2025-03-01 01:41:32 +0700
committerzeertzjq <zeertzjq@outlook.com>2025-03-02 06:46:26 +0800
commit47b748af5465201cfba710efb9ca695d2b19304b (patch)
treebb01208baaa8964b2636834490a48e30fc5fd889
parent2b0f967b7704dcc782aebc99ec79482c20b5feef (diff)
downloadrneovim-47b748af5465201cfba710efb9ca695d2b19304b.tar.gz
rneovim-47b748af5465201cfba710efb9ca695d2b19304b.tar.bz2
rneovim-47b748af5465201cfba710efb9ca695d2b19304b.zip
vim-patch:0b82054: runtime(lua): Improve 'include' and make '*expr' functions script-local
- Prevent 'include' from matching variable assignments as calls to require() and others. - Use script-local functions for 'includeexpr' and 'foldexpr'. - Formatting fixes. closes: vim/vim#16746 https://github.com/vim/vim/commit/0b8205484b703b4a5a569cd1b0ed876bbb13901f Co-authored-by: Doug Kearns <dougkearns@gmail.com>
-rw-r--r--runtime/ftplugin/lua.vim12
1 files changed, 6 insertions, 6 deletions
diff --git a/runtime/ftplugin/lua.vim b/runtime/ftplugin/lua.vim
index 914e7ab6db..57c5887a86 100644
--- a/runtime/ftplugin/lua.vim
+++ b/runtime/ftplugin/lua.vim
@@ -5,7 +5,7 @@
" Contributor: Dorai Sitaram <ds26@gte.com>
" C.D. MacEachern <craig.daniel.maceachern@gmail.com>
" Phạm Bình An <phambinhanctb2004@gmail.com>
-" Last Change: 2025 Feb 25
+" Last Change: 2025 Feb 27
if exists("b:did_ftplugin")
finish
@@ -31,11 +31,11 @@ setlocal formatoptions-=t formatoptions+=croql
let &l:define = '\<function\|\<local\%(\s\+function\)\='
-let &l:include = '\v<((do|load)file|require)[^''"]*[''"]\zs[^''"]+'
-setlocal includeexpr=LuaInclude(v:fname)
+let &l:include = '\<\%(\%(do\|load\)file\|require\)\s*('
+setlocal includeexpr=s:LuaInclude(v:fname)
setlocal suffixesadd=.lua
-let b:undo_ftplugin = "setlocal cms< com< def< fo< inc< inex< sua<"
+let b:undo_ftplugin = "setl cms< com< def< fo< inc< inex< sua<"
if exists("loaded_matchit") && !exists("b:match_words")
let b:match_ignorecase = 0
@@ -66,10 +66,10 @@ if exists("s:loaded_lua") || &cp
endif
let s:loaded_lua = 1
-function LuaInclude(fname) abort
+function s:LuaInclude(fname) abort
let lua_ver = str2float(printf("%d.%02d", g:lua_version, g:lua_subversion))
let fname = tr(a:fname, '.', '/')
- let paths = lua_ver >= 5.03 ? [ fname.'.lua', fname.'/init.lua' ] : [ fname.'.lua' ]
+ let paths = lua_ver >= 5.03 ? [fname .. ".lua", fname .. "/init.lua"] : [fname .. ".lua"]
for path in paths
if filereadable(path)
return path