Skip to content

Commit

Permalink
Fix lint issue reported by vint
Browse files Browse the repository at this point in the history
subtypes are interpreted from the filetype so we'll ignore case.
  • Loading branch information
lelutin committed Aug 28, 2024
1 parent dbda1ea commit 9ccb623
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 31 deletions.
4 changes: 2 additions & 2 deletions ftdetect/puppet.vim
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
" vint: -ProhibitAutocmdWithNoGroup
" Vim has fixed puppet vs pascal detection in patch 8.2.2334 so we can rely on
" their type detection from that point on.
if !has("patch-8.2.2334") && !has("nvim-0.5.0")
if !has('patch-8.2.2334') && !has('nvim-0.5.0')
" Vim's own filetypes.vim runs before all ftdetect scripts (why?) and matches
" detects the .pp extension as being a 'pascal' file. Since the script uses
" `setf`, we can nullify the filetype detection by removing all commands bound
Expand All @@ -14,7 +14,7 @@ if !has("patch-8.2.2334") && !has("nvim-0.5.0")
endif
" Vim now has autodetection for epuppet and Puppetfile. We only need to add
" autocommands for older versions of vim / neovim
if !has("patch-8.2.2402") && !has("nvim-0.5.0")
if !has('patch-8.2.2402') && !has('nvim-0.5.0')
" Some epp files may get marked as "mason" type before this script is reached.
" Vim's own scripts.vim forces the type if it detects a `<%` at the start of
" the file. All files ending in .epp should be epuppet
Expand Down
30 changes: 15 additions & 15 deletions ftplugin/epuppet.vim
Original file line number Diff line number Diff line change
Expand Up @@ -14,45 +14,45 @@ set cpo-=C

" Define some defaults in case the included ftplugins don't set them.
let s:undo_ftplugin = ''
if has("win32")
if has('win32')
let s:browsefilter = "All Files (*.*)\t*.*\n"
else
let s:browsefilter = "All Files (*)\t*\n"
endif
let s:match_words = ''

if !exists("g:epuppet_default_subtype")
let g:epuppet_default_subtype = "sh"
if !exists('g:epuppet_default_subtype')
let g:epuppet_default_subtype = 'sh'
endif

if &filetype =~ '^epuppet\.'
if &filetype =~# '^epuppet\.'
let b:epuppet_subtype = matchstr(&filetype,'^epuppet\.\zs\w\+')
elseif !exists('b:epuppet_subtype')
let b:epuppet_subtype = matchstr(substitute(expand("%:t"),'\c\%(\.epp\)\+$','',''),'\.\zs\w\+\%(\ze+\w\+\)\=$')
let b:epuppet_subtype = matchstr(substitute(expand('%:t'),'\c\%(\.epp\)\+$','',''),'\.\zs\w\+\%(\ze+\w\+\)\=$')
" TODO instead of listing exceptions like this, can we instead recognize
" extension -> type mapping?
if b:epuppet_subtype == 'rhtml'
if b:epuppet_subtype ==? 'rhtml'
let b:epuppet_subtype = 'html'
elseif b:epuppet_subtype == 'rb'
elseif b:epuppet_subtype ==? 'rb'
let b:epuppet_subtype = 'ruby'
elseif b:epuppet_subtype == 'yml'
elseif b:epuppet_subtype ==? 'yml'
let b:epuppet_subtype = 'yaml'
elseif b:epuppet_subtype == 'js'
elseif b:epuppet_subtype ==? 'js'
let b:epuppet_subtype = 'javascript'
elseif b:epuppet_subtype == 'txt'
elseif b:epuppet_subtype ==? 'txt'
" Conventional; not a real file type
let b:epuppet_subtype = 'text'
elseif b:epuppet_subtype == 'py'
elseif b:epuppet_subtype ==? 'py'
let b:epuppet_subtype = 'python'
elseif b:epuppet_subtype == 'rs'
elseif b:epuppet_subtype ==? 'rs'
let b:epuppet_subtype = 'rust'
elseif b:epuppet_subtype == ''
elseif b:epuppet_subtype ==?''
let b:epuppet_subtype = g:epuppet_default_subtype
endif
endif

if exists("b:epuppet_subtype") && b:epuppet_subtype != '' && b:epuppet_subtype !=? 'epuppet'
exe "runtime! ftplugin/".b:epuppet_subtype.".vim ftplugin/".b:epuppet_subtype."_*.vim ftplugin/".b:epuppet_subtype."/*.vim"
if exists('b:epuppet_subtype') && b:epuppet_subtype != '' && b:epuppet_subtype !=? 'epuppet'
exe 'runtime! ftplugin/'.b:epuppet_subtype.'.vim ftplugin/'.b:epuppet_subtype.'_*.vim ftplugin/'.b:epuppet_subtype.'/*.vim'
endif
unlet! b:did_ftplugin

Expand Down
28 changes: 14 additions & 14 deletions syntax/epuppet.vim
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,38 @@ if exists('b:current_syntax')
finish
endif

if !exists("g:epuppet_default_subtype")
let g:epuppet_default_subtype = "sh"
if !exists('g:epuppet_default_subtype')
let g:epuppet_default_subtype = 'sh'
endif

if &filetype =~ '^epuppet\.'
if &filetype =~# '^epuppet\.'
let b:epuppet_subtype = matchstr(&filetype,'^epuppet\.\zs\w\+')
elseif !exists('b:epuppet_subtype')
let b:epuppet_subtype = matchstr(substitute(expand("%:t"),'\c\%(\.epp\)\+$','',''),'\.\zs\w\+\%(\ze+\w\+\)\=$')
let b:epuppet_subtype = matchstr(substitute(expand('%:t'),'\c\%(\.epp\)\+$','',''),'\.\zs\w\+\%(\ze+\w\+\)\=$')
" TODO instead of listing exceptions like this, can we instead recognize
" extension -> type mapping?
if b:epuppet_subtype == 'rhtml'
if b:epuppet_subtype ==? 'rhtml'
let b:epuppet_subtype = 'html'
elseif b:epuppet_subtype == 'rb'
elseif b:epuppet_subtype ==? 'rb'
let b:epuppet_subtype = 'ruby'
elseif b:epuppet_subtype == 'yml'
elseif b:epuppet_subtype ==? 'yml'
let b:epuppet_subtype = 'yaml'
elseif b:epuppet_subtype == 'js'
elseif b:epuppet_subtype ==? 'js'
let b:epuppet_subtype = 'javascript'
elseif b:epuppet_subtype == 'txt'
elseif b:epuppet_subtype ==? 'txt'
" Conventional; not a real file type
let b:epuppet_subtype = 'text'
elseif b:epuppet_subtype == 'py'
elseif b:epuppet_subtype ==? 'py'
let b:epuppet_subtype = 'python'
elseif b:epuppet_subtype == 'rs'
elseif b:epuppet_subtype ==? 'rs'
let b:epuppet_subtype = 'rust'
elseif b:epuppet_subtype == ''
elseif b:epuppet_subtype ==? ''
let b:epuppet_subtype = g:epuppet_default_subtype
endif
endif

if exists("b:epuppet_subtype") && b:epuppet_subtype != '' && b:epuppet_subtype !=? 'epuppet'
exe "runtime! syntax/".b:epuppet_subtype.".vim"
if exists('b:epuppet_subtype') && b:epuppet_subtype != '' && b:epuppet_subtype !=? 'epuppet'
exe 'runtime! syntax/'.b:epuppet_subtype.'.vim'
unlet! b:current_syntax
endif

Expand Down

0 comments on commit 9ccb623

Please sign in to comment.