Change filetype detection for .sc

The code used deprecated functions and I don't use Supercollider anyway,
so make .sc always be a scala file
This commit is contained in:
Alexander Gehrke 2024-05-29 15:24:43 +02:00
parent 0223565b9a
commit c6010628ca
2 changed files with 10 additions and 33 deletions

View file

@ -1,18 +1,19 @@
vim.filetype.add({
extension = {
['vtt'] = 'vtt',
['typ'] = 'typst',
["vtt"] = "vtt",
["typ"] = "typst",
["sc"] = "scala",
},
filename = {
['.scalafmt.conf'] = 'hocon',
['kitty.conf'] = 'kitty',
['neomuttrc'] = 'neomutt',
['template'] = 'sh',
['mbsyncrc'] = 'mbsyncrc',
[".scalafmt.conf"] = "hocon",
["kitty.conf"] = "kitty",
["neomuttrc"] = "neomutt",
["template"] = "sh",
["mbsyncrc"] = "mbsyncrc",
},
pattern = {
['${XDG_CONFIG_HOME}/kitty/*.conf'] = 'kitty',
['${XDG_CONFIG_HOME}/kitty/*.session'] = 'kitty-session',
["${XDG_CONFIG_HOME}/kitty/*.conf"] = "kitty",
["${XDG_CONFIG_HOME}/kitty/*.session"] = "kitty-session",
},
})

View file

@ -1,24 +0,0 @@
-- Override detection from lua/vim/filetype/detect.lua
-- removes match on |%w+| for SuperCollider
vim.filetype.add({
extension = {
-- This function checks the first 25 lines of file extension "sc" to resolve
-- detection between scala and SuperCollider
sc = function(path, bufnr)
for _, line in ipairs(vim.filetype.getlines(bufnr, 1, 25)) do
if
vim.filetype.findany(line, {
'var%s<',
'classvar%s<',
'%^this.*',
'%+%s%w*%s{',
'%*ar%s',
})
then
return 'supercollider'
end
end
return 'scala'
end
}
})