mirror of
https://github.com/neovim/neovim
synced 2025-07-16 01:01:49 +00:00
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
00a00f5d3f
Co-authored-by: brianhuster <phambinhanctb2004@gmail.com>
Co-authored-by: dkearns <dougkearns@gmail.com>
This commit is contained in:
@ -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`: >
|
re-source "javaformat.vim" for Vim versions greater than `8.2.1397`: >
|
||||||
runtime autoload/javaformat.vim
|
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*
|
MAIL *ft-mail-plugin*
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
|
@ -1870,13 +1870,9 @@ instead, and the name of your source file should be `*.pike`
|
|||||||
|
|
||||||
LUA *lua.vim* *ft-lua-syntax*
|
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 Lua syntax file can be used for versions 4.0, 5.0+. You can select one of
|
||||||
the default). You can select one of these versions using the global variables
|
these versions using the global variables |g:lua_version| and
|
||||||
lua_version and lua_subversion. For example, to activate Lua
|
|g:lua_subversion|.
|
||||||
5.1 syntax highlighting, set the variables like this: >
|
|
||||||
|
|
||||||
:let lua_version = 5
|
|
||||||
:let lua_subversion = 1
|
|
||||||
|
|
||||||
|
|
||||||
MAIL *mail.vim* *ft-mail.vim*
|
MAIL *mail.vim* *ft-mail.vim*
|
||||||
|
@ -4,14 +4,24 @@
|
|||||||
" Previous Maintainer: Max Ischenko <mfi@ukr.net>
|
" Previous Maintainer: Max Ischenko <mfi@ukr.net>
|
||||||
" Contributor: Dorai Sitaram <ds26@gte.com>
|
" Contributor: Dorai Sitaram <ds26@gte.com>
|
||||||
" C.D. MacEachern <craig.daniel.maceachern@gmail.com>
|
" C.D. MacEachern <craig.daniel.maceachern@gmail.com>
|
||||||
" Tyler Miller <tmillr@proton.me>
|
" Phạm Bình An <phambinhanctb2004@gmail.com>
|
||||||
" Last Change: 2024 Jan 14
|
" Last Change: 2025 Feb 25
|
||||||
|
|
||||||
if exists("b:did_ftplugin")
|
if exists("b:did_ftplugin")
|
||||||
finish
|
finish
|
||||||
endif
|
endif
|
||||||
let b:did_ftplugin = 1
|
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
|
let s:cpo_save = &cpo
|
||||||
set cpo&vim
|
set cpo&vim
|
||||||
|
|
||||||
@ -21,11 +31,11 @@ setlocal formatoptions-=t formatoptions+=croql
|
|||||||
|
|
||||||
let &l:define = '\<function\|\<local\%(\s\+function\)\='
|
let &l:define = '\<function\|\<local\%(\s\+function\)\='
|
||||||
|
|
||||||
" TODO: handle init.lua
|
let &l:include = '\v<((do|load)file|require)[^''"]*[''"]\zs[^''"]+'
|
||||||
setlocal includeexpr=tr(v:fname,'.','/')
|
setlocal includeexpr=LuaInclude(v:fname)
|
||||||
setlocal suffixesadd=.lua
|
setlocal suffixesadd=.lua
|
||||||
|
|
||||||
let b:undo_ftplugin = "setlocal cms< com< def< fo< inex< sua<"
|
let b:undo_ftplugin = "setlocal cms< com< def< fo< inc< inex< sua<"
|
||||||
|
|
||||||
if exists("loaded_matchit") && !exists("b:match_words")
|
if exists("loaded_matchit") && !exists("b:match_words")
|
||||||
let b:match_ignorecase = 0
|
let b:match_ignorecase = 0
|
||||||
@ -48,7 +58,24 @@ if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
|
|||||||
let b:undo_ftplugin ..= " | unlet! b:browsefilter"
|
let b:undo_ftplugin ..= " | unlet! b:browsefilter"
|
||||||
endif
|
endif
|
||||||
|
|
||||||
let &cpo = s:cpo_save
|
" The rest of the file needs to be :sourced only once per Vim session
|
||||||
unlet s:cpo_save
|
if exists("s:loaded_lua") || &cp
|
||||||
|
let &cpo = s:cpo_save
|
||||||
|
unlet s:cpo_save
|
||||||
|
finish
|
||||||
|
endif
|
||||||
|
let s:loaded_lua = 1
|
||||||
|
|
||||||
|
function 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' ]
|
||||||
|
for path in paths
|
||||||
|
if filereadable(path)
|
||||||
|
return path
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
return fname
|
||||||
|
endfunction
|
||||||
|
|
||||||
" vim: nowrap sw=2 sts=2 ts=8 noet:
|
" vim: nowrap sw=2 sts=2 ts=8 noet:
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
" Language: Lua 4.0, Lua 5.0, Lua 5.1, Lua 5.2 and Lua 5.3
|
" Language: Lua 4.0, Lua 5.0, Lua 5.1, Lua 5.2 and Lua 5.3
|
||||||
" Maintainer: Marcus Aurelius Farias <masserahguard-lua 'at' yahoo com>
|
" Maintainer: Marcus Aurelius Farias <masserahguard-lua 'at' yahoo com>
|
||||||
" First Author: Carlos Augusto Teixeira Mendes <cmendes 'at' inf puc-rio br>
|
" First Author: Carlos Augusto Teixeira Mendes <cmendes 'at' inf puc-rio br>
|
||||||
" Last Change: 2022 Sep 07
|
" Last Change: 2025 Feb 25
|
||||||
" Options: lua_version = 4 or 5
|
" Options: lua_version = 4 or 5
|
||||||
" lua_subversion = 0 (for 4.0 or 5.0)
|
" lua_subversion = 0 (for 4.0 or 5.0)
|
||||||
" or 1, 2, 3 (for 5.1, 5.2 or 5.3)
|
" or 1, 2, 3 (for 5.1, 5.2 or 5.3)
|
||||||
@ -16,6 +16,7 @@ endif
|
|||||||
let s:cpo_save = &cpo
|
let s:cpo_save = &cpo
|
||||||
set cpo&vim
|
set cpo&vim
|
||||||
|
|
||||||
|
" keep in sync with ftplugin/lua.vim
|
||||||
if !exists("lua_version")
|
if !exists("lua_version")
|
||||||
" Default is lua 5.3
|
" Default is lua 5.3
|
||||||
let lua_version = 5
|
let lua_version = 5
|
||||||
|
Reference in New Issue
Block a user