add micro config
This commit is contained in:
parent
599b8acf3c
commit
f07375057d
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"Alt-/": "lua:comment.comment",
|
||||||
|
"Ctrl-J": "lua:initlua.zettelInsert",
|
||||||
|
"CtrlUnderscore": "lua:comment.comment",
|
||||||
|
"MouseRight": "lua:initlua.gotofile"
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
color-link comment "grey"
|
||||||
|
color-link constant "red"
|
||||||
|
color-link identifier "cyan"
|
||||||
|
color-link statement "yellow"
|
||||||
|
color-link symbol "yellow"
|
||||||
|
color-link preproc "magenta"
|
||||||
|
color-link type "green"
|
||||||
|
color-link special "magenta"
|
||||||
|
color-link ignore "default"
|
||||||
|
color-link error ",brightred"
|
||||||
|
color-link todo ",brightyellow"
|
||||||
|
color-link indent-char "black"
|
||||||
|
color-link line-number "yellow"
|
||||||
|
color-link current-line-number "red"
|
||||||
|
color-link diff-added "green"
|
||||||
|
color-link diff-modified "yellow"
|
||||||
|
color-link diff-deleted "red"
|
||||||
|
color-link gutter-error ",red"
|
||||||
|
color-link gutter-warning "red"
|
||||||
|
#Cursor line causes readability issues. Disabled for now.
|
||||||
|
#color-link cursor-line "white,black"
|
||||||
|
color-link color-column "white"
|
||||||
|
#No extended types. (bool in C)
|
||||||
|
color-link type.extended "default"
|
||||||
|
#No bracket highlighting.
|
||||||
|
color-link symbol.brackets "default"
|
||||||
|
#Color shebangs the comment color
|
||||||
|
color-link preproc.shebang "comment"
|
||||||
|
color-link statusline "black,grey"
|
|
@ -0,0 +1,65 @@
|
||||||
|
local micro = import("micro")
|
||||||
|
local config = import("micro/config")
|
||||||
|
local buf = import("micro/buffer")
|
||||||
|
local util = import("micro/util")
|
||||||
|
local path = import("path")
|
||||||
|
local time = import("time")
|
||||||
|
|
||||||
|
function gotofile(bp)
|
||||||
|
local selection = bp.Cursor.CurSelection -- cursor position
|
||||||
|
local line = bp.buf.Line(bp.buf, selection[1]["Y"]) -- get the current line
|
||||||
|
local path_start, path_end
|
||||||
|
-- TODO add other delimiters
|
||||||
|
|
||||||
|
-- search forward from cursor position for a delimiter
|
||||||
|
-- store it to find the end of the path
|
||||||
|
for v = selection[1]["X"], #line do
|
||||||
|
local r = util.RuneAt(line, v)
|
||||||
|
if r == ')' or r == "}" or r == "]" or r == " " then
|
||||||
|
path_end = v
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- do the same, looking backwards, for the start of the path
|
||||||
|
for v = selection[1]["X"],0, -1 do
|
||||||
|
local r = util.RuneAt(line,v)
|
||||||
|
if r == '(' or r == "{" or r == "[" or r == " " then
|
||||||
|
path_start = v+2
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- slice up the path and go to that file
|
||||||
|
if path_start ~= nil and path_end ~= nil then
|
||||||
|
-- get the path from the buffer
|
||||||
|
p = string.sub(line, path_start, path_end)
|
||||||
|
-- get the path relative to current file if it's relative
|
||||||
|
if not path.IsAbs(p) then
|
||||||
|
p = path.Join(path.Dir(bp.buf.Path), p)
|
||||||
|
end
|
||||||
|
-- open in a split
|
||||||
|
-- TODO placement that's better than just splitting?
|
||||||
|
bp.HSplitCmd(bp, {p})
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function zettelInsert(bp)
|
||||||
|
local t = time.Now() -- current unix time
|
||||||
|
local ut = t.Unix(t)
|
||||||
|
local cursor = bp.Cursor.Loc
|
||||||
|
local cursorLoc = buf.Loc(cursor["X"], cursor["Y"])
|
||||||
|
local newFilePath = ut .. ".md"
|
||||||
|
local link = "[[" .. newFilePath .. "]]"
|
||||||
|
bp.Buf:Replace(cursorLoc, cursorLoc, link ) -- insert link at cursor position
|
||||||
|
local newBuffer = buf.NewBuffer("# " .. ut .. " - ", path.Join(path.Dir(bp.buf.Path), newFilePath))
|
||||||
|
bp.HSplitBuf(bp, newBuffer)
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function init()
|
||||||
|
config.MakeCommand("gotofile", gotofile, config.NoComplete)
|
||||||
|
config.MakeCommand("zi", zettelInsert, config.NoComplete)
|
||||||
|
config.TryBindKey("MouseRight", "lua:initlua.gotofile", true)
|
||||||
|
end
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"colorscheme": "nico",
|
||||||
|
"softwrap": true
|
||||||
|
}
|
Reference in New Issue