Mercurial > vim
diff runtime/autoload/dist/ft.vim @ 30023:87063bfe81cd v9.0.0349
patch 9.0.0349: filetype of *.sil files not well detected
Commit: https://github.com/vim/vim/commit/be807d582499acbe314ead3891481cba6ca136df
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Sep 1 15:01:25 2022 +0100
patch 9.0.0349: filetype of *.sil files not well detected
Problem: Filetype of *.sil files not well detected.
Solution: Inspect the file contents to guess the filetype.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 01 Sep 2022 16:15:03 +0200 |
parents | 2198955f9e27 |
children | d4c8fdaa3ae7 |
line wrap: on
line diff
--- a/runtime/autoload/dist/ft.vim +++ b/runtime/autoload/dist/ft.vim @@ -878,6 +878,23 @@ export def FTsig() endif enddef +# This function checks the first 100 lines of files matching "*.sil" to +# resolve detection between Swift Intermediate Language and SILE. +export def FTsil() + for lnum in range(1, [line('$'), 100]->min()) + var line: string = getline(lnum) + if line =~ '^\s*[\\%]' + setf sile + return + elseif line =~ '^\s*\S' + setf sil + return + endif + endfor + # no clue, default to "sil" + setf sil +enddef + export def FTsys() if exists("g:filetype_sys") exe "setf " .. g:filetype_sys