shaderslang.vim 1.7 KB

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