Patch 8.2.3686
Problem: Filetype detection often mixes up Forth and F#.
Solution: Add a function to inspect the file contents. (Doug Kearns)
Files: runtime/autoload/dist/ft.vim, runtime/doc/filetype.txt,
runtime/doc/syntax.txt, runtime/filetype.vim, runtime/scripts.vim,
src/testdir/test_filetype.vim
*** ../vim-8.2.3685/runtime/autoload/dist/ft.vim 2021-11-26 13:01:36.984427367 +0000
--- runtime/autoload/dist/ft.vim 2021-11-27 17:15:53.930582276 +0000
***************
*** 219,224 ****
--- 219,241 ----
endif
endfunc
+ " Distinguish between Forth and F#.
+ " Provided by Doug Kearns.
+ func dist#ft#FTfs()
+ if exists("g:filetype_fs")
+ exe "setf " . g:filetype_fs
+ else
+ let line = getline(nextnonblank(1))
+ " comments and colon definitions
+ if line =~ '^\s*\.\=( ' || line =~ '^\s*\\G\= ' || line =~ '^\\$'
+ \ || line =~ '^\s*: \S'
+ setf forth
+ else
+ setf fs
+ endif
+ endif
+ endfunc
+
" Distinguish between HTML, XHTML and Django
func dist#ft#FThtml()
let n = 1
*** ../vim-8.2.3685/runtime/doc/filetype.txt 2021-09-03 18:21:31.271026051 +0100
--- runtime/doc/filetype.txt 2021-11-27 17:13:50.615167069 +0000
***************
*** 139,156 ****
file name variable ~
*.asa g:filetype_asa |ft-aspvbs-syntax| |ft-aspperl-syntax|
- *.asp g:filetype_asp |ft-aspvbs-syntax| |ft-aspperl-syntax|
*.asm g:asmsyntax |ft-asm-syntax|
! *.prg g:filetype_prg
! *.pl g:filetype_pl
! *.inc g:filetype_inc
! *.w g:filetype_w |ft-cweb-syntax|
*.i g:filetype_i |ft-progress-syntax|
*.m g:filetype_m |ft-mathematica-syntax|
*.p g:filetype_p |ft-pascal-syntax|
*.pp g:filetype_pp |ft-pascal-syntax|
*.sh g:bash_is_sh |ft-sh-syntax|
*.tex g:tex_flavor |ft-tex-plugin|
*filetype-ignore*
To avoid that certain files are being inspected, the g:ft_ignore_pat variable
--- 139,157 ----
file name variable ~
*.asa g:filetype_asa |ft-aspvbs-syntax| |ft-aspperl-syntax|
*.asm g:asmsyntax |ft-asm-syntax|
! *.asp g:filetype_asp |ft-aspvbs-syntax| |ft-aspperl-syntax|
! *.fs g:filetype_fs |ft-forth-syntax|
*.i g:filetype_i |ft-progress-syntax|
+ *.inc g:filetype_inc
*.m g:filetype_m |ft-mathematica-syntax|
*.p g:filetype_p |ft-pascal-syntax|
+ *.pl g:filetype_pl
*.pp g:filetype_pp |ft-pascal-syntax|
+ *.prg g:filetype_prg
*.sh g:bash_is_sh |ft-sh-syntax|
*.tex g:tex_flavor |ft-tex-plugin|
+ *.w g:filetype_w |ft-cweb-syntax|
*filetype-ignore*
To avoid that certain files are being inspected, the g:ft_ignore_pat variable
***************
*** 545,550 ****
--- 546,559 ----
in the preview window. It is equivalent to calling "git diff --cached" plus
any arguments given to the command.
+ GPROF *ft-gprof-plugin*
+
+ The gprof filetype plugin defines a mapping <C-]> to jump from a function
+ entry in the gprof flat profile or from a function entry in the call graph
+ to the details of that function in the call graph.
+
+ The mapping can be disabled with: >
+ let g:no_gprof_maps = 1
MAIL *ft-mail-plugin*
*** ../vim-8.2.3685/runtime/doc/syntax.txt 2021-11-24 16:19:41.385010087 +0000
--- runtime/doc/syntax.txt 2021-11-27 17:13:50.615167069 +0000
***************
*** 1495,1500 ****
--- 1533,1546 ----
conditionals are LightBlue for better distinction.
+ FORTH *forth.vim* *ft-forth-syntax*
+
+ Files matching "*.fs" could be F# or Forth. If the automatic detection
+ doesn't work for you, or you don't edit F# at all, use this in your
+ startup vimrc: >
+ :let filetype_fs = "forth"
+
+
FORTRAN *fortran.vim* *ft-fortran-syntax*
Default highlighting and dialect ~
*** ../vim-8.2.3685/runtime/filetype.vim 2021-11-27 14:31:43.955527187 +0000
--- runtime/filetype.vim 2021-11-27 17:13:50.615167069 +0000
***************
*** 632,638 ****
au BufNewFile,BufRead *.mas,*.master setf master
" Forth
! au BufNewFile,BufRead *.fs,*.ft,*.fth setf forth
" Reva Forth
au BufNewFile,BufRead *.frt setf reva
--- 632,641 ----
au BufNewFile,BufRead *.mas,*.master setf master
" Forth
! au BufNewFile,BufRead *.ft,*.fth setf forth
!
! " F# or Forth
! au BufNewFile,BufRead *.fs call dist#ft#FTfs()
" Reva Forth
au BufNewFile,BufRead *.frt setf reva
*** ../vim-8.2.3685/runtime/scripts.vim 2021-11-16 15:28:05.451664358 +0000
--- runtime/scripts.vim 2021-11-27 17:13:50.615167069 +0000
***************
*** 198,203 ****
--- 198,207 ----
elseif s:name =~# 'fish\>'
set ft=fish
+ " Gforth
+ elseif s:name =~# 'gforth\>'
+ set ft=forth
+
endif
unlet s:name
*** ../vim-8.2.3685/src/testdir/test_filetype.vim 2021-11-27 14:31:43.955527187 +0000
--- src/testdir/test_filetype.vim 2021-11-27 17:13:50.615167069 +0000
***************
*** 182,192 ****
\ 'fgl': ['file.4gl', 'file.4gh', 'file.m4gl'],
\ 'fish': ['file.fish'],
\ 'focexec': ['file.fex', 'file.focexec'],
! \ 'forth': ['file.fs', 'file.ft', 'file.fth'],
\ 'fortran': ['file.f', 'file.for', 'file.fortran', 'file.fpp', 'file.ftn', 'file.f77', 'file.f90', 'file.f95', 'file.f03', 'file.f08'],
\ 'fpcmake': ['file.fpc'],
\ 'framescript': ['file.fsl'],
\ 'freebasic': ['file.fb', '
file.bi'],
\ 'fstab': ['fstab', 'mtab'],
\ 'fvwm': ['/.fvwm/file', 'any/.fvwm/file'],
\ 'gdb': ['.gdbinit', 'gdbinit'],
--- 182,193 ----
\ 'fgl': ['file.4gl', 'file.4gh', 'file.m4gl'],
\ 'fish': ['file.fish'],
\ 'focexec': ['file.fex', 'file.focexec'],
! \ 'forth': ['file.ft', 'file.fth'],
\ 'fortran': ['file.f', 'file.for', 'file.fortran', 'file.fpp', 'file.ftn', 'file.f77', 'file.f90', 'file.f95', 'file.f03', 'file.f08'],
\ 'fpcmake': ['file.fpc'],
\ 'framescript': ['file.fsl'],
\ 'freebasic': ['file.fb', '
file.bi'],
+ \ 'fs': ['file.fs'],
\ 'fstab': ['fstab', 'mtab'],
\ 'fvwm': ['/.fvwm/file', 'any/.fvwm/file'],
\ 'gdb': ['.gdbinit', 'gdbinit'],
***************
*** 664,669 ****
--- 665,671 ----
\ 'fennel': [['#!/path/fennel']],
\ 'routeros': [['#!/path/rsc']],
\ 'fish': [['#!/path/fish']],
+ \ 'forth': [['#!/path/gforth']],
\ }
" Various forms of "env" optional arguments.
***************
*** 970,973 ****
--- 972,1028 ----
filetype off
endfunc
+ func Test_fs_file()
+ filetype on
+
+ call writefile(['looks like F#'], 'Xfile.fs')
+ split Xfile.fs
+ call assert_equal('fs', &filetype)
+ bwipe!
+
+ let g:filetype_fs = 'forth'
+ split Xfile.fs
+ call assert_equal('forth', &filetype)
+ bwipe!
+ unlet g:filetype_fs
+
+ " Test dist#ft#FTfs()
+
+ " Forth (Gforth)
+
+ call writefile(['( Forth inline comment )'], 'Xfile.fs')
+ split Xfile.fs
+ call assert_equal('forth', &filetype)
+ bwipe!
+
+ call writefile(['.( Forth displayed inline comment )'], 'Xfile.fs')
+ split Xfile.fs
+ call assert_equal('forth', &filetype)
+ bwipe!
+
+ call writefile(['\ Forth line comment'], 'Xfile.fs')
+ split Xfile.fs
+ call assert_equal('forth', &filetype)
+ bwipe!
+
+ " empty line comment - no space required
+ call writefile(['\'], 'Xfile.fs')
+ split Xfile.fs
+ call assert_equal('forth', &filetype)
+ bwipe!
+
+ call writefile(['\G Forth documentation comment '], 'Xfile.fs')
+ split Xfile.fs
+ call assert_equal('forth', &filetype)
+ bwipe!
+
+ call writefile([': squared ( n -- n^2 )', 'dup * ;'], 'Xfile.fs')
+ split Xfile.fs
+ call assert_equal('forth', &filetype)
+ bwipe!
+
+ call delete('Xfile.fs')
+ filetype off
+ endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
*** ../vim-8.2.3685/src/version.c 2021-11-27 14:31:43.955527187 +0000
--- src/version.c 2021-11-27 17:15:13.306767863 +0000
***************
*** 759,760 ****
--- 759,762 ----
{ /* Add new patch number below this line */
+ /**/
+ 3686,
/**/
--
Every time I lose weight, it finds me again!
/// Bram Moolenaar -- Br...@Moolenaar.net --
http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features --
http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims --
http://ICCF-Holland.org ///