aboutsummaryrefslogtreecommitdiff
path: root/runtime/doc
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2026-09-17 16:56:45 -0400
committerGitHub <noreply@github.com>2026-09-17 16:56:45 -0400
commit6ad6dcd5d4ca2cbe28de8ea5ffe77cfee40a7004 (patch)
tree321be87303392ebcaa9f9f985373c8aa53772fdc /runtime/doc
parentd1fd8158de63107d2ada9f69c1a491d76edfc9aa (diff)
downloadrneovim-6ad6dcd5d4ca2cbe28de8ea5ffe77cfee40a7004.tar.gz
rneovim-6ad6dcd5d4ca2cbe28de8ea5ffe77cfee40a7004.tar.bz2
rneovim-6ad6dcd5d4ca2cbe28de8ea5ffe77cfee40a7004.zip
fix(filetype): empty 'filetype' skips :setfiletype #41958
Problem: After `:restart` a restored buffer can have an empty 'filetype'. Lazy LSP setup during the read replays FileType via `:doautoall`, which sets `did_filetype` even though `filetype=''`. :e foo.md :restart :set ft? " filetype= Solution: Set `did_filetype` only if 'filetype' is non-empty.
Diffstat (limited to 'runtime/doc')
-rw-r--r--runtime/doc/options.txt11
-rw-r--r--runtime/doc/vimfn.txt7
2 files changed, 10 insertions, 8 deletions
diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt
index 5581733fbc..d82b7a2f88 100644
--- a/runtime/doc/options.txt
+++ b/runtime/doc/options.txt
@@ -462,15 +462,16 @@ reads back as the function (from Lua) or a `"<Lua …>"` hint (Vimscript/RPC).
Setting the filetype
:setf[iletype] [FALLBACK] {filetype} *:setf* *:setfiletype*
- Set the 'filetype' option to {filetype}, but only if
- not done yet in a sequence of (nested) autocommands.
+ Set the 'filetype' option to {filetype}, unless it was
+ already set (non-empty) in a sequence of (nested)
+ autocommands.
This is short for: >
:if !did_filetype()
: setlocal filetype={filetype}
:endif
-< This command is used in a filetype.vim file to avoid
- setting the 'filetype' option twice, causing different
- settings and syntax files to be loaded.
+< Used in a filetype.vim file to avoid setting the
+ 'filetype' option twice, causing different settings
+ and syntax files to be loaded.
When the optional FALLBACK argument is present, a
later :setfiletype command will override the
diff --git a/runtime/doc/vimfn.txt b/runtime/doc/vimfn.txt
index f8e33e6d36..2ad24365fb 100644
--- a/runtime/doc/vimfn.txt
+++ b/runtime/doc/vimfn.txt
@@ -1743,10 +1743,11 @@ dictwatcherdel({dict}, {pattern}, {callback}) *dictwatcherdel()*
did_filetype() *did_filetype()*
Returns |TRUE| when autocommands are being executed and the
- FileType event has been triggered at least once. Can be used
- to avoid triggering the FileType event again in the scripts
- that detect the file type. |FileType|
+ FileType event triggered at least once for a buffer with
+ a non-empty 'filetype'. Can be used to avoid triggering
+ the FileType event again in the |ftdetect| scripts. |FileType|
Returns |FALSE| when `:setf FALLBACK` was used.
+
When editing another file, the counter is reset, thus this
really checks if the FileType event has been triggered for the
current buffer. This allows an autocommand that starts