]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.2.0788: filetype: hip files are not recognized v9.2.0788
authorYoung <young20050727@gmail.com>
Sat, 18 Jul 2026 09:39:58 +0000 (09:39 +0000)
committerChristian Brabandt <cb@256bit.org>
Sat, 18 Jul 2026 09:39:58 +0000 (09:39 +0000)
Problem:  filetype: hip files are not recognized
Solution: Detect *.hip files as hip filetype, include filetype, syntax
          and indent plugins, update makemenu.vim and synmenu.vim (Young)

Round out HIP (Heterogeneous-compute Interface for Portability) support
to mirror the existing CUDA files:

- autoload/dist/ft.vim: detect the ".hip" extension as filetype "hip"
- ftplugin/hip.vim: behave like C++ by sourcing ftplugin/cpp.vim
- indent/hip.vim: use cindent, like indent/cuda.vim
- makemenu.vim / synmenu.vim: add a Syntax menu entry

The syntax/hip.vim file already sources syntax/cpp.vim and adds the
HIP-specific keywords, matching syntax/cuda.vim.

closes: #20773

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Young <young20050727@gmail.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
.github/MAINTAINERS
runtime/autoload/dist/ft.vim
runtime/ftplugin/hip.vim [new file with mode: 0644]
runtime/indent/hip.vim [new file with mode: 0644]
runtime/makemenu.vim
runtime/synmenu.vim
runtime/syntax/hip.vim [new file with mode: 0644]
src/testdir/test_filetype.vim
src/version.c

index 6fdafa0945ee6c0c4b2fb465f04f55afaa589be5..81bf38d68a824cfd9122116e8b77fbe57918c216 100644 (file)
@@ -584,6 +584,7 @@ runtime/syntax/hcl.vim                                      @gpanders
 runtime/syntax/help.vim                                        @dkearns
 runtime/syntax/help_ru.vim                             @RestorerZ
 runtime/syntax/hgcommit.vim                            @k-takata
+runtime/syntax/hip.vim                                 @Young-TW
 runtime/syntax/hitest.vim                              @lacygoill
 runtime/syntax/hog.vim                                 @wtfbbqhax
 runtime/syntax/hollywood.vim                           @sodero
