summaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-11-27 17:22:07 +0000
committerBram Moolenaar <Bram@vim.org>2021-11-27 17:22:07 +0000
commit3d14c0f2b964195d08b34bb43f89ec5f99255194 (patch)
tree163e4b2f4c8ec11c664d0a0bc92e41da1f87a2a8 /runtime
parentc07f11e42fc2eac5e750bf05aa3030f9b02a22ca (diff)
downloadvim-git-3d14c0f2b964195d08b34bb43f89ec5f99255194.tar.gz
patch 8.2.3686: filetype detection often mixes up Forth and F#v8.2.3686
Problem: Filetype detection often mixes up Forth and F#. Solution: Add a function to inspect the file contents. (Doug Kearns)
Diffstat (limited to 'runtime')
-rw-r--r--runtime/autoload/dist/ft.vim17
-rw-r--r--runtime/doc/filetype.txt19
-rw-r--r--runtime/doc/syntax.txt8
-rw-r--r--runtime/filetype.vim5
-rw-r--r--runtime/scripts.vim4
5 files changed, 47 insertions, 6 deletions
diff --git a/runtime/autoload/dist/ft.vim b/runtime/autoload/dist/ft.vim
index 344889249..0cbcb1bbb 100644
--- a/runtime/autoload/dist/ft.vim
+++ b/runtime/autoload/dist/ft.vim
@@ -219,6 +219,23 @@ func dist#ft#FTe()
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
diff --git a/runtime/doc/filetype.txt b/runtime/doc/filetype.txt
index 38622a426..8cb2e118a 100644
--- a/runtime/doc/filetype.txt
+++ b/runtime/doc/filetype.txt
@@ -139,18 +139,19 @@ can be used to overrule the filetype used for certain extensions:
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|
+ *.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
@@ -538,6 +539,14 @@ Options:
For further discussion of fortran_have_tabs and the method used for the
detection of source format see |ft-fortran-syntax|.
+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
GIT COMMIT *ft-gitcommit-plugin*
diff --git a/runtime/doc/syntax.txt b/runtime/doc/syntax.txt
index 08d3f5f11..3bc5cf4b0 100644
--- a/runtime/doc/syntax.txt
+++ b/runtime/doc/syntax.txt
@@ -1533,6 +1533,14 @@ gvim display. Here, statements are colored LightYellow instead of Yellow, and
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 ~
diff --git a/runtime/filetype.vim b/runtime/filetype.vim
index dcef709ed..fd3998b29 100644
--- a/runtime/filetype.vim
+++ b/runtime/filetype.vim
@@ -632,7 +632,10 @@ au BufNewFile,BufRead auto.master setf conf
au BufNewFile,BufRead *.mas,*.master setf master
" Forth
-au BufNewFile,BufRead *.fs,*.ft,*.fth setf 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
diff --git a/runtime/scripts.vim b/runtime/scripts.vim
index 0ff8e4908..3790b1c10 100644
--- a/runtime/scripts.vim
+++ b/runtime/scripts.vim
@@ -198,6 +198,10 @@ if s:line1 =~# "^#!"
elseif s:name =~# 'fish\>'
set ft=fish
+ " Gforth
+ elseif s:name =~# 'gforth\>'
+ set ft=forth
+
endif
unlet s:name