Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use setfiletype instead of set filetype #31

Merged
merged 1 commit into from
May 28, 2021

Conversation

doronbehar
Copy link
Contributor

Hi,

This is kind of hard to explain, and I can't really point to the right location in the docs that explains this, but the TL;DR of this change is:

Enable me to add something like this to my filetype.vim

" Nixpkgs
au BufNewFile,BufRead /var/src/nixpkgs/** setf nix.nixpkgs

(While I set some extra settings to ftplugin/nixpkgs.vim).

I've learned about this subtlety at neomutt/neomutt.vim#4 .

This enables users to override the filetype detection behavior while
keeping the plugin installed.
@doronbehar
Copy link
Contributor Author

BTW great plugin! Without you it'd have taken me a month to get errorformat as I needed :).

@bew
Copy link

bew commented Oct 28, 2020

This is a good change! The docs of setfiletype explains it quite well:

:setf[iletype] {filetype}			*:setf* *:setfiletype*
			Set the 'filetype' option to {filetype}, but only if
			not done yet 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.
			{not in Vi}

Since plugins autocommands are run after user ones, we can't override the filetype if we want to change it a little like @doronbehar shows.

Copy link
Owner

@LnL7 LnL7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting I didn't realise there was a difference between setfiletype and set filetype.

@LnL7 LnL7 merged commit 63b47b3 into LnL7:master May 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants