aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim
diff options
context:
space:
mode:
authorGaƩtan Lepage <33058747+GaetanLepage@users.noreply.github.com>2023-05-11 09:43:02 +0200
committerGitHub <noreply@github.com>2023-05-11 15:43:02 +0800
commite90b506903babc84f8c5b796c3b25c7f20e183d2 (patch)
tree64bf8a3b9107af2d2b9710f821faf05981932de8 /runtime/lua/vim
parent9d306ac6b79c13b5f42ea4e22c6f8ccc628f6a6a (diff)
downloadrneovim-e90b506903babc84f8c5b796c3b25c7f20e183d2.tar.gz
rneovim-e90b506903babc84f8c5b796c3b25c7f20e183d2.tar.bz2
rneovim-e90b506903babc84f8c5b796c3b25c7f20e183d2.zip
vim-patch:9.0.1539: typst filetype is not recognized (#23578)
Problem: Typst filetype is not recognized. Solution: Distinguish between sql and typst. (Gaetan Lepage, closes vim/vim#12363) https://github.com/vim/vim/commit/4ce1bda869e4ec0152d7dcbe1e491ceac5341d5e
Diffstat (limited to 'runtime/lua/vim')
-rw-r--r--runtime/lua/vim/filetype.lua4
-rw-r--r--runtime/lua/vim/filetype/detect.lua22
2 files changed, 25 insertions, 1 deletions
diff --git a/runtime/lua/vim/filetype.lua b/runtime/lua/vim/filetype.lua
index 5c799b23f2..c746eef1bb 100644
--- a/runtime/lua/vim/filetype.lua
+++ b/runtime/lua/vim/filetype.lua
@@ -997,7 +997,9 @@ local extension = {
spi = 'spyce',
spy = 'spyce',
tyc = 'sql',
- typ = 'sql',
+ typ = function(path, bufnr)
+ return require('vim.filetype.detect').typ(bufnr)
+ end,
pkb = 'sql',
tyb = 'sql',
pks = 'sql',
diff --git a/runtime/lua/vim/filetype/detect.lua b/runtime/lua/vim/filetype/detect.lua
index 74b01d569c..94106a3547 100644
--- a/runtime/lua/vim/filetype/detect.lua
+++ b/runtime/lua/vim/filetype/detect.lua
@@ -1322,6 +1322,28 @@ function M.txt(bufnr)
end
end
+function M.typ(bufnr)
+ if vim.g.filetype_typ then
+ return vim.g.filetype_typ
+ end
+
+ for _, line in ipairs(getlines(bufnr, 1, 200)) do
+ if
+ findany(line, {
+ '^CASE[%s]?=[%s]?SAME$',
+ '^CASE[%s]?=[%s]?LOWER$',
+ '^CASE[%s]?=[%s]?UPPER$',
+ '^CASE[%s]?=[%s]?OPPOSITE$',
+ '^TYPE%s',
+ })
+ then
+ return 'sql'
+ end
+ end
+
+ return 'typst'
+end
+
-- Determine if a .v file is Verilog, V, or Coq
function M.v(bufnr)
if vim.fn.did_filetype() ~= 0 then