To override settings, you need to use the after
directory.
In this case, we need to know whether to use after/indent
or after/ftplugin
—use :verbose set <options we care about>?
to find where they were last set, and pay attention to whether it was in the ftplugin
or indent
directory. We expect it to be indent
in this case, but sometimes people do strange things.
Assuming we need to override an indent
file, we place
setlocal indentexpr=
setlocal cindent
In ~/.vim/after/indent/javascript.vim
(ditto for typescript
).
Don’t forget to read about b:undo_ftplugin
and b:undo_indent
—they will need to be set properly.
To quote from :h undo_indent
:
When the user does ":setfiletype xyz" the effect of the previous filetype
should be undone. Set the b:undo_ftplugin variable to the commands that will
undo the settings in your filetype plugin.
...
For undoing the effect of an indent script, the b:undo_indent variable should
be set accordingly.
In this case, we'll need to append
'setlocal indentexpr< cindent<'
to b:undo_indent
:
let b:undo_indent = get(b:, 'undo_indent', '')
if !empty(b:undo_indent)
let b:undo_indent .= '|'
endif
let b:undo_indent .= 'setlocal indentexpr< cindent<'