A vis plugin for editorconfig.
You'll need the Lua wrapper for editorconfig-core installed. This can
be done through luarocks: luarocks install editorconfig-core
git clone https://github.com/seifferth/vis-editorconfig "$HOME/.config/vis/edconf"Then add require('edconf') to your visrc.lua.
You may use a different name for the local repository, if you like.
You could, for instance, use $HOME/.config/vis/vis-editorconfig and
require('vis-editorconfig'). Note, however, that the repository must
not be called editorconfig. Since the editorconfig-core lua library
is also called editorconfig, naming the repository editorconfig
will cause name conflicts that result in infinite recursion.
Not all editorconfig functionality is supported by vis and hence by this plugin. At this moment, there is full support for the following settings:
- indent_style
- indent_size
- tab_width
- insert_final_newline
The following settings are implemented partially and / or support is turned off by default:
- spelling_language: Since vis does not support spellchecking
natively, this plugin will only set
vis.win.file.spelling_languageto the specified value. It is then up to the spellchecking plugin to respect that variable. - trim_trailing_whitespace: Turned off by default, can be enabled
via
:set edconfhooks on. - end_of_line: Turned off by default, partial support can be enabled
via
:set edconfhooks on. Onlycrlfandlfare supported, plaincris not. The implementation is also very basic. If end_of_line is set tocrlf, a return character will be inserted at the end of each line that does not yet end withcrlf. If end_of_line is set tolf, return characters at the end of a line will be stripped. While I would encourage every vis user to stick tolfterminated files, this might be convenient if, for some reason, they do need to composecrlfterminated files. - max_line_length: Turned off by default, partial support can be
enabled via
:set edconfhooks on. There is no straightforward way to automatically wrap content that might be written in arbitrary programming (or non-programming) languages. For that reason, vis-editorconfig doesn't even try. If max_line_length is enabled, vis-editorconfig issues a warning, however, indicating which lines are longer than the specified length. Note that you will miss this warning if you write your file with:wq, so if you care about it, write it with:w<RETURN>:q.
The reason those last three settings are optional and turned off by
default is their scalability. Each of those operations is implemented
as a pre-save-hook with a complexity of O(n), where n is the filesize.
Since vis is incredibly good at editing huge files efficiently, there
seems to be a very real danger that those hooks could cause the editor
to freeze just before a user's valuable changes are written to disk.
If hooks are enabled, they will be executed as configured in the relevant
.editorconfig files. If you want to use a less cautious approach and
enable these hooks by default, you can load the plugin like this:
edconf = require('edconf')
edconf.enable_hooks = true
In addition to the properties listed above, this plugin also provides optional support for the following non-standard extension of the editorconfig standard:
- x_spelling_enable: Similar to how the
spelling_languageproperty causesvis.win.file.spelling_languageto be set, this property causesvis.win.file.spelling_enableto be set. Note that this property is a non-standard extension intended for personal use only. In order to keep things clean,.editorconfigfiles using this property should not be shared and should not be committed to revision control systems.
All non-standard extensions are disabled by default and will be ignored
by this plugin. In order to enable support for a non-standard property
like x_spelling_enable, the user must explicitly enable that property
when loading the plugin. This can be done as follows:
edconf = require('edconf')
edconf.enable_non_standard.x_spelling_enable = true
This project is licensed under the terms of the Apache License
Version 2.0. A copy of that license is included in this repository
as LICENSES/Apache-2.0.txt.