mirror of
https://github.com/neovim/neovim.git
synced 2024-12-31 17:13:26 -07:00
feat(filetype.lua): Add typescript extension to filetype detection (#16923)
port from `filetype.vim`; also add `getline` convenience function
This commit is contained in:
parent
39238435db
commit
8ade8009ee
@ -19,6 +19,10 @@ local function starsetf(ft)
|
|||||||
}}
|
}}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function getline(bufnr, lnum)
|
||||||
|
return api.nvim_buf_get_lines(bufnr, lnum-1, lnum, false)[1]
|
||||||
|
end
|
||||||
|
|
||||||
-- Filetypes based on file extension
|
-- Filetypes based on file extension
|
||||||
local extension = {
|
local extension = {
|
||||||
-- BEGIN EXTENSION
|
-- BEGIN EXTENSION
|
||||||
@ -635,6 +639,13 @@ local extension = {
|
|||||||
tssop = "tssop",
|
tssop = "tssop",
|
||||||
tutor = "tutor",
|
tutor = "tutor",
|
||||||
twig = "twig",
|
twig = "twig",
|
||||||
|
ts = function(path, bufnr)
|
||||||
|
if getline(bufnr, 1):find("<%?xml") then
|
||||||
|
return "xml"
|
||||||
|
else
|
||||||
|
return "typescript"
|
||||||
|
end
|
||||||
|
end,
|
||||||
tsx = "typescriptreact",
|
tsx = "typescriptreact",
|
||||||
uc = "uc",
|
uc = "uc",
|
||||||
uit = "uil",
|
uit = "uil",
|
||||||
|
Loading…
Reference in New Issue
Block a user