Skip to content

Commit 616219f

Browse files
mTvare6chrisbra
authored andcommitted
patch 9.1.0995: filetype: shaderslang files are not detected
Problem: filetype: shaderslang files are not detected Solution: detect '*.slang' files as shaderslang filetype, include a filetype and syntax script (mtvare6) Reference: https://shader-slang.com/ closes: #16387 Signed-off-by: mtvare6 <[email protected]> Signed-off-by: Christian Brabandt <[email protected]>
1 parent 0072cee commit 616219f

File tree

6 files changed

+423
-1
lines changed

6 files changed

+423
-1
lines changed

.github/MAINTAINERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ runtime/ftplugin/scss.vim @tpope
273273
runtime/ftplugin/sdoc.vim @gpanders
274274
runtime/ftplugin/sed.vim @dkearns
275275
runtime/ftplugin/sh.vim @dkearns
276+
runtime/ftplugin/shaderslang.vim @mTvare6
276277
runtime/ftplugin/slint.vim @ribru17
277278
runtime/ftplugin/snakemake.vim @ribru17
278279
runtime/ftplugin/solidity.vim @cothi
@@ -590,6 +591,7 @@ runtime/syntax/scss.vim @tpope
590591
runtime/syntax/sdoc.vim @gpanders
591592
runtime/syntax/sed.vim @dkearns
592593
runtime/syntax/shared/debversions.vim @jamessan
594+
runtime/syntax/shaderslang.vim @mTvare6
593595
runtime/syntax/solidity.vim @cothi
594596
runtime/syntax/spec.vim @ignatenkobrain
595597
runtime/syntax/sqloracle.vim @chrisbra

runtime/filetype.vim

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2185,7 +2185,7 @@ au BufNewFile,BufRead [rR]antfile,*.rant,[rR]akefile,*.rake setf ruby
21852185
au BufNewFile,BufRead *.rs setf rust
21862186
au BufNewFile,BufRead Cargo.lock,*/.cargo/config,*/.cargo/credentials setf toml
21872187

2188-
" S-lang (or shader language, or SmallLisp)
2188+
" S-lang
21892189
au BufNewFile,BufRead *.sl setf slang
21902190

21912191
" Sage
@@ -2209,6 +2209,9 @@ au BufNewFile,BufRead *.scala setf scala
22092209
" SBT - Scala Build Tool
22102210
au BufNewFile,BufRead *.sbt setf sbt
22112211

2212+
" Slang Shading Language
2213+
au BufNewFile,BufRead *.slang setf shaderslang
2214+
22122215
" Slint
22132216
au BufNewFile,BufRead *.slint setf slint
22142217

runtime/ftplugin/shaderslang.vim

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
" Vim filetype plugin file
2+
" Language: Slang
3+
" Maintainer: Austin Shijo <[email protected]>
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

0 commit comments

Comments
 (0)