-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
60ea059
commit 68fb500
Showing
18 changed files
with
763 additions
and
204 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
-- A list of known commands | ||
ahk | ||
cd $ | ||
comment | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
O:\MyProfile\editor\confMicro\init.lua | ||
O:\MyProfile\editor\UpdateGIT.bat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,179 @@ | ||
# Introduction | ||
|
||
There does not seem to be a simple introduction to using Lua in micro. | ||
Coming to GoLua from regular Lua/LuaJIT there are some significant differences: | ||
|
||
* There are some "extra" functions. | ||
* Go libraries are imported to extend the Lua environment. | ||
* There is no eval function! | ||
* Don't use os.execute(), it kills the mouse | ||
* You cannot load binary libraries. | ||
* [See source](https://github.com/yuin/gopher-lua#differences-between-lua-and-gopherlua) | ||
|
||
## Lua Environment | ||
|
||
ver: | ||
|
||
_VERSION=Lua 5.1 | ||
_GOPHER_LUA_VERSION=GopherLua 0.1 | ||
|
||
package.path: | ||
|
||
.\?.lua | ||
<exe>\lua\?.lua | ||
<exe>\lua\?\init.lua | ||
%LUA_PATH%lua\lua\?.lua | ||
%LUA_PATH%lua\lua\?\init.lua 5 | ||
|
||
package.cpath: BLANK | ||
|
||
init.lua: | ||
|
||
The init.lua file is automatically called when the application loads. | ||
Any errors will crash micro.exe! | ||
Upgrading may overwrite this file! | ||
I would recommend requiring to Lua files, rather than adding much code to the init file. | ||
|
||
## Standard Lua functions | ||
|
||
excluded: | ||
dostring | ||
|
||
included: | ||
Everything else | ||
|
||
## Additional Lua functions | ||
|
||
import([exposed_go_library]) | ||
Returns a userdata blob with all the library contents. Not iterable using Lua. | ||
|
||
curbuf() | ||
Returns an handle to the current buffer pane. Not iterable using Lua. | ||
|
||
## Micro API | ||
|
||
local micro = import("micro"): | ||
|
||
micro.CurPane() | ||
micro.CurTab() | ||
micro.InfoBar() | ||
micro.Lock=userdata | ||
micro.Log() | ||
micro.SetStatusInfoFn() | ||
micro.Tabs() | ||
micro.TermError() | ||
micro.TermMessage() | ||
|
||
local config = import("micro/config"): | ||
|
||
config.AddRuntimeFile() | ||
config.AddRuntimeFileFromMemory() | ||
config.AddRuntimeFilesFromDirectory() | ||
config.ConfigDir=string | ||
config.FileComplete() | ||
config.GetGlobalOption() | ||
config.HelpComplete() | ||
config.ListRuntimeFiles() | ||
config.MakeCommand() | ||
config.NewRTFiletype() | ||
config.OptionComplete() | ||
config.OptionValueComplete() | ||
config.RTColorscheme=number | ||
config.RTHelp=number | ||
config.RTPlugin=number | ||
config.RTSyntax=number | ||
config.ReadRuntimeFile() | ||
config.RegisterCommonOption() | ||
config.RegisterGlobalOption() | ||
config.Reload() | ||
config.SetGlobalOption() | ||
config.SetGlobalOptionNative() | ||
config.TryBindKey() | ||
|
||
local buffer = import("micro/buffer"): | ||
|
||
buffer.BTDefault=number | ||
buffer.BTHelp=number | ||
buffer.BTInfo=number | ||
buffer.BTLog=number | ||
buffer.BTRaw=number | ||
buffer.BTScratch=number | ||
buffer.ByteOffset() | ||
buffer.Loc() | ||
buffer.Log() | ||
buffer.LogBuf() | ||
buffer.MTError=number | ||
buffer.MTInfo=number | ||
buffer.MTWarning=number | ||
buffer.NewBuffer() | ||
buffer.NewBufferFromFile() | ||
buffer.NewMessage() | ||
buffer.NewMessageAtLine() | ||
|
||
local shell = import("micro/shell"): | ||
|
||
shell.ExecCommand() | ||
shell.JobSend() | ||
shell.JobSpawn() | ||
shell.JobStart() | ||
shell.JobStop() | ||
shell.RunBackgroundShell() | ||
shell.RunCommand() | ||
shell.RunInteractiveShell() | ||
shell.RunTermEmulator() | ||
shell.TermEmuSupported=boolean | ||
|
||
## Imported Go code | ||
|
||
This is the power of micro! Nearly all functions from these packages are supported. For an exact list of which functions are supported you can look through: | ||
|
||
P:\MyPrograms\EDITORS\micro\src\micro-master\internal\lua\lua.go | ||
|
||
libraries: | ||
|
||
archive/zip | ||
bytes | ||
errors | ||
fmt | ||
io | ||
io/ioutil | ||
math | ||
math/rand | ||
net | ||
net/http | ||
os | ||
path | ||
path/filepath | ||
regexp | ||
runtime | ||
strings | ||
sync | ||
time | ||
unicode/utf8 | ||
|
||
humanize | ||
|
||
## Event call backs | ||
|
||
* `init()`: this function should be used for your plugin initialization. | ||
This function is called after buffers have been initialized. | ||
|
||
* `preinit()`: initialization function called before buffers have been | ||
initialized. | ||
|
||
* `postinit()`: initialization function called after `init()`. | ||
|
||
* `onBufferOpen(buf)`: runs when a buffer is opened. The input contains | ||
the buffer object. | ||
|
||
* `onBufPaneOpen(bufpane)`: runs when a bufpane is opened. The input | ||
contains the bufpane object. | ||
|
||
* `onAction(bufpane)`: runs when `Action` is triggered by the user, where | ||
`Action` is a bindable action (see `> help keybindings`). A bufpane | ||
is passed as input and the function should return a boolean defining | ||
whether the view should be relocated after this action is performed. | ||
|
||
* `preAction(bufpane)`: runs immediately before `Action` is triggered | ||
by the user. Returns a boolean which defines whether the action should | ||
be cancelled. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# Linter | ||
|
||
The linter plugin runs a compiler or linter on your source code | ||
and parses the resulting output so that the messages and line numbers | ||
can be viewed from within micro. By default, the plugin supports the | ||
following filetypes and linters: | ||
|
||
* c: gcc | ||
* c++: g++ | ||
* d: dmd | ||
* go: go build | ||
* haskell: hlint | ||
* java: javac | ||
* javascript: jshint | ||
* javascript: eslint | ||
* literate: lit | ||
* lua: luacheck | ||
* nim: nim | ||
* objective-c: clang | ||
* python: pyflakes | ||
* python: mypy | ||
* python: pylint | ||
* shell: shfmt | ||
* swift: swiftc (MacOS and Linux only) | ||
* yaml: yamllint | ||
|
||
If the linter plugin is enabled and the file corresponds to one of | ||
these filetypes, each time the buffer is saved, or when the `> lint` | ||
command is executed, micro will run the corresponding utility in the | ||
background and display the messages when it completes. | ||
|
||
The linter plugin also allows users to extend the supported filetypes. | ||
From inside another micro plugin, the function `linter.makeLinter` can | ||
be called to register a new filetype. Here is the spec for the `makeLinter` | ||
function: | ||
|
||
* `linter.makeLinter(name, filetype, cmd, args, errorformat, os, whitelist, domatch, loffset, coffset, callback)` | ||
|
||
> name: name of the linter | ||
> filetype: filetype to check for to use linter | ||
> cmd: main linter process that is executed | ||
> args: arguments to pass to the linter process | ||
use %f to refer to the current file name | ||
use %d to refer to the current directory name | ||
> errorformat: how to parse the linter/compiler process output | ||
%f: file, %l: line number, %m: error/warning message | ||
> os: list of OSs this linter is supported or unsupported on | ||
optional param, default: {} | ||
> whitelist: should the OS list be a blacklist (do not run the linter for these OSs) | ||
or a whitelist (only run the linter for these OSs) | ||
optional param, default: false (should blacklist) | ||
> domatch: should the filetype be interpreted as a lua pattern to match with | ||
the actual filetype, or should the linter only activate on an exact match | ||
optional param, default: false (require exact match) | ||
> loffset: line offset will be added to the line number returned by the linter | ||
useful if the linter returns 0-indexed lines | ||
optional param, default: 0 | ||
> coffset: column offset will be added to the col number returned by the linter | ||
useful if the linter returns 0-indexed columns | ||
optional param, default: 0 | ||
> callback: function to call before executing the linter, if it returns | ||
false the lint is canceled. The callback is passed the buf. | ||
optional param, default: nil | ||
|
||
Below is an example for including a linter for any filetype using | ||
the `misspell` linter which checks for misspelled words in a file. | ||
|
||
```lua | ||
function init() | ||
-- uses the default linter plugin | ||
-- matches any filetype | ||
linter.makeLinter("misspell", "", "misspell", {"%f"}, "%f:%l:%c: %m", {}, false, true) | ||
end | ||
``` | ||
|
||
Here is an example for a more typical use-case, where the linter will only match one filetype (C in this case): | ||
|
||
```lua | ||
function init() | ||
linter.makeLinter("gcc", "c", "gcc", {"-fsyntax-only", "-Wall", "-Wextra", "%f"}, "%f:%l:%c:.+: %m") | ||
end | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -316,3 +316,5 @@ gmh | |
gmh | ||
gmh | ||
gmh | ||
reloa | ||
ahk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -127,3 +127,4 @@ actions | |
fzf | ||
fzf | ||
fzf | ||
key |
Oops, something went wrong.