EditorConfig Core bindings for Lua
C CMake
Permalink
Failed to load latest commit information.
cmake/Modules Add CMake build and editorconfig-core-test test suite Sep 15, 2016
tests @ 1609bf5 Add CMake build and editorconfig-core-test test suite Sep 15, 2016
.editorconfig Add CMake build and editorconfig-core-test test suite Sep 15, 2016
.gitignore Add rockspec and installation notes to README.md Sep 18, 2016
.gitmodules Add CMake build and editorconfig-core-test test suite Sep 15, 2016
CMakeLists.txt Improve test coverage Oct 1, 2016
LICENSE
README.md Update README.md Sep 29, 2016
editorconfig-core-scm-1.rockspec Bump version to 0.2.0 Sep 29, 2016
editorconfig.lua.in Improve test coverage Oct 1, 2016
editorconfig_lua.c Remove lua_call to open EC handle Oct 1, 2016

README.md

EditorConfig Lua Core

EditorConfig Lua Core provides the same functionality as the EditorConfig C Core library.

EditorConfig Project

EditorConfig makes it easy to maintain the correct coding style when switching between different text editors and between different projects. The EditorConfig project maintains a file format and plugins for various text editors which allow this file format to be read and used by those editors. For information on the file format and supported text editors, see the EditorConfig website.

Installation

Build/install using LuaRocks (recommended):

luarocks make

Build/install using CMake:

mkdir cmbuild
cd cmbuild
cmake ..
make
make test   #optional

Then copy the editorconfig_core.so binary module to somewhere in your LUA_CPATH.

Usage

The open module function returns an iterator over the property set. Typical usage by plugins would be:

ec = require("editorconfig_core")

for name, value in ec.open("/full/path/to/file") do
    configure_property[name](value)
end

Alternatively the parse module function returns a key/value property table. Sometimes it is useful to have the same stable order for each parse() invocation that the EditorConfig C Core library provides. For that the property keys are available as an array in a second return value:

prop, names = ec.parse("/full/path/to/file")
print(#names .. " properties:")
for idx, name in ipairs(names) do
  print(string.format("%s: %s=%s", idx, name, prop[name]))
end

Note also the use of the length operator to retrieve the EditorConfig property count for a given file.