aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-01-02 19:06:43 +0800
committerGitHub <noreply@github.com>2024-01-02 19:06:43 +0800
commit2bf68df289de12510d472f362482e5bde253cb41 (patch)
tree98224e3f267b124b59331accc929db95971395e0 /runtime/lua/vim
parente98bef259abf876b90ba1f7885a36b94490e38a6 (diff)
downloadrneovim-2bf68df289de12510d472f362482e5bde253cb41.tar.gz
rneovim-2bf68df289de12510d472f362482e5bde253cb41.tar.bz2
rneovim-2bf68df289de12510d472f362482e5bde253cb41.zip
vim-patch:10b4f75d4c03 (#26846)
runtime(dist/ft): improve filetype detection for *.v (V/Verilog/Coq) Patch provided by Dan Alt closes: vim/vim#13793 https://github.com/vim/vim/commit/10b4f75d4c03c1cd4f579be5fdc812ba41b72fef Co-authored-by: Christian Brabandt <cb@256bit.org>
Diffstat (limited to 'runtime/lua/vim')
-rw-r--r--runtime/lua/vim/filetype/detect.lua22
1 files changed, 18 insertions, 4 deletions
diff --git a/runtime/lua/vim/filetype/detect.lua b/runtime/lua/vim/filetype/detect.lua
index a1c5ac73b4..6a14c73c92 100644
--- a/runtime/lua/vim/filetype/detect.lua
+++ b/runtime/lua/vim/filetype/detect.lua
@@ -1530,12 +1530,26 @@ function M.v(_, bufnr)
-- Filetype was already detected
return
end
+ if vim.g.filetype_v then
+ return vim.g.filetype_v
+ end
+ local in_comment = 0
for _, line in ipairs(getlines(bufnr, 1, 200)) do
- if not line:find('^%s*/') then
- if findany(line, { ';%s*$', ';%s*/' }) then
- return 'verilog'
- elseif findany(line, { '%.%s*$', '%.%s*%(%*' }) then
+ if line:find('^%s*/%*') then
+ in_comment = 1
+ end
+ if in_comment == 1 then
+ if line:find('%*/') then
+ in_comment = 0
+ end
+ elseif not line:find('^%s*//') then
+ if
+ line:find('%.%s*$') and not line:find('/[/*]')
+ or line:find('%(%*') and not line:find('/[/*].*%(%*')
+ then
return 'coq'
+ elseif findany(line, { ';%s*$', ';%s*/[/*]' }) then
+ return 'verilog'
end
end
end