]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.1.0906: filetype: Nvidia PTX files are not recognized v9.1.0906
authorYinzuo Jiang <jiangyinzuo@foxmail.com>
Thu, 5 Dec 2024 20:31:09 +0000 (21:31 +0100)
committerChristian Brabandt <cb@256bit.org>
Thu, 5 Dec 2024 20:31:09 +0000 (21:31 +0100)
Problem:  filetype: Nvidia PTX files are not recognized
Solution: detect '*.ptx' files as ptx filetype (Yinzuo Jiang)

Reference: https://docs.nvidia.com/cuda/parallel-thread-execution/

closes: #16171

Signed-off-by: Yinzuo Jiang <jiangyinzuo@foxmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
.github/MAINTAINERS
runtime/filetype.vim
runtime/ftplugin/ptx.vim [new file with mode: 0644]
runtime/syntax/ptx.vim [new file with mode: 0644]
src/testdir/test_filetype.vim
src/version.c

index 4c5ee6d2b24586dec7eaaeb6db5cd3f526a1764e..50755e1a69af73cb84f603932533c38e8ef5eeee 100644 (file)
@@ -249,6 +249,7 @@ runtime/ftplugin/postscr.vim                @mrdubya
 runtime/ftplugin/prisma.vim            @ribru17
 runtime/ftplugin/ps1.vim               @heaths
 runtime/ftplugin/ps1xml.vim            @heaths
+runtime/ftplugin/ptx.vim               @jiangyinzuo
 runtime/ftplugin/purescript.vim                @ribru17
 runtime/ftplugin/pymanifest.vim                @ObserverOfTime
 runtime/ftplugin/python.vim            @tpict
@@ -556,6 +557,7 @@ runtime/syntax/prolog.vim           @XVilka
 runtime/syntax/ps1.vim                 @heaths
 runtime/syntax/ps1xml.vim              @heaths
 runtime/syntax/psl.vim                 @danielkho
+runtime/syntax/ptx.vim                 @jiangyinzuo
 runtime/syntax/pymanifest.vim          @ObserverOfTime
 runtime/syntax/qb64.vim                        @dkearns
 runtime/syntax/qml.vim                 @ChaseKnowlden
index 2c46c57b1ef83cb99c01850decfc42353b53cc7f..fe1204778380e0fdca20ece01c534faf9fc9e500 100644 (file)
@@ -1976,6 +1976,10 @@ au BufNewFile,BufRead *.pk                       setf poke
 " Protocols
 au BufNewFile,BufRead */etc/protocols          setf protocols
 
+" Nvidia PTX (Parallel Thread Execution)
+" See https://docs.nvidia.com/cuda/parallel-thread-execution/
+au BufNewFile,BufRead *.ptx                    setf ptx
+
 " Purescript
 au BufNewFile,BufRead *.purs                   setf purescript
 
diff --git a/runtime/ftplugin/ptx.vim b/runtime/ftplugin/ptx.vim
new file mode 100644 (file)
index 0000000..12b127c
--- /dev/null
@@ -0,0 +1,16 @@
+" Vim filetype plugin file
+" Language:    Nvidia PTX (Parellel Thread Execution)
+" Maintainer:  Yinzuo Jiang <jiangyinzuo@foxmail.com>
+" Last Change: 2024-12-05
+
+if exists("b:did_ftplugin")
+  finish
+endif
+
+let b:did_ftplugin = 1
+
+" Comments in PTX follow C/C++ syntax
+" See: https://docs.nvidia.com/cuda/parallel-thread-execution/#syntax
+setlocal commentstring=//\ %s
+
+let b:undo_ftplugin = 'setl commentstring<'
diff --git a/runtime/syntax/ptx.vim b/runtime/syntax/ptx.vim
new file mode 100644 (file)
index 0000000..98de4ff
--- /dev/null
@@ -0,0 +1,52 @@
+" Vim syntax file
+" Language: Nvidia PTX (Parallel Thread Execution)
+" Maintainer: Yinzuo Jiang <jiangyinzuo@foxmail.com>
+" Latest Revision: 2024-12-05
+
+if exists("b:current_syntax")
+  finish
+endif
+
+let s:cpo_save = &cpo
+set cpo&vim
+
+syntax iskeyword .,_,a-z,48-57
+
+" https://docs.nvidia.com/cuda/parallel-thread-execution/#directives
+syntax keyword ptxFunction .entry .func
+syntax keyword ptxDirective .branchtargets .file .loc .secion .maxnctapersm .maxnreg .minnctapersm .noreturn .pragma .reqntid .target .version .weak
+syntax keyword ptxOperator .address_size .alias .align .callprototype .calltargets
+syntax keyword ptxStorageClass .common .const .extern .global .local .param .reg .sreg .shared .tex .visible
+syntax keyword ptxType .explicitcluster .maxclusterrank .reqnctapercluster
+
+" https://docs.nvidia.com/cuda/parallel-thread-execution/#fundamental-types
+" signed integer
+syntax keyword ptxType .s8 .s16 .s32 .s64
+" unsigned integer
+syntax keyword ptxType .u8 .u16 .u32 .u64
+" floating-point
+syntax keyword ptxType .f16 .f16x2 .f32 .f64
+" bits (untyped)
+syntax keyword ptxType .b8 .b16 .b32 .b64 .b128
+" predicate
+syntax keyword ptxType .pred
+
+" https://docs.nvidia.com/cuda/parallel-thread-execution/#instruction-statements
+syntax keyword ptxStatement ret
+
+syntax region  ptxCommentL start="//" skip="\\$" end="$" keepend
+syntax region ptxComment matchgroup=ptxCommentStart start="/\*" end="\*/" extend
+
+hi def link ptxFunction Function
+hi def link ptxDirective Keyword
+hi def link ptxOperator Operator
+hi def link ptxStorageClass StorageClass
+hi def link ptxType Type
+hi def link ptxStatement Statement
+
+hi def link ptxCommentL ptxComment
+hi def link ptxCommentStart ptxComment
+hi def link ptxComment Comment
+
+let &cpo = s:cpo_save
+unlet s:cpo_save
index ef1d8b57e73e909c412d6e37b99d383d98c079ed..2dc0f4961b30049323b06163f7e4ca3ae56a8c48 100644 (file)
@@ -608,6 +608,7 @@ def s:GetFilenameChecks(): dict<list<string>>
     ps1xml: ['file.ps1xml'],
     psf: ['file.psf'],
     psl: ['file.psl'],
+    ptx: ['file.ptx'],
     pug: ['file.pug'],
     puppet: ['file.pp'],
     purescript: ['file.purs'],
index 4cf68620cb27ae548c8fa6e0a7247a257982564b..c230d4f9d03dacc6c39203fe8ba3d6baaeac9ac9 100644 (file)
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    906,
 /**/
     905,
 /**/