xref: /vim-8.2.3635/runtime/ftplugin/lua.vim (revision 519cc559)
1" Vim filetype plugin file.
2" Language:	        Lua
3" Maintainer:		Doug Kearns <[email protected]>
4" Previous Maintainer:	Max Ischenko <[email protected]>
5" Last Change:	        2021 Nov 15
6
7" Only do this when not done yet for this buffer
8if exists("b:did_ftplugin")
9  finish
10endif
11
12" Don't load another plugin for this buffer
13let b:did_ftplugin = 1
14
15let s:cpo_save = &cpo
16set cpo&vim
17
18" Set 'formatoptions' to break comment lines but not other lines, and insert
19" the comment leader when hitting <CR> or using "o".
20setlocal formatoptions-=t formatoptions+=croql
21
22setlocal comments=:--
23setlocal commentstring=--%s
24setlocal suffixesadd=.lua
25
26let b:undo_ftplugin = "setlocal fo< com< cms< sua<"
27
28if exists("loaded_matchit") && !exists("b:match_words")
29  let b:match_ignorecase = 0
30  let b:match_words =
31        \ '\<\%(do\|function\|if\)\>:' .
32        \ '\<\%(return\|else\|elseif\)\>:' .
33        \ '\<end\>,' .
34        \ '\<repeat\>:\<until\>,' .
35        \ '\%(--\)\=\[\(=*\)\[:]\1]'
36  let b:undo_ftplugin .= " | unlet! b:match_words b:match_ignorecase"
37endif
38
39if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter")
40  let b:browsefilter = "Lua Source Files (*.lua)\t*.lua\n" .
41	\              "All Files (*.*)\t*.*\n"
42  let b:undo_ftplugin .= " | unlet! b:browsefilter"
43endif
44
45let &cpo = s:cpo_save
46unlet s:cpo_save
47