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

Automatically indent on "else" #31

Closed
rosenfeld opened this issue Feb 23, 2011 · 4 comments
Closed

Automatically indent on "else" #31

rosenfeld opened this issue Feb 23, 2011 · 4 comments
Labels

Comments

@rosenfeld
Copy link

Shouldn't the indent file include 'else' in indentkeys?

Setting identkeys to include 'e' doesn't seem to work (at least for me in Vim 7.3). On the other hand, it seems to work if I change (just included '=else') the indentkeys line to:

setlocal indentkeys+==end,=else,=elsif,=when,=ensure,=rescue,==begin,==end

Also, why does indentkeys include the default "0{,0},0),0], ^F,o,O,e"? I agree that ^F, 'o' and 'O' are useful, but I couldn't understand the other ones nor I could test if they are working. Maybe I didn't understand the documentation correctly.

@now
Copy link
Member

now commented Feb 23, 2011

Yes, it should and it does. The 'e' in indentkeys does just that. If it’s not working for you I would bet a lot that it’s either your syntax that’s broken or your configuration. Something as basic as that would have been caught a long time ago (I hope). I’m closing this, awaiting an actual example that breaks the indentation function.

The value of indentkeys is correct and why should be obvious from the documentation. If it isn’t, I suggest that you post to vim-dev and ask them (Bram) to clarify the documentation. To answer your question, however, the 0* are there to indent the character listed when it appears as the first non-indent character in the line.

@rosenfeld
Copy link
Author

Indeed. The culprit is the neocomplcache plugin in my configuration files. Here is what I use:

let g:neocomplcache_enable_at_startup = 1
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS 
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags 
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS 
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete 
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
"let g:neocomplcache_enable_auto_select = 1 
" Enable heavy omni completion. 
if !exists('g:neocomplcache_omni_patterns') 
  let g:neocomplcache_omni_patterns = {} 
endif
let g:neocomplcache_omni_patterns.ruby = '[^. *\t]\.\w*\|\h\w*::'
autocmd FileType ruby setlocal omnifunc=rubycomplete#Complete

The interesting part is that it works if '=else' is added to indentkeys :)

Regarding the 0* in indentkeys, could you please provide me some simple use case of how can I test them so that I could understand them better?

Best regards!

@now
Copy link
Member

now commented Feb 24, 2011

Well, simply type one of the characters at the start of a line.

The { is there to align the start of hash literals, the } is there to align the end of hash literals and blocks, the ) is there to align the end of method argument lists and other kinds of parenthesis-delimited blocks, and the ] is there to indent the ending of an array literal. I can’t remember why [ isn’t in that list, but I’m sure there was a reason.

[
 1,
 2,
 3
].map{ |i|
  i * 2
}

@rosenfeld
Copy link
Author

Ok, now I could understand. My tests were failing because of neocomplcache. I've disabled all my user plugins and did see most of the indentkeys options working. The only thing that didn't make any difference is the '0{'. Could you test if there is any situation it helps for you? Try just deleting the '0{' from indentkeys and see the results.

Maybe that is the reason why '0[' is not necessary...
Thank you again!

@dkearns dkearns added the indent label Sep 18, 2015
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants