diff options
author | Robin Gagnon <me@reobin.dev> | 2022-01-04 16:34:55 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-04 22:34:55 +0100 |
commit | 8ade8009ee1fb508bf94ca6c8c3cd288f051c55b (patch) | |
tree | 10af0369b2f3049a7876567f0b90505157bd67cf | |
parent | 39238435dbfc632356d10f287994c80142dd95bd (diff) | |
download | rneovim-8ade8009ee1fb508bf94ca6c8c3cd288f051c55b.tar.gz rneovim-8ade8009ee1fb508bf94ca6c8c3cd288f051c55b.tar.bz2 rneovim-8ade8009ee1fb508bf94ca6c8c3cd288f051c55b.zip |
feat(filetype.lua): Add typescript extension to filetype detection (#16923)
port from `filetype.vim`; also add `getline` convenience function
-rw-r--r-- | runtime/lua/vim/filetype.lua | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua index f7048f3709..bbcbe53eaa 100644 --- a/runtime/lua/vim/filetype.lua +++ b/runtime/lua/vim/filetype.lua @@ -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", |