aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrank Seifferth <frankseifferth@posteo.net>2021-10-07 13:36:50 +0200
committerFrank Seifferth <frankseifferth@posteo.net>2021-10-07 13:41:24 +0200
commit556370f35d4486ad01d549a7f6ff24618a547908 (patch)
treea2b96abc54fdc93836b1230a70ffadd7813df2fe
parent68ef4657583ce8c47ade8ec080e4f6db8aa755a9 (diff)
downloadvis-editorconfig-556370f35d4486ad01d549a7f6ff24618a547908.tar.gz
Allow setting arbitrary options via 'vis_*' keys
-rw-r--r--README.md25
-rw-r--r--edconf.lua4
2 files changed, 28 insertions, 1 deletions
diff --git a/README.md b/README.md
index 321f4b7..6e04cdc 100644
--- a/README.md
+++ b/README.md
@@ -74,3 +74,28 @@ import in `visrc.lua`:
require('editorconfig/edconf')
vis:command('set edconfhooks on') -- supposing you did previously
-- require('vis')
+
+### Setting arbitrary options
+
+To some it might be convenient to use editorconfig files to set arbitrary
+vis options. Therefore, the vis editorconfig plugin uses the `vis_`
+prefix in keys as an interface to anything that can be specified with
+`:set`.
+
+Instead of running `:set spelllang en_US` after opening a file, for
+instance, one can also add
+
+ vis_spelllang = en_US
+
+to the appropriate section of an editorconfig file.
+
+Note that keys in editorconfig are case-insensitive. The specification
+suggests to lowercase them. Therefore, it is only possible to use this
+mechanism for lowercase options. If you really need to use upper or
+camel case options, add an alias to your `visrc.lua`:
+
+```lua
+vis:option_register("snake_case_option", "string", function(value)
+ vis:command("set camelCaseOption " .. value)
+end, "Alias for camelCaseOption")
+```
diff --git a/edconf.lua b/edconf.lua
index ed83ed5..12df5a7 100644
--- a/edconf.lua
+++ b/edconf.lua
@@ -176,7 +176,9 @@ end
function ec_set_values(path)
if path then
for name, value in ec_iter(path) do
- if OPTIONS[name] then
+ if name:sub(1,4) == "vis_" then
+ vis_set(name:sub(5,#name), value)
+ elseif OPTIONS[name] then
OPTIONS[name](value)
end
end