Make languages & policies user-configurable #109
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add three configurables:
g:vue_indent_languages
replacess:languages
. It can be configuredbefore or after loading
indent/vue.vim
, and can be modified on thefly.
g:vue_indent_open_close_tags
configures the policy for indentingopen/close tags. It defaults to 0 which forces open/close tags for
sections in a vue single-file component to the first column.
g:vue_indent_first_line
configures the policy for indenting thefirst line after an open tag. It defaults to -1 which uses the
autoindent default, i.e. the same column as the open tag. It will
also preserve existing indentation when reindenting, which means
that authors can use their preferred first line indentation without
needing any special configuration.
Additionally
g:vue_indent_first_line
can be overridden per-language byspecifying a value for
language.first_line
. We use this for the htmllanguage configuration to defer to
html.vim
for indenting the first lineof an html template.
Minor changes:
Since
s:get_indentexpr
is called lazily, it resetsindentexpr
beforereturning.
Use
searchpair()
to find the closing tag instead of a hard-coded list.For development and debugging, it's possible to
:echo GetVueIndent()
which also enables error reporting and messages that are normally
squelched when called as indentexpr. Note that although
GetVueIndent()
uses
getpos('.')
properly if line number isn't supplied, languageindenters vary between
getpos('.')
andv:lnum
, so this is mostlyuseful for debugging vue.vim's internal operation.