Browse Source

Merge branch 'master' of github.com:10sr/dotfiles

pull/15/head
10sr 7 years ago
parent
commit
82e22d33bf
2 changed files with 47 additions and 2 deletions
  1. +3
    -0
      emacs.el
  2. +44
    -2
      micro/init.lua

+ 3
- 0
emacs.el View File

@@ -100,6 +100,7 @@ found, otherwise returns nil."
gitignore-mode
adoc-mode
malabar-mode

;; ack
color-moccur
ggtags
@@ -120,6 +121,8 @@ found, otherwise returns nil."
pkgbuild-mode
minibuffer-line
which-key
;; I think this works in place of my autosave lib
super-save

scala-mode
;;ensime


+ 44
- 2
micro/init.lua View File

@@ -2,6 +2,8 @@

local function getProperties(fullpath)
-- TODO: Avoid command injection vulnerability
-- For example, following command will create file b.txt
-- $ micro "a.txt'; touch 'b.txt"
local file = io.popen("editorconfig '" .. fullpath .. "'", "r")
local output = file:read("*all")
file:close()
@@ -20,16 +22,56 @@ 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_str, 10)
if indent_size ~= nil then
messenger:Message("set tabsize to " .. indent_size_str)
SetLocalOption("tabsize", indent_size, view)
end

if indent_style == "space" then
-- messenger:Message("indent_style to space")
SetLocalOption("tabstospaces", "on", view)
elseif indent_style == "tab" then
-- messenger:Message("indent_style to tab")
SetLocalOption("tabstospaces", "off", 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

-- SetLocalOption("tabsize", 4, view)
-- SetLocalOption("tabstospaces", "on", view)
setIndentation(properties, view)
-- Currently micro does not support changing coding-systems
-- (Always use utf-8 with LF?)
-- setCodingSystem(properties, view)
-- `ruler' is not what we want!
-- setMaxLineLength(properties, view)
-- setTrimTrailingWhitespace(properties, view)
-- We have eofnewline! Use this!
-- setInsertFinalNewline(properties, view)
end

function onSave(view)
messenger:Message("Saved!")
end

-- function getindentstyle()

Loading…
Cancel
Save