diff --git a/micro/init.lua b/micro/init.lua index 65f0079..15b55cc 100644 --- a/micro/init.lua +++ b/micro/init.lua @@ -22,16 +22,46 @@ local function getProperties(fullpath) return properties end +local function setIndentation(properties, view) + local indent_size_str = properties["indent_size"] + local tab_width_str = properties["tab_width"] + local indent_style = properties["indent_style"] + + local indent_size = tonumber(indent_size, 10) + if indent_size ~= nil then + SetLocalOption("tabsize", indent_size, view) + end + + if indent_style == "space" then + messenger:Message("indent_style to space") + SetLocalOption("indentchar", " ", view) + elseif indent_style == "tab" then + messenger:Message("indent_style to tab") + SetLocalOption("indentchar", "\t", view) + else + messenger:Message("unknown indent_style") + end +end + function onViewOpen(view) -- Is this portable? (work on windows?) local pwd = os.getenv("PWD") local filename = view.Buf.Path -- prop, names = ec.parse(filepath) local fullpath = JoinPaths(pwd, filename) - local out = getProperties(fullpath) - messenger:Message("edconf: " .. out["indent_style"]) + local properties = getProperties(fullpath) + if properties["indent_style"] == nil then + messenger:Message("edconf: nil") + else + messenger:Message("edconf: " .. properties["indent_style"]) + end + + setIndentation(properties, view) + -- setCodingSystem(propertieps, view) end function onSave(view) messenger:Message("Saved!") end + +-- function getindentstyle()