micro-editor / micro-editor/micro
The init methods from the plugins should be run before micro starts handling buffers
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 29.6k
- Forks
- 1.4k
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 10
Description
Description of the problem or steps to reproduce
When micro handles files specified on the command line, Buffers and BufPanes of these files are created before the init method from the plugins are run. This put plugins who wants to provide 'open on start' features in a delicate position: when the plugin initializes, the 'events' it needs to handle are passed already.
Use the following dummy plugin in ~/.config/micro/plug/dummy/dummy.lua
local micro = import("micro")
local function pane_str(pane)
local ret = 'nil'
if pane then
ret = pane:ID()..':'..pane.Buf:GetName()
end
return ret
end
function onBufferOpen(buf)
micro.Log('>> onBufferOpen('..buf:GetName()..')')
micro.Log('<< onBufferOpen')
end
function onBufPaneOpen(pane)
micro.Log('>> onBufPaneOpen('..pane_str(pane)..')')
micro.Log('<< onBufPaneOpen')
end
function init()
micro.Log('>> init')
micro.Log('<< init')
end
then launch micro opening 2 files:
micro -debug python_file.py test.lua
Close micro and look at the log file:
2020/03/30 13:21:03 Micro started
2020/03/30 13:21:05 >> onBufferOpen(python_file.py)
2020/03/30 13:21:05 << onBufferOpen
2020/03/30 13:21:05 >> onBufferOpen(test.lua)
2020/03/30 13:21:05 << onBufferOpen
2020/03/30 13:21:05 >> onBufPaneOpen(0:python_file.py)
2020/03/30 13:21:05 << onBufPaneOpen
2020/03/30 13:21:05 >> onBufPaneOpen(0:test.lua)
2020/03/30 13:21:05 << onBufPaneOpen
2020/03/30 13:21:05 >> onBufferOpen(No name)
2020/03/30 13:21:05 << onBufferOpen
2020/03/30 13:21:05 >> onBufPaneOpen(0:No name)
2020/03/30 13:21:05 << onBufPaneOpen
2020/03/30 13:21:05 >> onBufferOpen(Log)
2020/03/30 13:21:05 << onBufferOpen
2020/03/30 13:21:05 >> init
2020/03/30 13:21:05 << init
Specifications
OS: Ubuntu 19.10
Version: 2.0.3-dev.21
Commit hash: 1cf9537
Compiled on March 27, 2020
Happens also with the latest official release 2.0.2.
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 at micro's startup sequence where command-line files create Buffers and BufPanes, then inspect when plugin init is invoked relative to onBufferOpen and onBufPaneOpen. Reproduce with the dummy.lua plugin and micro -debug python_file.py test.lua; done means init runs before those startup buffer and pane events.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, lua
- Domain
- cli, devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100