tpope / vim-sleuth

sleuth.vim: Heuristically set buffer options
https://www.vim.org/scripts/script.php?script_id=4375
1.92k stars 86 forks source link

vim-sleuth + vim-javascript = no indent at all #25

Closed danielfalk closed 9 years ago

danielfalk commented 9 years ago

The notes for sleuth are quite clear: if a file is indented by tabs, then shiftwidth is set to 0. This creates a problem when I want to use vim-javascript. It seems that it wants to use the shiftwidth to indent, hence no indent at all.

So this is partly an issue, and partly a question. Which is the correct behavior? vim-javascript, or vim-sleuth? I don't know myself, but looking here: http://vim.wikia.com/wiki/Indenting_source_code suggests that shiftwidth should be the same value as tabstop (see section "Indentation purely with hard tabs").

Incidentally, I have ts=4 and sw=4 in my vimrc, but sleuth overwrites this value for the js file I'm trying to edit.

Thank you for your attention.

tpope commented 9 years ago

This is a pretty severe unintended consequence of b6b4c3b237678f1214ea2eca0e3e50eaafb30e3a. I'll revert.

axiom commented 9 years ago

(I do believe this is due to vim-javascript using &sw instead of the recommended shiftwidth().)

tpope commented 9 years ago

Yes, but shiftwidth() is brand new as of 7.4, while 'shiftwidth' is as old as vi itself. The transition will take years.

fd0 commented 9 years ago

For the record: https://github.com/fatih/vim-go had the same problem: https://github.com/fatih/vim-go/pull/308, I proposed to use shiftwidth(), which was accepted.