robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

zeertzjqvim-patch:98bf999: runtime(lua): Update ftplugin, fix matchit block comment pattern (#40349)131f9f73ac

master
2.4 KiB88 linesraw
1" Vim filetype plugin file.
2
3" Language:		Lua
4" Maintainer:		Doug Kearns <dougkearns@gmail.com>
5" Previous Maintainer:	Max Ischenko <mfi@ukr.net>
6" Contributor:		Dorai Sitaram <ds26@gte.com>
7"			C.D. MacEachern <craig.daniel.maceachern@gmail.com>
8"			Tyler Miller <tmillr@proton.me>
9"			Phạm Bình An <phambinhanctb2004@gmail.com>
10"			@konfekt
11" Last Change:		2026 Jun 20
12
13if exists("b:did_ftplugin")
14  finish
15endif
16let b:did_ftplugin = 1
17
18" keep in sync with syntax/lua.vim
19if !exists("lua_version")
20  " Default is lua 5.3
21  let lua_version = 5
22  let lua_subversion = 3
23elseif !exists("lua_subversion")
24  " lua_version exists, but lua_subversion doesn't. In this case set it to 0
25  let lua_subversion = 0
26endif
27
28let s:cpo_save = &cpo
29set cpo&vim
30
31setlocal comments=:---,:--
32setlocal commentstring=--\ %s
33setlocal formatoptions-=t formatoptions+=croql
34setlocal path-=. " Lua doesn't support importing module in path related to current file like JS
35
36let &l:define = '\<function\|\<local\%(\s\+function\)\='
37
38let &l:include = '\<\%(\%(do\|load\)file\|require\)\s*('
39setlocal includeexpr=s:LuaInclude(v:fname)
40setlocal suffixesadd=.lua
41
42let b:undo_ftplugin = "setl cms< com< def< fo< inc< inex< sua< pa<"
43
44if exists("loaded_matchit") && !exists("b:match_words")
45  let b:match_ignorecase = 0
46  let b:match_words =
47	\ '\<\%(do\|function\|if\)\>:' ..
48	\ '\<\%(return\|else\|elseif\)\>:' ..
49	\ '\<end\>,' ..
50	\ '\<repeat\>:\<until\>,' ..
51	\ '--\[\(=*\)\[:\%(--\)\=]\1]'
52  let b:undo_ftplugin ..= " | unlet! b:match_words b:match_ignorecase"
53endif
54
55if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
56  let b:browsefilter = "Lua Source Files (*.lua)\t*.lua\n"
57  if has("win32")
58    let b:browsefilter ..= "All Files (*.*)\t*\n"
59  else
60    let b:browsefilter ..= "All Files (*)\t*\n"
61  endif
62  let b:undo_ftplugin ..= " | unlet! b:browsefilter"
63endif
64
65" The rest of the file needs to be :sourced only once per Vim session
66if exists("s:loaded_lua") || &cp
67  let &cpo = s:cpo_save
68  unlet s:cpo_save
69  finish
70endif
71let s:loaded_lua = 1
72
73function s:LuaInclude(fname) abort
74  let lua_ver = str2float(printf("%d.%02d", g:lua_version, g:lua_subversion))
75  let fname = tr(a:fname, '.', '/')
76  let paths = lua_ver >= 5.03 ? [fname .. ".lua", fname .. "/init.lua"] : [fname .. ".lua"]
77  for path in paths
78    if filereadable(path)
79      return path
80    endif
81  endfor
82  return fname
83endfunction
84
85let &cpo = s:cpo_save
86unlet s:cpo_save
87
88" vim: nowrap sw=2 sts=2 ts=8 noet: