Skip to content

Commit

Permalink
Use setf instead of set=
Browse files Browse the repository at this point in the history
  • Loading branch information
Igor Kapkov committed Jan 3, 2015
1 parent 0daaa85 commit 1ac9ebd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion ftdetect/slim.vim
Original file line number Diff line number Diff line change
@@ -1 +1 @@
autocmd BufNewFile,BufRead *.slim set filetype=slim
autocmd BufNewFile,BufRead *.slim setf slim

7 comments on commit 1ac9ebd

@rapind
Copy link

@rapind rapind commented on 1ac9ebd Aug 26, 2016

Choose a reason for hiding this comment

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

@igas was there a reason for changing this back? You now lose indenting in files that start with a doctype html due to this change.

Seems like this has gone back and forth for some reason over the years: https://github.com/slim-template/vim-slim/commits/master/ftdetect/slim.vim

Relevant issue: github.com//issues/38

@ixti
Copy link
Member

@ixti ixti commented on 1ac9ebd Aug 27, 2016

Choose a reason for hiding this comment

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

According to vim docs, I believe we should use setf (gonna change that back in my PR or will close PR completely -- gonna check who sets ft incorrectly first)

@igas
Copy link
Contributor

@igas igas commented on 1ac9ebd Aug 28, 2016

Choose a reason for hiding this comment

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

@rapind yes, as @ixti said this is better way to do it, but due to some other pachages/bugs it doesn't work as expected. This suppose to do it only ones instead of each time.

@rapind
Copy link

@rapind rapind commented on 1ac9ebd Aug 29, 2016

Choose a reason for hiding this comment

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

@igas interesting.

According to the docs you want to use setf so you don't override what may have already been set. So it follows that doctype html is kept by vim when using setf. So it's not a bug and just an unfortunate side effect of specifying doctype when using setf. There was a previous discussion here where they seem to have opted for set filetype. #38

I recommend using set filetype instead though as it results in the least surprise for users of this plugin.


From the docs:

Include this autocommand to .vimrc, if you do NOT want to override a previous filetype detection, but only set a filetype if the filetype was not detected at all:

" associate *.foo with php filetype
au BufRead,BufNewFile *.foo setfiletype php

To override any filetype which was already detected, use this instead (note the 'set filetype=' syntax):

au BufRead,BufNewFile *.module set filetype=php

@ixti
Copy link
Member

@ixti ixti commented on 1ac9ebd Aug 29, 2016

Choose a reason for hiding this comment

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

What about (pushed a patch to PR) using set filetype=slim on *.slim if first line is doctype html, and setf otherwise.

@rapind
Copy link

@rapind rapind commented on 1ac9ebd Aug 29, 2016

Choose a reason for hiding this comment

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

@ixti pretty cool. I'm still struggling to see what the use case is for wanting to keep an existing syntax on a slim file when you have this plugin enabled though. Before adding the extra conditional (complexity) can someone suggest a use case where setf is better for *.slim files?

@ixti
Copy link
Member

@ixti ixti commented on 1ac9ebd Aug 29, 2016

Choose a reason for hiding this comment

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

The use case is when by some unexpected reason user would like to have different filetype on *.slim files (e.g. some other utility will have same name for it's files) based on some complex rules. In fact after the discussion and attempts to find best solution I think the BEST solutions is to avoid to decide for user HOW he wants ftdetect of slim to work. gonna provede a better patch on PR :D

Please sign in to comment.