summaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorGaetan Lepage <gaetan@glepage.com>2023-05-10 22:01:55 +0100
committerBram Moolenaar <Bram@vim.org>2023-05-10 22:01:55 +0100
commit4ce1bda869e4ec0152d7dcbe1e491ceac5341d5e (patch)
tree349509e1ca04cb29840c2aa33b519a856567a7a4 /runtime
parent411da64e77ef9d8edd1a5aa80fa5b9a4b159c93d (diff)
downloadvim-git-4ce1bda869e4ec0152d7dcbe1e491ceac5341d5e.tar.gz
patch 9.0.1539: typst filetype is not recognizedv9.0.1539
Problem: Typst filetype is not recognized. Solution: Distinguish between sql and typst. (Gaetan Lepage, closes #12363)
Diffstat (limited to 'runtime')
-rw-r--r--runtime/autoload/dist/ft.vim27
-rw-r--r--runtime/doc/filetype.txt1
-rw-r--r--runtime/filetype.vim5
3 files changed, 31 insertions, 2 deletions
diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim
index 3d9d60a75..7ac053eb2 100644
--- a/runtime/autoload/dist/ft.vim
+++ b/runtime/autoload/dist/ft.vim
@@ -470,7 +470,7 @@ enddef
# Returns true if file content looks like LambdaProlog module
def IsLProlog(): bool
- # skip apparent comments and blank lines, what looks like
+ # skip apparent comments and blank lines, what looks like
# LambdaProlog comment may be RAPID header
var l: number = nextnonblank(1)
while l > 0 && l < line('$') && getline(l) =~ '^\s*%' # LambdaProlog comment
@@ -1106,6 +1106,31 @@ export def FTlsl()
endif
enddef
+export def FTtyp()
+ if exists("g:filetype_typ")
+ exe "setf " .. g:filetype_typ
+ return
+ endif
+
+ # Look for SQL type definition syntax
+ for line in getline(1, 200)
+ # SQL type files may define the casing
+ if line =~ '^CASE\s\==\s\=\(SAME\|LOWER\|UPPER\|OPPOSITE\)$'
+ setf sql
+ return
+ endif
+
+ # SQL type files may define some types as follows
+ if line =~ '^TYPE\s.*$'
+ setf sql
+ return
+ endif
+ endfor
+
+ # Otherwise, affect the typst filetype
+ setf typst
+enddef
+
# Set the filetype of a *.v file to Verilog, V or Cog based on the first 200
# lines.
export def FTv()
diff --git a/runtime/doc/filetype.txt b/runtime/doc/filetype.txt
index b8686a189..477ea7b25 100644
--- a/runtime/doc/filetype.txt
+++ b/runtime/doc/filetype.txt
@@ -164,6 +164,7 @@ variables can be used to overrule the filetype used for certain extensions:
*.sys g:filetype_sys
*.sh g:bash_is_sh |ft-sh-syntax|
*.tex g:tex_flavor |ft-tex-plugin|
+ *.typ g:filetype_typ
*.w g:filetype_w |ft-cweb-syntax|
For a few filetypes the global variable is used only when the filetype could
diff --git a/runtime/filetype.vim b/runtime/filetype.vim
index 38db8a23b..7618902fd 100644
--- a/runtime/filetype.vim
+++ b/runtime/filetype.vim
@@ -2058,7 +2058,10 @@ au BufNewFile,BufRead *.spy,*.spi setf spyce
au BufNewFile,BufRead squid.conf setf squid
" SQL for Oracle Designer
-au BufNewFile,BufRead *.tyb,*.typ,*.tyc,*.pkb,*.pks setf sql
+au BufNewFile,BufRead *.tyb,*.tyc,*.pkb,*.pks setf sql
+
+" *.typ can be either SQL or Typst files
+au BufNewFile,BufRead *.typ call dist#ft#FTtyp()
" SQL
au BufNewFile,BufRead *.sql call dist#ft#SQL()