mtvare6 | 616219f | 2025-01-07 20:31:27 +0100 | [diff] [blame] | 1 | " Vim filetype plugin file |
| 2 | " Language: Slang |
| 3 | " Maintainer: Austin Shijo <epestr@proton.me> |
| 4 | " Last Change: 2025 Jan 05 |
| 5 | |
| 6 | " Only do this when not done yet for this buffer |
| 7 | if exists("b:did_ftplugin") |
| 8 | finish |
| 9 | endif |
| 10 | |
| 11 | " Don't load another plugin for this buffer |
| 12 | let b:did_ftplugin = 1 |
| 13 | |
| 14 | " Using line continuation here. |
| 15 | let s:cpo_save = &cpo |
| 16 | set cpo-=C |
| 17 | |
| 18 | let b:undo_ftplugin = "setl fo< com< cms< inc<" |
| 19 | |
| 20 | " Set 'formatoptions' to break comment lines but not other lines, |
| 21 | " and insert the comment leader when hitting <CR> or using "o". |
| 22 | setlocal fo-=t fo+=croql |
| 23 | |
| 24 | " Set comment string (Slang uses C-style comments) |
| 25 | setlocal commentstring=//\ %s |
| 26 | |
| 27 | " Set 'comments' to format dashed lists in comments |
| 28 | setlocal comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,:///,:// |
| 29 | |
| 30 | " When the matchit plugin is loaded, this makes the % command skip parens and |
| 31 | " braces in comments properly, and adds support for shader-specific keywords |
| 32 | if exists("loaded_matchit") |
| 33 | " Add common shader control structures |
| 34 | let b:match_words = '{\|^\s*\<\(if\|for\|while\|switch\|struct\|class\)\>:}\|^\s*\<break\>,' .. |
| 35 | \ '^\s*#\s*if\(\|def\|ndef\)\>:^\s*#\s*elif\>:^\s*#\s*else\>:^\s*#\s*endif\>,' .. |
| 36 | \ '\[:\]' |
| 37 | let b:match_skip = 's:comment\|string\|character\|special' |
| 38 | let b:match_ignorecase = 0 |
| 39 | let b:undo_ftplugin ..= " | unlet! b:match_skip b:match_words b:match_ignorecase" |
| 40 | endif |
| 41 | |
| 42 | " Win32 and GTK can filter files in the browse dialog |
| 43 | if (has("gui_win32") || has("gui_gtk")) && !exists("b:browsefilter") |
| 44 | let b:browsefilter = "Slang Source Files (*.slang)\t*.slang\n" |
| 45 | if has("win32") |
| 46 | let b:browsefilter ..= "All Files (*.*)\t*\n" |
| 47 | else |
| 48 | let b:browsefilter ..= "All Files (*)\t*\n" |
| 49 | endif |
| 50 | let b:undo_ftplugin ..= " | unlet! b:browsefilter" |
| 51 | endif |
| 52 | |
| 53 | let &cpo = s:cpo_save |
| 54 | unlet s:cpo_save |