robin/laufey
git clone https://git.robinwobin.dev/robin/laufey
131f9f73ac
master
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" ) 14finish 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 21let lua_version = 5 22let lua_subversion = 3 23elseif ! exists ( "lua_subversion" ) 24" lua_version exists, but lua_subversion doesn't. In this case set it to 0 25let lua_subversion = 0 26endif 27 28let s: cpo_save = & cpo 29set cpo & vim 30 31setlocal comments = :---,:-- 32setlocal commentstring = --\ %s 33setlocal formatoptions -= tformatoptions += 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" ) 45let b: match_ignorecase = 0 46let b: match_words = 47 \'\<\%(do\|function\|if\)\>:' .. 48 \'\<\%(return\|else\|elseif\)\>:' .. 49 \'\<end\>,' .. 50 \'\<repeat\>:\<until\>,' .. 51 \'--\[\(=*\)\[:\%(--\)\=]\1]' 52let b: undo_ftplugin ..= " | unlet! b:match_words b:match_ignorecase" 53endif 54 55if ( has ( "gui_win32" ) || has ( "gui_gtk" )) && ! exists ( "b:browsefilter" ) 56let b: browsefilter = "Lua Source Files (*.lua)\t*.lua\n" 57if has ( "win32" ) 58let b: browsefilter ..= "All Files (*.*)\t*\n" 59else 60let b: browsefilter ..= "All Files (*)\t*\n" 61endif 62let 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 67let & cpo = s: cpo_save 68unlet s: cpo_save 69finish 70endif 71let s: loaded_lua = 1 72 73function s: LuaInclude ( fname ) abort 74let lua_ver = str2float ( printf ( "%d.%02d" , g: lua_version , g: lua_subversion )) 75let fname = tr ( a: fname , '.' , '/' ) 76let paths = lua_ver >= 5.03 ? [ fname .. ".lua" , fname .. "/init.lua" ] : [ fname .. ".lua" ] 77for path in paths 78if filereadable ( path ) 79return path 80endif 81endfor 82return fname 83endfunction 84 85let & cpo = s: cpo_save 86unlet s: cpo_save 87 88" vim: nowrap sw=2 sts=2 ts=8 noet: