I'm using vim version 8.0 on OS X (installed through Homebrew) and it keeps indenting object literals wrong. The first key and only the first key is flush with the previous line. All subsequent keys are indented four spaces.
var object = {
key1: "value1",
key2: "value2"
};
as
var object = {
key1: "value1",
key2: "value2",
};
The javascript indentation file is here.
/usr/local/share/vim/vim80/indent/javascript.vim
It is pretty clearly the pangloss/vim-javascript plugin.
cat /usr/local/share/vim/vim80/indent/javascript.vim | head -n 5
" Vim indent file
" Language: Javascript
" Maintainer: Chris Paul ( https://github.com/bounceme )
" URL: https://github.com/pangloss/vim-javascript
" Last Change: August 25, 2016
STR:
% touch awesome.js
% vim -u NONE awesome.js
:set filetype=javascript
type out javascript example
gg=G
voilà incorrectly indented code.
If there isn't some hidden configuration setting that's causing the bundled indenter for javascript to act up, is there a way to completely shadow <...>/indent/javascript.vim
and <...>/syntax/javascript.vim
so I can start writing a replacement?
:filetype indent on
before:set ft=javascript
to enable loading the indentation file. So your minimal test is a bit too minimal here :-) If I do this, it works as expected for me. Try adding:filetype plugin indent on
to your vimrc. Does that fix it?filetype plugin indent on
in it, but I will update the test and post new and better screenshots if anything changed.set nomagic
and it looks like it was interfering with the parser.