# Vim functions for file type detection
#
# Maintainer: The Vim Project <https://github.com/vim/vim>
-# Last Change: 2025 Nov 30
+# Last Change: 2025 Dec 07
# Former Maintainer: Bram Moolenaar <Bram@vim.org>
# These functions are moved here from runtime/filetype.vim to make startup
endif
enddef
+# Erlang Application Resource Files (*.app.src is matched by extension)
+# See: https://erlang.org/doc/system/applications
+export def FTapp()
+ if exists("g:filetype_app")
+ exe "setf " .. g:filetype_app
+ return
+ endif
+ const pat = '^\s*{\s*application\s*,\s*\(''\=\)' .. expand("%:t:r:r") .. '\1\s*,'
+ var line: string
+ for lnum in range(1, min([line("$"), 100]))
+ line = getline(lnum)
+ # skip Erlang comments, might be something else
+ if line =~ '^\s*%' || line =~ '^\s*$'
+ continue
+ elseif line =~ '^\s*{' &&
+ getline(lnum, lnum + 9)->filter((_, v) => v !~ '^\s*%')->join(' ') =~# pat
+ setf erlang
+ endif
+ return
+ endfor
+enddef
+
# This function checks for the kind of assembly that is wanted by the user, or
# can be detected from the beginning of the file.
export def FTasm()
-*filetype.txt* For Vim version 9.1. Last change: 2025 Nov 09
+*filetype.txt* For Vim version 9.1. Last change: 2025 Dec 07
VIM REFERENCE MANUAL by Bram Moolenaar
variables can be used to overrule the filetype used for certain extensions:
file name variable ~
+ *.app g:filetype_app
*.asa g:filetype_asa |ft-aspperl-syntax|
|ft-aspvbs-syntax|
*.asm g:asmsyntax |ft-asm-syntax|
" Elm Filter Rules file
au BufNewFile,BufRead filter-rules setf elmfilt
-" Erlang
+" Erlang Application Resource Files
au BufNewFile,BufRead *.app.src setf erlang
+au BufNewFile,BufRead *.app call dist#ft#FTapp()
" ESMTP rc file
au BufNewFile,BufRead *esmtprc setf esmtprc
filetype off
endfunc
+" Erlang Application Resource File
+func Test_app_file()
+ filetype on
+
+ call writefile(['% line comment', '{application, xfile1,'], 'xfile1.app', 'D')
+ split xfile1.app
+ call assert_equal('erlang', &filetype)
+ bwipe!
+
+ call writefile(['% line comment', "{application, 'Xfile2',"], 'Xfile2.app', 'D')
+ split Xfile2.app
+ call assert_equal('erlang', &filetype)
+ bwipe!
+
+ call writefile([' % line comment',
+ \ ' ',
+ \ ' % line comment',
+ \ ' { ',
+ \ ' % line comment ',
+ \ ' application , ',
+ \ ' % line comment ',
+ \ ' xfile3 , '],
+ \ 'xfile3.app', 'D')
+ split xfile3.app
+ call assert_equal('erlang', &filetype)
+ bwipe!
+
+ filetype off
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
static int included_patches[] =
{ /* Add new patch number below this line */
+/**/
+ 1962,
/**/
1961,
/**/