mirror of
https://github.com/zyedidia/micro.git
synced 2026-02-04 22:20:20 +09:00
Improve autoclose plugin auto tabbing
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
// "github.com/mitchellh/go-homedir"
|
||||
)
|
||||
|
||||
// This file is meant (for now) for autocompletion in command mode, not
|
||||
@@ -16,6 +17,12 @@ func FileComplete(input string) (string, []string) {
|
||||
var files []os.FileInfo
|
||||
var err error
|
||||
if len(dirs) > 1 {
|
||||
// home, _ := homedir.Dir()
|
||||
|
||||
// directories := strings.Join(dirs[:len(dirs)-1], "/")
|
||||
// if strings.HasPrefix(directories, "~") {
|
||||
// directories = strings.Replace(directories, "~", home)
|
||||
// }
|
||||
files, err = ioutil.ReadDir(strings.Join(dirs[:len(dirs)-1], "/"))
|
||||
} else {
|
||||
files, err = ioutil.ReadDir(".")
|
||||
|
||||
@@ -269,6 +269,7 @@ func main() {
|
||||
L.SetGlobal("IsWordChar", luar.New(L, IsWordChar))
|
||||
L.SetGlobal("HandleCommand", luar.New(L, HandleCommand))
|
||||
L.SetGlobal("HandleShellCommand", luar.New(L, HandleShellCommand))
|
||||
L.SetGlobal("GetLeadingWhitespace", luar.New(L, GetLeadingWhitespace))
|
||||
|
||||
// Used for asynchronous jobs
|
||||
L.SetGlobal("JobStart", luar.New(L, JobStart))
|
||||
|
||||
@@ -411,7 +411,7 @@ func runtimeHelpPluginsMd() (*asset, error) {
|
||||
return a, nil
|
||||
}
|
||||
|
||||
var _runtimePluginsAutocloseAutocloseLua = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\xb4\x56\x4d\x6b\xe3\x3c\x10\xbe\xe7\x57\x0c\xee\x21\x36\xb5\x03\x7e\x8f\x05\xbf\xd0\x76\x61\x29\x94\xdd\xa5\x2c\xfb\x41\xdb\x83\x22\x8f\x63\x51\x57\x0a\x23\x29\xe9\x52\xfa\xdf\x17\xd9\x8e\x62\x27\x76\xda\x2c\x6d\x0e\x8a\x6c\xcd\xc7\x33\x1f\x7a\xc6\x85\x95\xdc\x08\x25\x81\x97\x8c\xce\x4d\xa8\x0d\xc5\x20\xa2\x09\x00\x00\xa1\xb1\x24\x41\x1b\x12\x72\x31\xd3\x76\xde\x9e\xd6\x02\x28\xf3\xc9\x44\x14\xf0\x19\xcd\xd7\xa5\xb3\x10\x06\xcc\x1a\xc5\x2b\xa5\x31\x88\x20\xcb\x40\x8a\x0a\x4c\x89\xb2\xb6\x75\x9e\xe7\xfb\x62\x31\x18\xb2\xd8\xda\xaa\x14\x67\x15\xf8\xc3\x6f\x4c\x90\x86\x0c\x9e\x83\xbb\xe0\x2e\x08\x62\x08\xa6\x53\xb7\x86\x91\x5b\x9f\x5f\xdc\x7a\x7b\x1f\xbc\x74\xf4\xbe\xe0\xba\x12\xb2\xa3\xb9\x27\x3b\xf1\xe1\x2a\x79\x63\x25\x86\xd4\x44\x2a\x0a\x90\xca\x8c\xc5\xe2\x83\xd8\x26\xa5\x7e\xac\x61\xbb\x4d\x03\x61\x05\x19\x5c\x5a\xfa\x21\x70\x1d\x36\x66\x0b\x45\x20\x20\x83\x34\x86\x93\x9d\xc0\x72\xe5\x2d\x8a\x02\xc8\xe5\xab\xad\x40\x5f\xf0\x56\xdc\xc7\xf0\xdf\x0e\x86\xad\x4f\x6e\xe9\x5a\x48\x84\x0c\x56\xb3\x0b\x5b\x9c\xb9\x87\x70\x35\xbb\xb4\xa4\x15\xcd\x7e\x47\x93\x9e\x8e\x28\x36\x4e\x5a\xbd\x18\xbc\xec\xaf\xd3\x34\x3a\x1e\x85\xfb\xad\xce\x2e\x18\x7f\xd0\x4b\xc6\x31\x2c\x58\xa5\x31\x1a\x10\x69\xbc\xdc\x88\x45\x69\xc6\x84\xe6\x84\xec\xa1\xf7\xd6\x27\xb8\x13\xc0\x16\x30\xfc\x0f\x29\x30\x99\x43\x78\xa5\x7f\x2a\xca\x2f\x4b\x46\xe1\x78\x7c\x49\x1a\x45\xa0\xe8\x40\x06\x92\xd7\x32\xe0\x2c\x0c\xa6\x60\x18\xfa\xd0\xfe\xf5\x62\xa7\xef\x57\xec\x4e\xae\xb2\x0c\x4e\x36\xfa\x8a\xea\x6e\x7f\x53\xd6\x4e\x47\x63\x4e\x12\xf7\x1e\xa6\xc9\x14\x4a\x24\x04\xa1\xc1\x28\xc8\x91\xb0\x40\xc9\xb1\x3e\x5c\x2a\x21\x0d\x92\x3b\xf0\x26\xaf\x15\x87\x75\x29\x78\xe9\x34\x5c\xfc\x8f\xcc\x08\xce\xaa\xea\x0f\x3c\xb2\x1c\x87\xfc\xac\x4b\x94\xc0\x95\x5c\x21\x19\x21\x17\xb0\x50\x8e\x94\x2c\x37\xb5\xcb\xca\xb2\x21\xa5\x2b\x03\x12\x31\xaf\x45\xe6\xd8\x02\x23\x07\x2d\x87\x39\x72\x66\x75\x83\xd1\x53\x02\x3e\x2d\xd1\x99\x64\x20\x95\xf4\xd0\x1b\x47\xfb\x1d\x5d\x57\xe0\x4a\x6a\x24\x13\x26\xdd\xe0\xe2\x83\x57\xe8\xad\x6d\xbf\xbb\x77\xff\xf5\x75\xe8\x30\x58\xe3\xbd\x65\xbd\xf0\x43\x99\xec\x8d\x0d\xb8\x15\xad\x98\x36\x87\x64\x93\x74\xc7\xb0\xa3\x63\xf0\xf7\x62\xa3\x1e\xc3\xc9\x66\xdb\x95\x97\xf8\x64\xfa\x0a\xbe\x75\xd3\xf6\x1a\xec\x72\x6f\x6f\x38\xf4\xd9\xd7\x7b\xef\x5d\xcb\xae\xc2\xe8\xc5\x74\xe9\xf6\x58\x0e\xab\x8f\xd3\x67\x53\xc7\xef\x6c\x3e\x4a\x9f\x07\x9a\x2d\xb8\x93\x41\xf4\x0f\xed\xb3\x24\xdc\xd2\xf6\x87\xf5\xce\x11\x63\xf0\x88\x16\x83\xf7\x98\x65\x6e\x72\x8c\x5b\x78\x75\x12\xec\x17\x73\x75\xf6\x09\x2b\x34\x7b\x43\xb0\x5b\x83\xee\x77\x95\xfb\xf6\xa9\x8b\xf2\x37\x00\x00\xff\xff\x8c\xa6\x24\x33\x84\x09\x00\x00")
|
||||
var _runtimePluginsAutocloseAutocloseLua = []byte("\x1f\x8b\x08\x00\x00\x09\x6e\x88\x00\xff\xb4\x56\x5d\x6b\xa3\x4c\x14\xbe\xcf\xaf\x38\xd8\x8b\x28\xd5\x40\xde\xcb\x80\x2f\xb4\x5d\x28\x85\xee\x07\x65\xd9\xee\xd2\xf6\x62\x32\x1e\x75\xa8\x3d\x13\xce\x8c\x49\x97\xd2\xff\xbe\x8c\x5a\xa3\x49\x4c\x13\x68\x73\x61\xd4\x79\x9e\xf3\xfd\x61\x5a\x92\xb4\x4a\x13\xc8\x5c\xf0\x99\xf5\x8d\xe5\x10\x54\x30\x02\x00\x60\xb4\x25\x13\x18\xcb\x8a\xb2\x89\x29\xe7\xcd\x69\x05\x40\x4a\x46\x23\x95\xc2\x25\xda\xef\x0b\x27\xc1\xf7\x44\x69\xb5\x2c\xb4\x41\x2f\x80\x38\x06\x52\x05\xd8\x1c\xa9\x92\x75\x96\x24\xdb\xb0\x10\x2c\x97\xd8\xc8\x2a\xb4\x14\x05\xb4\x87\x3f\x84\x62\x03\x31\xbc\x78\xf7\xde\xbd\xe7\x85\xe0\x8d\xc7\xee\xea\x07\xee\xfa\xf2\xea\xae\x77\x0f\xde\x6b\x87\xf7\x0d\x57\x85\xa2\x0e\x73\x0b\x3b\x6a\xdd\xd5\x74\x53\x12\xfa\x5c\x7b\xaa\x52\x20\x6d\x87\x7c\x69\x9d\x58\x07\xa5\x7a\xac\xcc\x76\x37\xb5\x09\x4b\x88\xe1\xa2\xe4\x5f\x0a\x57\x7e\x2d\x36\xd5\x0c\x0a\x62\x98\x86\x70\xb2\xe1\x58\xa2\x5b\x89\x2a\x05\x76\xf1\x6a\x32\xd0\x07\xde\xa9\x87\x10\xfe\xdb\xb0\x61\xad\x53\x96\x7c\xad\x08\x21\x86\xe5\xe4\xbc\x4c\x67\xee\xc1\x5f\x4e\x2e\x4a\x36\x9a\x27\x7f\x82\x51\x8f\xa3\xd2\x37\x25\x0d\x2f\x84\x16\xfb\xfb\x74\x1a\x1c\x6f\x85\xfb\x2d\x67\xe7\x42\x3e\x9a\x85\x90\xe8\xa7\xa2\x30\x18\xec\x80\xd4\x5a\x6e\x54\x96\xdb\x21\xd0\x9c\x51\x3c\xf6\xde\xb6\x01\xee\x38\xb0\x36\x18\xfe\x87\x29\x08\x4a\xc0\xbf\x32\xb7\x9a\x93\x8b\x5c\xb0\x3f\xec\x5f\x34\x0d\x02\xd0\xbc\x27\x02\xd1\x7b\x11\x70\x12\x76\x86\x60\xb7\xe9\xbb\xee\xdf\x4f\xf6\xf4\xe3\x92\xdd\x89\x55\x1c\xc3\xc9\x1b\x5f\x73\x55\xed\x07\x45\xed\x74\xd0\xe7\x28\x72\xef\x61\x1c\x8d\x21\x47\x46\x50\x06\xac\x86\x04\x19\x53\x24\x89\xd5\xe1\x42\x2b\xb2\xc8\xee\xa0\x15\x79\xad\x25\xac\x72\x25\x73\xc7\x70\xfe\x3f\x09\xab\xa4\x28\x8a\xbf\xf0\x24\x12\xdc\xa5\x67\x95\x23\x81\xd4\xb4\x44\xb6\x8a\x32\xc8\xb4\x1b\x4a\xa5\xb4\x95\xca\xa2\x14\xbb\x48\x57\x16\x08\x31\xa9\x20\x73\x6c\x0c\x63\x67\x5a\x02\x73\x94\xa2\x34\xb5\x8d\xed\x48\xc0\xe7\x05\x3a\x91\x02\x48\x53\x6b\x7a\xad\x68\xbb\xa2\xab\x0c\x5c\x91\x41\xb6\x7e\xd4\x75\x2e\xdc\xdb\x42\x87\x96\xfd\xe6\xbd\xfb\xaf\xda\xa1\x35\x77\xc1\x58\xab\x6f\xc6\x9e\xff\xa9\xa3\xec\xc0\x0a\xec\x41\xdd\x84\x85\x78\x4f\xc3\x75\xf1\x84\xcf\xf6\x5d\xc2\xe9\xb4\x4b\x59\xb9\x29\x7f\x89\xf6\x1a\x45\xa2\x28\xbb\xcd\x95\xc5\x7a\x0c\x35\xd4\x1a\xfc\x84\xc6\x20\x65\xc8\xb3\xaf\x68\x8c\xc8\xaa\x63\xa7\x2a\x04\x0f\xbc\xb0\xd5\xdc\xf4\xcf\xe6\xd0\xee\x6d\x95\xfe\xd8\x6e\x7d\xec\xf5\x73\x97\x30\xd8\xd1\x2e\x4d\xad\xc7\xfb\xe9\xc3\x73\xb7\x9f\xff\xc1\xd9\x5b\xc3\x7e\x8a\xf9\x20\x64\x4f\x31\x7b\xf7\xe4\xc1\x64\x02\x2b\xb3\xcd\x8b\xa2\x43\x8d\x38\xbc\xc8\xbb\x5f\x1e\x95\xb0\xed\xb2\x5f\xaf\x9b\x4f\x2b\xf9\x23\xd6\xf7\x11\x9d\x01\x1f\xb1\x83\xdd\xc6\xdb\xd3\x52\xc7\x2f\x97\xe5\xec\x0b\x16\x68\xb7\x72\x37\x94\x15\xf7\xcd\x56\x25\xe5\x5f\x00\x00\x00\xff\xff\x08\x07\xbd\xf9\x3c\x0a\x00\x00")
|
||||
|
||||
func runtimePluginsAutocloseAutocloseLuaBytes() ([]byte, error) {
|
||||
return bindataRead(
|
||||
@@ -426,7 +426,7 @@ func runtimePluginsAutocloseAutocloseLua() (*asset, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := bindataFileInfo{name: "runtime/plugins/autoclose/autoclose.lua", size: 2436, mode: os.FileMode(420), modTime: time.Unix(1471461104, 0)}
|
||||
info := bindataFileInfo{name: "runtime/plugins/autoclose/autoclose.lua", size: 2620, mode: os.FileMode(420), modTime: time.Unix(1471644821, 0)}
|
||||
a := &asset{bytes: bytes, info: info}
|
||||
return a, nil
|
||||
}
|
||||
|
||||
@@ -43,25 +43,31 @@ function onRune(r)
|
||||
end
|
||||
end
|
||||
|
||||
function onInsertNewline()
|
||||
function preInsertNewline()
|
||||
if not GetOption("autoclose") then
|
||||
return
|
||||
end
|
||||
|
||||
local v = CurView()
|
||||
local curLine = v.Buf:Line(v.Cursor.Y)
|
||||
local lastLine = v.Buf:Line(v.Cursor.Y-1)
|
||||
local curRune = charAt(lastLine, #lastLine)
|
||||
local nextRune = charAt(curLine, 1)
|
||||
local curRune = charAt(curLine, v.Cursor.X)
|
||||
local nextRune = charAt(curLine, v.Cursor.X+1)
|
||||
local ws = GetLeadingWhitespace(curLine)
|
||||
messenger:Message(curRune, " ", nextRune)
|
||||
|
||||
for i = 1, #autoNewlinePairs do
|
||||
if curRune == charAt(autoNewlinePairs[i], 1) then
|
||||
if nextRune == charAt(autoNewlinePairs[i], 2) then
|
||||
v:InsertNewline(false)
|
||||
v:InsertTab(false)
|
||||
v.Buf:Insert(-v.Cursor.Loc, "\n")
|
||||
v.Buf:Insert(-v.Cursor.Loc, "\n" .. ws)
|
||||
-- v:InsertNewline(false)
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
function preBackspace()
|
||||
|
||||
Reference in New Issue
Block a user