micro-editor / micro-editor/micro
Micro plugin with fzf and fasd
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 29.6k
- Forks
- 1.4k
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 10
Description
I am trying to mod. this script (see at bottom)
to use this command fasd -flt | tail -n 25 | grep -Ev '\.(tiff|jpg|jpeg|png|gif|pxm|mp3|mp4|aac)$' | fzf --tac
Instead of just straight fzf
I use fasd to list recently opened files/documents/code etc (media is excluded) via fzf and open them in micro.
I want to access this while in micro.
The commands in this script are will be the same except prefixed by an 'r'. so rfv = recent file / split vertical.
I hope this make sense.
I have tried changing the command in line 9, but a error flashes up and its far to quick to read.
VERSION = "1.0.0"
local micro = import("micro")
local shell = import("micro/shell")
local config = import("micro/config")
local buffer = import("micro/buffer")
function fzf(bp, opt)
local output, err = shell.RunInteractiveShell("fzf", false, true)
if err ~= nil then
micro.InfoBar():Error(err)
else
fzfOpen(output, bp, opt)
end
end
function fzf_find(bp, args, opt)
local strings = import("strings")
local cmd = "grep --line-buffered -rnwi "
local pattern = ""
for i = 1, #args do
pattern = args[i] .. " "
end
cmd = cmd .. pattern .. " * | fzf"
local output, err = shell.RunInteractiveShell(cmd, false, true)
-- local run, err = shell.RunBackgroundShell(cmd)
-- local output = run()
if err ~= nil then
micro.InfoBar():Error("could not execute fzf command: ", err)
return
end
-- output = strings.Split(output, "\n")
-- micro:TermMessage("\nOutput\n", output)
local input = strings.Split(output, ":")
if #input < 2 then
micro.InfoBar():Error("bad input format: ", input)
return
end
fzfOpenLine(input[1], bp, 2, input[2])
micro.InfoBar():Message(input[1] .. " @ " .. input[2])
end
function fzfOpen(output, bp, opt)
local strings = import("strings")
local strconv = import("strconv")
file = strings.TrimSpace(output)
if file ~= "" then
local buf, err = buffer.NewBufferFromFile(file)
if err ~= nil then
micro.InfoBar():Error(err)
end
if opt == 0 then
bp:OpenBuffer(buf)
elseif opt == 1 then
bp:HSplitBuf(buf)
elseif opt == 2 then
bp:VSplitBuf(buf)
end
end
end
function fzfOpenLine(output, bp, opt, line)
local strings = import("strings")
local strconv = import("strconv")
file = strings.TrimSpace(output)
if file ~= "" then
local buf, err = buffer.NewBufferFromFile(file)
if err ~= nil then
micro.InfoBar():Error(err)
end
local new_bp
if opt == 0 then
new_bp = bp:OpenBuffer(buf)
elseif opt == 1 then
new_bp = bp:HSplitBuf(buf)
elseif opt == 2 then
new_bp =bp:VSplitBuf(buf)
end
new_bp.Cursor.Y = tonumber(line)-1
new_bp.Cursor:Relocate()
end
end
function init()
config.MakeCommand("f", function(bp, args)
fzf(bp, 0)
end, config.NoComplete)
config.MakeCommand("fh", function(bp, args)
fzf(bp, 1)
end, config.NoComplete)
config.MakeCommand("fv", function(bp, args)
fzf(bp, 2)
end, config.NoComplete)
config.MakeCommand("ff", function(bp, args)
fzf_find(bp, args, 2)
end, config.NoComplete)
config.AddRuntimeFile("fzf", config.RTHelp, "help/fzf.md")
end
Getting this to work would make it, in my eyes, the perfect (user friendly) cli editor
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start from the embedded Lua plugin script, especially the fzf command in line 9, and reproduce the reported error while running the fasd pipeline. Done means the recent-file command works inside micro, excludes the listed media extensions, and supports the requested r-prefixed commands for opening files and splits.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua, shell
- Domain
- cli, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100