Comments (11)
vim-sleuth struggles with mail. takes forever for vim to open within mutt (goes away when i remove plugin), so +1 for exclude ft support
from vim-sleuth.
Does it try to auto-detect settings even when you've explicitly configured them for the filetype?
from vim-sleuth.
The idea is that autocmd FileType go set sw=2
should override sleuth.vim. Though it might be possible to break it if you order things weird in your vimrc.
from vim-sleuth.
Okay, more analysis: Vim versions 7.4.488 and 7.4.622 exhibit identical behaviors with the following minimal .vimrc
:
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'gmarik/Vundle.vim'
"Plugin 'tpope/vim-sleuth'
call vundle#end()
filetype plugin indent on
au FileType go set ts=2 sw=2
This form (sleuth
disabled) works correctly, with ts=2
and the file described in #28 looking right. When uncommenting line 4 (sleuth
enabled), ts=8
, ignoring my setting. Moving the filetype
lines around the file doesn't seem to have any effect.
from vim-sleuth.
Yeah, there's no mystery why vim-sleuth overrides your custom settings. It registers an autocmd in plugin/sleuth.vim, after your vimrc executes, so the autocmd will fire late and override other autocmds. The question is whether there's anything vim-sleuth can do to give precedence to other plugins.
If there's nothing automatic, maybe a convention of setting b:options_applied
to disable sleuth's detection fallback would work:
au Filetype go set ts=2 sw=2 | let b:options_applied = 1
from vim-sleuth.
I could have sworn that I had this working, but you're right, the sleuth autocommand is defined later and will always win over the vimrc.
One thing you could do is stick your overrides in after/plugin/sleuth.vim
, or define them from within a VimEnter
autocommand.
au VimEnter * au indent_override FileType go set ts=2 sw=2
You could also explicitly runtime! plugin/sleuth.vim
before defining your autocommands.
These are all crude hacks, but I think they are better than b:options_applied
, which will stick around even if you change file types.
from vim-sleuth.
I ran into this again and added this to my vimrc as a workaround:
VAMActivate sleuth
" Workaround for https://github.com/tpope/vim-sleuth/issues/29.
" Define autocmd as early as possible so other autocmds can override.
runtime! plugin/sleuth.vim
The VimEnter option is much less flexible because it forces you to repeat your explicit configuration values inline. It's not an option if you want to give other filetype plugins control over indent settings instead of hard-coding your own.
I'd really appreciate a fix that could get vim-sleuth to have the right precedence out of the box, though. =)
from vim-sleuth.
A similar issue occurs with rst.vim, which uses 3-space indents (see marshallward/vim-restructuredtext#8 for rationale); but if you have item lists à la
- foo bar this is a loooooong
line
- and so on
then vim-sleuth will set a 2-space indent.
I'm not sure whether the autocommand ordering would make the following work, but perhaps(?) sleuth_automatic could be made a buffer-local variable, so that one could set b:sleuth_automatic to 0 in ~/.vim/ftplugin/foo.vim?
from vim-sleuth.
This would also be a great workaround for #43
from vim-sleuth.
Merged #44 which should provide for this. I also limited it to 20 neighbor files before giving up, which I have a hunch is what was causing the mail slowdown.
from vim-sleuth.
I've added options to opt-out of heuristic detection on a per-filetype basis:
let g:sleuth_mail_heuristics = 0
There's also g:sleuth_heuristics
to change it from opt-out to opt-in.
This is a bit less flexible than a buffer-local option, but easier to use and not subject to autocommand ordering issues, so I am deprecating b:sleuth_automatic
and maybe the global version too, unless someone gives me a good reason not to.
from vim-sleuth.
Related Issues (20)
- New release (last one is 7 years old) HOT 2
- Markdown files takes >= 20 seconds to load HOT 4
- Sleuth not working when a modeline is setting the filetype HOT 5
- `indentexpr` mysteriously set HOT 4
- Getting an error E121: Undefined variable: capture
- New changes cause tabstop=8 to be set in Go files HOT 1
- Disable for specific filetype HOT 5
- Do not run sleuth if buftype == terminal / prompt / popup HOT 1
- textwidth shouldn't be affected for gitcommit filetype HOT 3
- Extra newlines being inserted when using language server formatting HOT 21
- [Bug] Argument mismatch at s:ModelineOptions HOT 1
- Golang files tabstop is 8 HOT 9
- Option to disable EditorConfig override? HOT 10
- Set new file default tabstop? HOT 1
- echo execute() gives "Sleuth failed to detect indent settings" HOT 3
- eol/endofline is not inferred correctly (empty line at end of file always gets removed after editing) HOT 2
- Question: always show as 2 spaces in vim without editing actual file HOT 1
- Tabstop is 8 for LaTeX file HOT 4
- Failed to detect indent setting on .hpp files HOT 1
- Indentation being inferred from multiline string literal in Python code when a different pydoc (also a multiline str literal) has quotes in it
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vim-sleuth.