diff --git a/cmd/micro/command.go b/cmd/micro/command.go index 10035fd1..13782148 100644 --- a/cmd/micro/command.go +++ b/cmd/micro/command.go @@ -565,26 +565,17 @@ func Replace(args []string) { } } } else { - bufStr := view.Buf.String() - matches := regex.FindAllStringIndex(bufStr, -1) - if matches != nil && len(matches) > 0 { - prevMatchCount := runePos(matches[0][0], bufStr) - searchCount := runePos(matches[0][1], bufStr) - prevMatchCount - from := FromCharPos(matches[0][0], view.Buf) - to := from.Move(searchCount, view.Buf) - adjust := Count(replace) - searchCount - view.Buf.Replace(from, to, replace) - found++ - if len(matches) > 1 { - for _, match := range matches[1:] { - found++ - matchCount := runePos(match[0], bufStr) - searchCount = runePos(match[1], bufStr) - matchCount - from = from.Move(matchCount-prevMatchCount+adjust, view.Buf) - to = from.Move(searchCount, view.Buf) + for i := 0; i < view.Buf.LinesNum(); i++ { + // view.Buf.lines[i].data = regex.ReplaceAll(view.Buf.lines[i].data, []byte(replace)) + matches := regex.FindAllIndex(view.Buf.lines[i].data, -1) + + if matches != nil && len(matches) > 0 { + for _, m := range matches { + from := Loc{m[0], i} + to := Loc{m[1], i} + view.Buf.Replace(from, to, replace) - prevMatchCount = matchCount - adjust = Count(replace) - searchCount + found++ } } } diff --git a/cmd/micro/micro.go b/cmd/micro/micro.go index a29e1563..ff2abb0b 100644 --- a/cmd/micro/micro.go +++ b/cmd/micro/micro.go @@ -486,7 +486,6 @@ func main() { default: event = nil } - } } } diff --git a/cmd/micro/runtime.go b/cmd/micro/runtime.go index 5076f5aa..003bda44 100644 --- a/cmd/micro/runtime.go +++ b/cmd/micro/runtime.go @@ -1080,7 +1080,7 @@ func runtimePluginsFtoptionsFtoptionsLua() (*asset, error) { return a, nil } -var _runtimePluginsLinterLinterLua = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xa4\x56\x5f\x8b\xdc\x36\x10\x7f\xbe\xfd\x14\x83\xa8\xc1\xbe\xb5\x9d\x36\xf4\x69\xc1\x94\xf4\xda\x04\x4a\x92\x2b\x5c\xda\x3e\xb4\x4d\xd1\x5a\xe3\x5d\xdd\xc9\x92\x91\xe4\xfd\xc3\x92\xef\x5e\x24\x79\xbd\xb6\xd7\x77\xa4\x34\x90\xd3\xac\x34\x33\xbf\x99\xdf\x8c\x3c\xe2\x15\xbc\x43\x7b\xdf\x58\xae\x64\x4c\x04\x97\x16\x35\x49\xa0\x28\x40\x72\x01\x76\x8b\x72\x01\x00\xf0\x86\xb1\x89\x4e\x0a\x56\xb7\x98\x2c\x50\xb2\xc5\xe2\x03\x7d\xc2\x3b\x55\xd7\x54\xb2\xa0\x40\x52\xe8\x14\x73\xb7\x74\x67\x24\x85\x6f\x93\xc5\xa2\x6a\x65\xe9\x7c\xc1\xe0\x28\x4e\x3c\xce\x5d\xab\x7f\xe7\xb8\x8f\x93\xd5\x03\xdd\x61\x5c\x51\x61\x30\x9c\xe8\x56\xbe\xf7\x0e\xe3\x0e\xb3\xf7\x32\x3c\x71\x9a\x42\x95\x54\x40\x65\xa1\xb8\xb8\xcb\x7f\x6c\xab\xd5\x5b\x2e\xf0\xd3\xb1\xc1\xb1\x1e\x17\x38\xd5\xcc\x7f\xa5\x76\x3b\xd0\x61\x5c\x43\x01\x3f\x71\x8d\xa5\x55\xfa\xf8\x91\xd6\x18\x3b\xbb\xe0\x87\x57\x70\xff\xe0\x18\x23\x7b\x2e\x99\xda\x1b\x72\xe1\xcd\xfd\x63\xb8\x93\xad\x10\x50\x00\xf9\xf8\xdb\x7b\xe2\xf7\x51\x18\xf4\xc2\xcd\xe0\xf4\x15\xc3\xdd\x2b\xf7\xa3\xd3\x91\xec\xec\xdf\x25\x53\x00\xd9\xa8\x89\x6b\x47\x60\x4c\x36\x6a\xdd\x72\xe1\xd8\x75\x1a\x29\x9c\x48\xff\x3b\x73\xbf\x3b\x88\x2f\x29\x90\xa8\x5a\x45\x62\x05\x51\x4d\x92\x2b\x27\xe7\xba\xf5\xd2\xc9\xe5\x78\xb1\x8a\xd8\x72\x60\xe9\x32\xb8\x44\x26\x5a\x3a\x1b\x9a\x68\x69\xb9\xc5\xf2\xc9\xf7\xc3\x45\x3e\x91\x2c\x93\x2a\x2b\x95\x50\xae\x93\xbe\x1e\xa7\x39\xda\xad\x92\xb3\x50\xcd\xb1\x12\xf4\x09\x8d\x83\x1a\xc8\x93\x24\xf2\x6c\xf5\xc3\x5c\xfa\xf5\xb1\x39\x3a\xcb\x6e\x9d\x58\xcd\x59\x34\xc7\x33\x61\xbd\xe4\xd2\x52\xad\x6d\x5a\x9b\x55\x4a\xd7\xd4\x16\x0d\xd5\x06\xe9\x5a\xa0\x2f\x46\xa6\xb1\x51\xda\x9a\x42\xaa\xab\xac\x9f\xcb\xb8\x9c\x2f\x79\x59\xfa\x52\xf9\xe5\x44\xb2\xca\x1c\xa5\xa5\x87\x4c\x49\xe1\xd3\xc8\xfe\xa0\x42\x04\x01\x0f\x56\xd3\x59\x92\xf3\x33\xcf\x37\x13\xc8\xe5\x72\x0c\xfa\x35\x98\x24\x33\x96\x15\xe5\x72\xf9\xdd\xf7\xff\x39\x80\x9b\x9b\x99\xc4\xcd\x9e\x57\x76\x36\x79\xb3\xe7\xb6\xf2\xb1\x1c\x4a\xdd\x4a\x1f\x8d\xd7\x2e\x5f\x4e\xf3\x1a\xe3\x7e\xfd\x88\xa5\xe5\x3b\xcc\xee\x66\x91\x4a\x41\xe5\x66\x0c\xd4\x6f\xfd\x4f\xce\xaf\x83\x61\xb3\x21\xb0\xda\x5f\xe4\xb0\x9c\x48\xb8\x33\x85\xaa\xaa\x70\xbd\x33\xbf\xec\xc3\x5f\xee\x97\x31\x0b\x51\x1c\x89\x28\x79\x09\xf7\x91\xee\xe6\x2f\xaf\x3b\xf0\x34\x9f\x85\x13\xc9\x5c\x14\x8c\xeb\xab\xee\x45\xad\x95\x7e\x11\xc2\x94\x9a\x37\xf3\x05\x7d\x34\xdb\xee\x2a\xf5\xd2\xf0\x02\x3a\x2d\x84\x48\xa4\xf9\x32\x7d\x0e\x41\xf2\x7a\xd6\xb5\xdb\x4f\xa1\x5b\x4e\xa4\xff\x18\x65\x99\xe0\xc6\xbe\x6d\x85\x70\xdf\x7a\x13\xb6\x8c\x65\xaa\xb5\x41\x76\x71\x98\x55\xe0\xf9\x12\x4b\x1e\x89\x14\x22\xb6\xcc\x07\x71\x48\x36\x19\x48\x4a\xfa\xe1\xb5\xe3\xb8\xef\x27\xc4\xdc\x90\x1d\x85\x3b\x9d\x62\xfd\x84\x18\x8f\xc5\x3b\x81\x54\xbf\x11\xe2\x5d\x6b\x2d\xea\x0f\x68\x0c\xdd\xa0\x89\x9f\x0b\xc5\x93\x10\x00\x53\x28\x6b\x96\x02\xd5\x1b\x93\x86\x72\x85\x6f\xd4\x74\xf0\x7a\x84\x89\xfb\xe0\x21\x59\x78\xd5\x5f\xd4\xfa\xa1\xa1\x7b\x19\x0f\xfc\x11\xd2\xfd\xef\x86\xbe\x92\x3f\x1f\xb8\x63\xf2\x8c\x3d\x02\x9c\xd2\xe5\x74\xe3\xf0\xe1\x7c\xc6\xe2\x32\x8b\x5d\x2f\x18\x28\xc0\x34\x62\x60\x44\xfe\x92\xa4\x0b\x2f\xa8\x69\xdc\xe0\x01\x8a\xa1\x97\xd5\xc6\xb4\xeb\x98\x44\x91\xbf\x3a\x71\x9e\x67\x09\x49\xfa\x4d\x7f\x73\xe3\x88\x2d\x87\x9b\x75\xd0\x74\x7b\xde\x77\xa5\x34\xfc\x93\xfa\x76\xe4\x12\x78\x43\xb9\xf6\xe4\xa0\x49\x80\xa9\xbe\x5c\x59\x06\x9f\x34\xaf\x61\xbf\xe5\x16\x4d\x43\x4b\x1c\x76\xa5\x7b\x6e\xb8\x65\x55\x53\x5b\x6e\x63\xf2\x39\x32\xb7\x0e\x23\x32\xb7\xdf\x0c\xa6\x0c\xaf\xc0\x58\xcd\xe5\x26\xaf\xb8\x64\x1e\x25\x0d\x69\x4d\x3a\x07\x46\x6f\x19\x4f\x20\xa6\x50\x9b\x8d\x63\x29\x78\x08\x48\x43\x17\x23\x6b\x5e\xc1\x9a\x1a\x94\xee\x5d\x73\xfd\x10\xf2\xaf\xc1\xfe\xdc\xbf\x7b\xae\x03\x18\xf7\xd0\xa8\x7d\xfa\xfe\xb3\x4a\xb6\xf5\x1a\xb5\x0f\x24\xf1\x21\xa6\xf0\x7a\x1c\xca\xf9\xd1\x33\x94\xaf\xdb\x3a\x14\xdf\x58\x9d\x82\xc1\x26\x19\xd5\xdd\xb4\xc2\x3d\xfd\x4e\x5f\x66\xba\x21\x26\xf1\x9f\x9f\x23\xf3\xb7\x2f\x72\xe8\x8a\xb8\x77\xe0\x8a\x8b\xb4\xdc\xba\xd2\x1a\xab\x57\x9b\xc0\x5a\x47\xf9\xa0\xbc\xd6\x0d\xf4\x9c\x4b\x83\xda\xc6\x01\x30\xf5\x96\xc9\xe8\xdd\xa6\xd1\xb6\x5a\x76\x11\x4d\x12\x18\xd3\x39\x88\xd4\x6d\x5e\xea\xe6\xfb\x30\x54\x95\xc4\xf9\xed\xab\x24\xce\x6f\x13\xd7\x93\xd1\xeb\xae\x53\x3a\x10\x67\xe6\x21\xfe\x0d\x00\x00\xff\xff\xba\xca\xd7\xde\xd0\x0b\x00\x00") +var _runtimePluginsLinterLinterLua = []byte("\x1f\x8b\x08\x00\x00\x00\x00\x00\x00\xff\xa4\x56\x6d\x8b\xdc\x36\x10\xfe\x7c\xfb\x2b\x06\x51\x83\x7d\x6b\x3b\x6d\xe8\xa7\x05\x53\xd2\x6b\x13\x28\x49\xae\x70\x69\xfb\xa1\x6d\x8a\xd6\x1a\xef\xea\x4e\x96\x8c\x24\xef\x0b\x4b\xfe\x7b\x91\xe4\xf5\xda\x5e\xdf\x91\xd2\x83\x5b\xc9\xd2\x68\x9e\x79\x79\xa4\x19\x5e\xc1\x3b\xb4\xf7\x8d\xe5\x4a\xc6\x44\x70\x69\x51\x93\x04\x8a\x02\x24\x17\x60\xb7\x28\x17\x00\x00\x6f\x18\x9b\xc8\xa4\x60\x75\x8b\xc9\x02\x25\x5b\x2c\x3e\xd0\x27\xbc\x53\x75\x4d\x25\x0b\x02\x24\x85\x4e\x30\x77\x43\xb7\x47\x52\xf8\x36\x59\x2c\xaa\x56\x96\x4e\x17\x0c\xb6\xe2\xc4\xe3\xdc\xb5\xfa\x77\x8e\xfb\x38\x59\x3d\xd0\x1d\xc6\x15\x15\x06\xc3\x8e\x6e\xe5\x7b\xaf\x30\xee\x30\x7b\x2d\xc3\x1d\x27\x29\x54\x49\x05\x54\x16\x8a\x8b\xba\xfc\xc7\xb6\x5a\xbd\xe5\x02\x3f\x1d\x1b\x1c\xcb\x71\x81\x53\xc9\xfc\x57\x6a\xb7\x03\x19\xc6\x35\x14\xf0\x13\xd7\x58\x5a\xa5\x8f\x1f\x69\x8d\xb1\x3b\x17\xf4\xf0\x0a\xee\x1f\x5c\xc4\xc8\x9e\x4b\xa6\xf6\x86\x5c\xe2\xe6\xfe\x18\xee\x64\x2b\x04\x14\x40\x3e\xfe\xf6\x9e\xf8\x75\x14\x06\xfd\xe4\x66\xb0\xfb\x8a\xe1\xee\x95\xfb\xe8\x64\x24\x3b\xeb\x77\xce\x14\x40\x36\x6a\xa2\xda\x05\x30\x26\x1b\xb5\x6e\xb9\x70\xd1\x75\x12\x29\x9c\x48\xff\x9d\xb9\xef\x0e\xe2\x4b\x0a\x24\xaa\x56\x91\x58\x41\x54\x93\xe4\x4a\xc9\x39\x6f\xfd\xec\xe4\x7c\xbc\x9c\x8a\xd8\x72\x70\xd2\x79\x70\xb1\x4c\xb4\x74\xd6\x34\xd1\xd2\x72\x8b\xe5\x93\xe7\xc3\x65\x7e\x22\x59\x26\x55\x56\x2a\xa1\x1c\x93\xbe\x1e\xa7\x39\xda\xad\x92\xb3\x50\xcd\xb1\x12\xf4\x09\x8d\x83\x1a\xcc\x27\x4e\xe4\xd9\xea\x87\x39\xf7\xeb\x63\x73\x74\x27\xbb\x71\x72\x6a\xee\x44\x73\x3c\x07\xac\x9f\x39\xb7\x54\x6b\x9b\xd6\x66\x95\xd2\x35\xb5\x45\x43\xb5\x41\xba\x16\xe8\x93\x91\x69\x6c\x94\xb6\xa6\x90\xea\xca\xeb\xe7\x3c\x2e\xe7\x53\x5e\x96\x3e\x55\x7e\x38\x91\xac\x32\x47\x69\xe9\x21\x53\x52\x78\x37\xb2\x3f\xa8\x10\x61\x82\x07\xab\xe9\x6c\x90\xf3\x73\x9c\x6f\x26\x90\xcb\xe5\x18\xf4\x6b\x30\x49\x66\x2c\x2b\xca\xe5\xf2\xbb\xef\xff\xb3\x01\x37\x37\x33\x8e\x9b\x3d\xaf\xec\xac\xf3\x66\xcf\x6d\xe5\x6d\x39\x94\xba\x95\xde\x1a\x2f\x5d\xbe\xec\xe6\x35\xc6\xfd\xfa\x11\x4b\xcb\x77\x98\xdd\xcd\x22\x95\x82\xca\xcd\x18\xa8\x5f\xfa\x9f\x31\xbf\x36\x86\xcd\x9a\xc0\x6a\x7f\x91\xc3\x70\x22\xe1\xce\x14\xaa\xaa\xc2\xf5\xce\xfc\xb0\x0f\xbf\xdc\x0f\xe3\x28\x44\x71\x24\xa2\xe4\x25\xdc\x47\xba\x9b\xbf\xbc\x6e\xc3\x87\xf9\x3c\x39\x91\xcc\x59\xc1\xb8\xbe\x62\x2f\x6a\xad\xf4\x8b\x10\xa6\xd4\xbc\x99\x4f\xe8\xa3\xd9\x76\x57\xa9\x9f\x0d\x2f\xa0\x93\x42\x88\x44\x9a\x2f\xd3\xe7\x10\x24\xaf\x67\x55\xbb\xf5\x14\xba\xe1\x44\xfa\xc7\x28\xcb\x04\x37\xf6\x6d\x2b\x84\x7b\xeb\x4d\x58\x32\x96\xa9\xd6\x86\xb9\xb3\xc3\xac\x42\x9c\x2f\xb6\xe4\x91\x48\x21\x62\xcb\xfc\xca\x0e\x63\x35\x97\x9b\xbc\xa6\xb6\xdc\xc6\x95\xf5\xf5\xcf\xa2\xa6\x16\x49\x32\xfb\x32\x9e\x77\x83\x64\x97\xdc\x6b\xce\xf4\x30\x92\x4d\xea\x9e\x92\xbe\x46\xee\x38\xee\xfb\x42\x34\x57\xcb\x47\xe0\xd3\x62\xd9\x17\xa2\x71\xf5\xbd\x13\x48\xf5\x1b\x21\xde\xb5\xd6\xa2\xfe\x80\xc6\xd0\x0d\x9a\xf8\x39\x53\xbc\x4b\x01\x30\x85\xb2\x66\x29\x50\xbd\x31\x69\x60\x45\x78\x0a\xa7\xf5\xdd\x23\x4c\xd4\x07\x0d\xc9\xc2\x8b\xfe\xa2\xd6\x0f\x0d\xdd\xcb\x78\xa0\x8f\x90\xee\xbf\xeb\x2d\x94\xfc\xf9\xe0\x63\x77\xc6\x1e\x01\x4e\xc3\xe5\x64\xe3\xf0\x3e\x3f\x73\xe2\x52\xf2\x1d\xe5\x0c\x14\x60\x1a\x31\x38\x44\xfe\x92\xa4\x33\x2f\x88\x69\xdc\xe0\x01\x8a\xa1\x96\xd5\xc6\xb4\xeb\x98\x44\x91\xbf\xa1\x71\x9e\x67\x09\x49\xfa\x45\xff\x40\xc4\x11\x5b\x0e\x17\xeb\x20\xe9\xd6\xbc\xee\x4a\x69\xf8\x27\xf5\xac\xe7\x12\x78\x43\xb9\xf6\xc1\x41\x93\x00\x53\x7d\xba\xb2\x0c\x3e\x69\x5e\xc3\x7e\xcb\x2d\x9a\x86\x96\x38\xe4\x98\xeb\x6a\xdc\xb0\x0a\x94\x24\x9f\x23\x73\xeb\x30\x22\x73\xfb\xcd\xa0\x98\x5d\xa8\x5b\x71\xc9\x3c\x4a\x1a\xdc\x9a\x30\x07\x46\x2d\x93\x0f\x20\xa6\x50\x9b\x8d\x8b\xd2\x90\xfc\x43\x15\xa3\xd3\xbc\x82\x35\x35\x28\x5d\xfb\x74\xdd\x6f\xf9\xa6\xb3\xdf\xf7\xed\xd5\xb5\x01\x63\x0e\x8d\xe8\xd3\xf3\xcf\x2a\xd9\xd6\x6b\xd4\xde\x90\xc4\x9b\x98\xc2\xeb\xb1\x29\xe7\xde\x6a\x38\xbf\xa6\x75\x48\xbe\xb1\x3a\x05\x83\x4d\x32\xca\xbb\x69\x85\xeb\x30\x4f\x5f\x66\xd8\x10\x93\xf8\xcf\xcf\x91\xf9\xdb\x27\x39\xb0\x22\xee\x15\xb8\xe4\x22\x2d\xb7\x2e\xb5\xc6\xea\xd5\x26\x44\xad\x0b\xf9\x20\xbd\xd6\xf5\x0d\x39\x97\x06\xb5\x8d\x03\x60\xea\x4f\x26\xa3\xf6\x50\xa3\x6d\xb5\xec\x2c\x9a\x38\x30\x0e\xe7\xc0\x52\xb7\x78\xc9\x9b\xe7\x61\xc8\x2a\x89\xf3\xdb\x57\x49\x9c\xdf\x26\x8e\x93\xd1\xeb\x8e\x29\x1d\x88\x3b\xe6\x21\xfe\x0d\x00\x00\xff\xff\xa3\xce\x4a\xc8\x37\x0c\x00\x00") func runtimePluginsLinterLinterLuaBytes() ([]byte, error) { return bindataRead( diff --git a/runtime/plugins/linter/linter.lua b/runtime/plugins/linter/linter.lua index c97a898d..db0cf8fc 100644 --- a/runtime/plugins/linter/linter.lua +++ b/runtime/plugins/linter/linter.lua @@ -43,6 +43,8 @@ function runLinter() lint("jshint", "jshint", {file}, "%f: line %l,.+, %m") elseif ft == "nim" then lint("nim", "nim", {"check", "--listFullPaths", "--stdout", "--hints:off", file}, "%f.%l, %d+. %m") + elseif string.match(ft, "literate") then + lint("literate", "lit", {"-c", file}, "%f:%l:%m") end end