index 18fcfbb641a9b44d2adfa6638864e11d8cafe71f..a72e91e3ea6fa272944733f348c7ee6af8bbc368 100644 (file)
@@ -1969,6 +1969,8 @@ const ft_from_ext = {
   # CUDA Compute Unified Device Architecture
   "cu": "cuda",
   "cuh": "cuda",
+  # HIP Heterogeneous-compute Interface for Portability
+  "hip": "hip",
   # Cue
   "cue": "cue",
   # DAX
diff --git a/runtime/ftplugin/hip.vim b/runtime/ftplugin/hip.vim
new file mode 100644 (file)
index 0000000..c57fa21
--- /dev/null
@@ -0,0 +1,11 @@
+" Vim filetype plugin
+" Language:    HIP (Heterogeneous-compute Interface for Portability)
+" Maintainer:  The Vim Project <https://github.com/vim/vim>
+" Last Change: 2026 Jul 15
+
+if exists('b:did_ftplugin')
+  finish
+endif
+
+" Behaves mostly just like C++
+runtime! ftplugin/cpp.vim
diff --git a/runtime/indent/hip.vim b/runtime/indent/hip.vim
new file mode 100644 (file)
index 0000000..680fc8b
--- /dev/null
@@ -0,0 +1,15 @@
+" Vim indent file
+" Language:    HIP (Heterogeneous-compute Interface for Portability)
+" Maintainer:  The Vim Project <https://github.com/vim/vim>
+" Last Change: 2026 Jul 15
+
+" Only load this indent file when no other was loaded.
+if exists("b:did_indent")
+   finish
+endif
+let b:did_indent = 1
+
+" It's just like C indenting
+setlocal cindent
+
+let b:undo_indent = "setl cin<"
index 3cff23db2a87c70d05e2f5dff990a67bcc95278a..6611f737cdc8fbcb20d54d3b19633396952838dc 100644 (file)
@@ -276,6 +276,7 @@ SynMenu HIJK.Hercules:hercules
 SynMenu HIJK.Hex\ dump.XXD:xxd
 SynMenu HIJK.Hex\ dump.Intel\ MCS51:hex
 SynMenu HIJK.Hg\ commit:hgcommit
+SynMenu HIJK.HIP:hip
 SynMenu HIJK.Hollywood:hollywood
 SynMenu HIJK.HTML.HTML:html
 SynMenu HIJK.HTML.HTML\ with\ M4:htmlm4
index 5d3321585efc252e80806cf83a8dfa338b91db30..c26c128b3c237e78df78f50421d07d645807b95d 100644 (file)
@@ -257,6 +257,7 @@ an 50.50.170 &Syntax.HIJK.Hercules :cal SetSyn("hercules")<CR>
 an 50.50.180 &Syntax.HIJK.Hex\ dump.XXD :cal SetSyn("xxd")<CR>
 an 50.50.190 &Syntax.HIJK.Hex\ dump.Intel\ MCS51 :cal SetSyn("hex")<CR>
 an 50.50.200 &Syntax.HIJK.Hg\ commit :cal SetSyn("hgcommit")<CR>
+an 50.50.205 &Syntax.HIJK.HIP :cal SetSyn("hip")<CR>
 an 50.50.210 &Syntax.HIJK.Hollywood :cal SetSyn("hollywood")<CR>
 an 50.50.220 &Syntax.HIJK.HTML.HTML :cal SetSyn("html")<CR>
 an 50.50.230 &Syntax.HIJK.HTML.HTML\ with\ M4 :cal SetSyn("htmlm4")<CR>
diff --git a/runtime/syntax/hip.vim b/runtime/syntax/hip.vim
new file mode 100644 (file)
index 0000000..f3bec3f
--- /dev/null
@@ -0,0 +1,52 @@
+" Vim syntax file
+" Language:    HIP (Heterogeneous-compute Interface for Portability)
+" Maintainer:  Young <young20050727@gmail.com>
+" Last Change: 2026 Jul 15
+" Based On:    syntax/cuda.vim by Timothy B. Terriberry
+
+" quit when a syntax file was already loaded
+if exists("b:current_syntax")
+  finish
+endif
+
+" Read the C++ syntax to start with
+runtime! syntax/cpp.vim
+
+" HIP extensions.
+" Reference: https://docs.amd.com/en/latest/develop-perf-tips/hip-programming-guide/
+syn keyword hipStorageClass    __device__ __global__ __host__ __managed__
+syn keyword hipStorageClass    __constant__ __grid_constant__ __shared__
+syn keyword hipStorageClass    __inline__ __noinline__ __forceinline__ __inline_hint__
+syn keyword hipStorageClass    __align__ __thread__ __restrict__
+syn keyword hipType            char1 char2 char3 char4
+syn keyword hipType            uchar1 uchar2 uchar3 uchar4
+syn keyword hipType            short1 short2 short3 short4
+syn keyword hipType            ushort1 ushort2 ushort3 ushort4
+syn keyword hipType            int1 int2 int3 int4
+syn keyword hipType            uint1 uint2 uint3 uint4
+syn keyword hipType            long1 long2 long3 long4
+syn keyword hipType            ulong1 ulong2 ulong3 ulong4
+syn keyword hipType            longlong1 longlong2 longlong3 longlong4
+syn keyword hipType            ulonglong1 ulonglong2 ulonglong3 ulonglong4
+syn keyword hipType            float1 float2 float3 float4
+syn keyword hipType            double1 double2 double3 double4
+syn keyword hipType            dim3 texture textureReference
+syn keyword hipType            hipError_t hipDeviceProp hipMemcpyKind
+syn keyword hipType            hipArray hipChannelFormatKind
+syn keyword hipType            hipChannelFormatDesc hipTextureAddressMode
+syn keyword hipType            hipTextureFilterMode hipTextureReadMode
+syn keyword hipVariable                gridDim blockIdx blockDim threadIdx warpSize
+syn keyword hipConstant                __HIP_ARCH__
+syn keyword hipConstant                __DEVICE_EMULATION__
+" There are too many HIP enumeration constants. We only define a subset of commonly used constants.
+" Reference: https://docs.amd.com/en/latest/develop-perf-tips/hip-programming-guide/
+syn keyword hipConstant                hipSuccess
+
+hi def link hipStorageClass    StorageClass
+hi def link hipType            Type
+hi def link hipVariable                Identifier
+hi def link hipConstant                Constant
+
+let b:current_syntax = "hip"
+
+" vim: ts=8
index 13c5770d72024241926a121ad22afe45f01bb93e..bc377440a984adc37a4742df86c47bad401d76e4 100644 (file)
@@ -377,6 +377,7 @@ def s:GetFilenameChecks(): dict<list<string>>
     hercules: ['file.vc', 'file.ev', 'file.sum', 'file.errsum'],
     hex: ['file.hex', 'file.ihex', 'file.ihe', 'file.ihx', 'file.int', 'file.mcs', 'file.h32', 'file.h80', 'file.h86', 'file.a43', 'file.a90'],
     hgcommit: ['hg-editor-file.txt'],
+    hip: ['file.hip'],
     hjson: ['file.hjson'],
     hlsplaylist: ['file.m3u', 'file.m3u8'],
     hog: ['file.hog', 'snort.conf', 'vision.conf'],
index f13a89b81105551b8a7273a8c55d0933788abed2..93e38b8a007b4f654ddc5e44a7c296b8c93386fc 100644 (file)
@@ -759,6 +759,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    788,
 /**/
     787,
 /**/