|
@@ -1,10 +1,22 @@ |
|
|
-- ec = require("editorconfig_core") |
|
|
-- ec = require("editorconfig_core") |
|
|
|
|
|
|
|
|
local function GetProperties(fullpath) |
|
|
|
|
|
local file = io.popen("echo fullpath: " .. fullpath, "r") |
|
|
|
|
|
|
|
|
local function getProperties(fullpath) |
|
|
|
|
|
local file = io.popen("editorconfig '" .. fullpath .. "'", "r") |
|
|
local output = file:read("*all") |
|
|
local output = file:read("*all") |
|
|
file:close() |
|
|
file:close() |
|
|
return output |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local properties = {} |
|
|
|
|
|
-- TODO: Which is better? output:gmatch(), string.gmatch(output, ...) |
|
|
|
|
|
for line in output:gmatch('([^\n]+)') do |
|
|
|
|
|
-- TODO: Fix regex |
|
|
|
|
|
local key, value = line:match('([^=]*)=(.*)') |
|
|
|
|
|
key = key:gsub('^%s(.-)%s*$', '%1') |
|
|
|
|
|
value = value:gsub('^%s(.-)%s*$', '%1') |
|
|
|
|
|
-- TODO: Throw error when key is empty string |
|
|
|
|
|
properties[key] = value |
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
return properties |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
function onViewOpen(view) |
|
|
function onViewOpen(view) |
|
@@ -13,12 +25,10 @@ function onViewOpen(view) |
|
|
local filename = view.Buf.Path |
|
|
local filename = view.Buf.Path |
|
|
-- prop, names = ec.parse(filepath) |
|
|
-- prop, names = ec.parse(filepath) |
|
|
local fullpath = JoinPaths(pwd, filename) |
|
|
local fullpath = JoinPaths(pwd, filename) |
|
|
local out = GetProperties(fullpath) |
|
|
|
|
|
messenger:Message("view.Buf.Path: " .. out) |
|
|
|
|
|
|
|
|
local out = getProperties(fullpath) |
|
|
|
|
|
messenger:Message("edconf: " .. out["indent_style"]) |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function onSave(view) |
|
|
function onSave(view) |
|
|
messenger:Message("Saved!") |
|
|
messenger:Message("Saved!") |
|
|
end |
|
|
end |