mirror of
https://github.com/neovim/neovim.git
synced 2024-12-19 10:45:16 -07:00
vim-patch:9.1.0876: filetype: openCL files are not recognized
Problem: filetype: openCL files are not recognized
Solution: detect '*.cl' files as opencl or lisp filetype,
include a opencl syntax and filetype plugin (Wu, Zhenyu)
closes: vim/vim#15825
e2c27ca8ef
Co-authored-by: Wu, Zhenyu <wuzhenyu@ustc.edu>
This commit is contained in:
parent
4c85c217d3
commit
23ead4f2cb
12
runtime/ftplugin/opencl.vim
Normal file
12
runtime/ftplugin/opencl.vim
Normal file
@ -0,0 +1,12 @@
|
||||
" Vim filetype plugin file
|
||||
" Language: OpenCL
|
||||
" Maintainer: Wu, Zhenyu <wuzhenyu@ustc.edu>
|
||||
" Last Change: 2024 Nov 19
|
||||
|
||||
if exists("b:did_ftplugin") | finish | endif
|
||||
let b:did_ftplugin = 1
|
||||
|
||||
setlocal comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,:///,://
|
||||
setlocal commentstring=/*\ %s\ */ define& include&
|
||||
|
||||
let b:undo_ftplugin = "setl commentstring< comments<"
|
@ -300,6 +300,7 @@ local extension = {
|
||||
cho = 'chordpro',
|
||||
chordpro = 'chordpro',
|
||||
ck = 'chuck',
|
||||
cl = detect.cl,
|
||||
eni = 'cl',
|
||||
icl = 'clean',
|
||||
cljx = 'clojure',
|
||||
@ -688,7 +689,6 @@ local extension = {
|
||||
ily = 'lilypond',
|
||||
liquid = 'liquid',
|
||||
liq = 'liquidsoap',
|
||||
cl = 'lisp',
|
||||
L = 'lisp',
|
||||
lisp = 'lisp',
|
||||
el = 'lisp',
|
||||
|
@ -180,6 +180,16 @@ function M.changelog(_, bufnr)
|
||||
return 'changelog'
|
||||
end
|
||||
|
||||
--- @type vim.filetype.mapfn
|
||||
function M.cl(_, bufnr)
|
||||
local lines = table.concat(getlines(bufnr, 1, 4))
|
||||
if lines:match('/%*') then
|
||||
return 'opencl'
|
||||
else
|
||||
return 'lisp'
|
||||
end
|
||||
end
|
||||
|
||||
--- @type vim.filetype.mapfn
|
||||
function M.class(_, bufnr)
|
||||
-- Check if not a Java class (starts with '\xca\xfe\xba\xbe')
|
||||
|
13
runtime/syntax/opencl.vim
Normal file
13
runtime/syntax/opencl.vim
Normal file
@ -0,0 +1,13 @@
|
||||
" Vim syntax file
|
||||
" Language: OpenCL
|
||||
" Last Change: 2024 Nov 19
|
||||
" Maintainer: Wu, Zhenyu <wuzhenyu@ustc.edu>
|
||||
|
||||
if exists("b:current_syntax")
|
||||
finish
|
||||
endif
|
||||
|
||||
" TODO: support openCL specific keywords
|
||||
runtime! syntax/c.vim
|
||||
|
||||
let current_syntax = "opencl"
|
@ -422,7 +422,7 @@ func s:GetFilenameChecks() abort
|
||||
\ 'limits': ['/etc/limits', '/etc/anylimits.conf', '/etc/anylimits.d/file.conf', '/etc/limits.conf', '/etc/limits.d/file.conf', '/etc/some-limits.conf', '/etc/some-limits.d/file.conf', 'any/etc/limits', 'any/etc/limits.conf', 'any/etc/limits.d/file.conf', 'any/etc/some-limits.conf', 'any/etc/some-limits.d/file.conf'],
|
||||
\ 'liquidsoap': ['file.liq'],
|
||||
\ 'liquid': ['file.liquid'],
|
||||
\ 'lisp': ['file.lsp', 'file.lisp', 'file.asd', 'file.el', 'file.cl', '.emacs', '.sawfishrc', 'sbclrc', '.sbclrc', 'file.stsg', 'any/local/share/supertux2/config'],
|
||||
\ 'lisp': ['file.lsp', 'file.lisp', 'file.asd', 'file.el', '.emacs', '.sawfishrc', 'sbclrc', '.sbclrc', 'file.stsg', 'any/local/share/supertux2/config'],
|
||||
\ 'lite': ['file.lite', 'file.lt'],
|
||||
\ 'litestep': ['/LiteStep/any/file.rc', 'any/LiteStep/any/file.rc'],
|
||||
\ 'logcheck': ['/etc/logcheck/file.d-some/file', '/etc/logcheck/file.d/file', 'any/etc/logcheck/file.d-some/file', 'any/etc/logcheck/file.d/file'],
|
||||
@ -1192,6 +1192,22 @@ func Test_cfg_file()
|
||||
filetype off
|
||||
endfunc
|
||||
|
||||
func Test_cl_file()
|
||||
filetype on
|
||||
|
||||
call writefile(['/*', ' * Xfile.cl', ' */', 'int f() {}'], 'Xfile.cl')
|
||||
split Xfile.cl
|
||||
call assert_equal('opencl', &filetype)
|
||||
bwipe!
|
||||
|
||||
call writefile(['()'], 'Xfile.cl')
|
||||
split Xfile.cl
|
||||
call assert_equal('lisp', &filetype)
|
||||
bwipe!
|
||||
|
||||
filetype off
|
||||
endfunc
|
||||
|
||||
func Test_d_file()
|
||||
filetype on
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user