On 2021-11-21, lacygoill wrote:
> This is probably not the right fix but it might give an idea to someone else:
>
> diff --git a/runtime/filetype.vim b/runtime/filetype.vim
> index c4c9cb904..d8c40196f 100644
> --- a/runtime/filetype.vim
> +++ b/runtime/filetype.vim
> @@ -632,7 +632,8 @@ 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
> +au BufNewFile,BufRead *.fs setf FALLBACK fsharp
>
> " Reva Forth
> au BufNewFile,BufRead *.frt setf reva
> diff --git a/runtime/scripts.vim b/runtime/scripts.vim
> index 0ff8e4908..612ed8dfd 100644
> --- a/runtime/scripts.vim
> +++ b/runtime/scripts.vim
> @@ -270,6 +270,14 @@ else
> \ || s:line5 =~# '^\s*dnl\>'
> set ft=m4
>
> + " forth scripts: Guess there is a line that starts with a colon
> + elseif s:line1 =~# '^\s*:\s\+'
> + \ || s:line2 =~# '^\s*:\s\+'
> + \ || s:line3 =~# '^\s*:\s\+'
> + \ || s:line4 =~# '^\s*:\s\+'
> + \ || s:line5 =~# '^\s*:\s\+'
> + set ft=forth
> +
> " AmigaDos scripts
> elseif $TERM == "amiga"
> \ && (s:line1 =~# "^;" || s:line1 =~? '^\.bra')
>
> With this patch, a file with an .fs extension is detected as fsharp by
> default.
> But if one of the first 5 lines starts with a colon, it's detected as forth
> instead.
>
> For anyone who can think of a better detection logic but doesn't know how to
> implement it, see :help new-filetype-scripts for more help. Then start Vim
> with
> this shell command:
>
> VIMRUNTIME=/path/to/my/local/vim vim -Nu NORC --cmd 'filetype plugin on'
> /tmp/fs.fs
I agree that something should be done to accommodate F# users.
However, I think it is bad form to change the default behavior of
Vim so that existing users who are used to behavior that has always
"just worked" have to change their behavior for the sake of that
accommodation. If Vim can't determine the filetype of an .fs file
with reasonable confidence, it should default to Forth, not F#.
How about adding a global configuration variable, to be used by
$VIMRUNTIME/filetype.vim, that Forth users could set in their vimrc
files? This would be simpler than requiring all of them to add
their own ~/.vim/filetype.vim or ~/vimfiles/filetype.vim file or to
add an autocommand to their vimrc. For example:
let g:fs_is_fsharp = 1
Regards,
Gary
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/20211121203446.GB12715%40phoenix.