feat(filetype.lua): Add typescript extension to filetype detection (#16923)

port from `filetype.vim`; also add `getline` convenience function
This commit is contained in:
Robin Gagnon 2022-01-04 16:34:55 -05:00 committed by GitHub
parent 39238435db
commit 8ade8009ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -19,6 +19,10 @@ local function starsetf(ft)
}}
end
local function getline(bufnr, lnum)
return api.nvim_buf_get_lines(bufnr, lnum-1, lnum, false)[1]
end
-- Filetypes based on file extension
local extension = {
-- BEGIN EXTENSION
@ -635,6 +639,13 @@ local extension = {
tssop = "tssop",
tutor = "tutor",
twig = "twig",
ts = function(path, bufnr)
if getline(bufnr, 1):find("<%?xml") then
return "xml"
else
return "typescript"
end
end,
tsx = "typescriptreact",
uc = "uc",
uit = "uil",