if !exists('g:polyglot_disabled') || index(g:polyglot_disabled, 'javascript') == -1 " Vim indent file " Language: Javascript " Maintainer: Chris Paul ( https://github.com/bounceme ) " URL: https://github.com/pangloss/vim-javascript " Last Change: December 4, 2017 " Only load this indent file when no other was loaded. if exists('b:did_indent') finish endif let b:did_indent = 1 " Now, set up our indentation expression and keys that trigger it. setlocal indentexpr=GetJavascriptIndent() setlocal autoindent nolisp nosmartindent setlocal indentkeys+=0],0) " Testable with something like: " vim -eNs "+filetype plugin indent on" "+syntax on" "+set ft=javascript" \ " "+norm! gg=G" '+%print' '+:q!' testfile.js \ " | diff -uBZ testfile.js - let b:undo_indent = 'setlocal indentexpr< smartindent< autoindent< indentkeys<' " Only define the function once. if exists('*GetJavascriptIndent') finish endif let s:cpo_save = &cpo set cpo&vim " indent correctly if inside