mirror of
https://github.com/neovim/neovim.git
synced 2024-12-24 21:25:04 -07:00
vim-patch:10b4f75d4c03 (#26846)
runtime(dist/ft): improve filetype detection for *.v (V/Verilog/Coq)
Patch provided by Dan Alt
closes: vim/vim#13793
10b4f75d4c
Co-authored-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
parent
e98bef259a
commit
2bf68df289
@ -167,6 +167,7 @@ variables can be used to overrule the filetype used for certain extensions:
|
|||||||
`*.sh` g:bash_is_sh |ft-sh-syntax|
|
`*.sh` g:bash_is_sh |ft-sh-syntax|
|
||||||
`*.tex` g:tex_flavor |ft-tex-plugin|
|
`*.tex` g:tex_flavor |ft-tex-plugin|
|
||||||
`*.typ` g:filetype_typ
|
`*.typ` g:filetype_typ
|
||||||
|
`*.v` g:filetype_v
|
||||||
`*.w` g:filetype_w |ft-cweb-syntax|
|
`*.w` g:filetype_w |ft-cweb-syntax|
|
||||||
|
|
||||||
For a few filetypes the global variable is used only when the filetype could
|
For a few filetypes the global variable is used only when the filetype could
|
||||||
|
@ -1530,12 +1530,26 @@ function M.v(_, bufnr)
|
|||||||
-- Filetype was already detected
|
-- Filetype was already detected
|
||||||
return
|
return
|
||||||
end
|
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
|
for _, line in ipairs(getlines(bufnr, 1, 200)) do
|
||||||
if not line:find('^%s*/') then
|
if line:find('^%s*/%*') then
|
||||||
if findany(line, { ';%s*$', ';%s*/' }) then
|
in_comment = 1
|
||||||
return 'verilog'
|
end
|
||||||
elseif findany(line, { '%.%s*$', '%.%s*%(%*' }) then
|
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'
|
return 'coq'
|
||||||
|
elseif findany(line, { ';%s*$', ';%s*/[/*]' }) then
|
||||||
|
return 'verilog'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user