patch 9.1.0906: filetype: Nvidia PTX files are not recognized

Commit: 
https://github.com/vim/vim/commit/bdb5f85a5189534653f36e92b1bc780ca8d25218
Author: Yinzuo Jiang <jiangyin...@foxmail.com>
Date:   Thu Dec 5 21:31:09 2024 +0100

    patch 9.1.0906: filetype: Nvidia PTX files are not recognized
    
    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 <jiangyin...@foxmail.com>
    Signed-off-by: Christian Brabandt <c...@256bit.org>

diff --git a/.github/MAINTAINERS b/.github/MAINTAINERS
index 4c5ee6d2b..50755e1a6 100644
--- a/.github/MAINTAINERS
+++ b/.github/MAINTAINERS
@@ -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
diff --git a/runtime/filetype.vim b/runtime/filetype.vim
index 2c46c57b1..fe1204778 100644
--- a/runtime/filetype.vim
+++ b/runtime/filetype.vim
@@ -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
index 000000000..12b127c8f
--- /dev/null
+++ b/runtime/ftplugin/ptx.vim
@@ -0,0 +1,16 @@
+" Vim filetype plugin file
+" Language:    Nvidia PTX (Parellel Thread Execution)
+" Maintainer:  Yinzuo Jiang <jiangyin...@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
index 000000000..98de4ff6d
--- /dev/null
+++ b/runtime/syntax/ptx.vim
@@ -0,0 +1,52 @@
+" Vim syntax file
+" Language: Nvidia PTX (Parallel Thread Execution)
+" Maintainer: Yinzuo Jiang <jiangyin...@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
diff --git a/src/testdir/test_filetype.vim b/src/testdir/test_filetype.vim
index ef1d8b57e..2dc0f4961 100644
--- a/src/testdir/test_filetype.vim
+++ b/src/testdir/test_filetype.vim
@@ -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'],
diff --git a/src/version.c b/src/version.c
index 4cf68620c..c230d4f9d 100644
--- a/src/version.c
+++ b/src/version.c
@@ -704,6 +704,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    906,
 /**/
     905,
 /**/

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion visit 
https://groups.google.com/d/msgid/vim_dev/E1tJIie-00B7JS-39%40256bit.org.

Raspunde prin e-mail lui