diff --git a/go.mod b/go.mod index 8a4e06d1..f5b85ab5 100644 --- a/go.mod +++ b/go.mod @@ -18,7 +18,7 @@ require ( github.com/zyedidia/tcell/v2 v2.0.8 github.com/zyedidia/terminal v0.0.0-20180726154117-533c623e2415 golang.org/x/text v0.3.2 - gopkg.in/yaml.v2 v2.2.7 + gopkg.in/yaml.v2 v2.2.8 layeh.com/gopher-luar v1.0.7 ) @@ -26,4 +26,6 @@ replace github.com/kballard/go-shellquote => github.com/zyedidia/go-shellquote v replace github.com/mattn/go-runewidth => github.com/zyedidia/go-runewidth v0.0.12 +replace layeh.com/gopher-luar => github.com/layeh/gopher-luar v1.0.7 + go 1.16 diff --git a/go.sum b/go.sum index 3cdc362b..c3b38c59 100644 --- a/go.sum +++ b/go.sum @@ -17,6 +17,8 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/layeh/gopher-luar v1.0.7 h1:wnfZhYiJM748y1A4qYBfcFeMY9HWbdERny+ZL0f/jWc= +github.com/layeh/gopher-luar v1.0.7/go.mod h1:TPnIVCZ2RJBndm7ohXyaqfhzjlZ+OA2SZR/YwL8tECk= github.com/lucasb-eyer/go-colorful v1.0.3 h1:QIbQXiugsb+q10B+MI+7DI1oQLdmnep86tWFlaaUAac= github.com/lucasb-eyer/go-colorful v1.0.3/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0= github.com/mattn/go-isatty v0.0.11 h1:FxPOTFNqGkuDUGi3H/qkUbQO4ZiBa2brKq5r0l8TGeM= @@ -68,7 +70,5 @@ gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogR gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.7 h1:VUgggvou5XRW9mHwD/yXxIYSMtY0zoKQf/v226p2nyo= -gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -layeh.com/gopher-luar v1.0.7 h1:53iv6CCkRs5wyofZ+qVXcyAYQOIG52s6pt4xkqZdq7k= -layeh.com/gopher-luar v1.0.7/go.mod h1:TPnIVCZ2RJBndm7ohXyaqfhzjlZ+OA2SZR/YwL8tECk= +gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/internal/display/statusline.go b/internal/display/statusline.go index 947a3ee7..be808eee 100644 --- a/internal/display/statusline.go +++ b/internal/display/statusline.go @@ -47,6 +47,12 @@ var statusInfo = map[string]func(*buffer.Buffer) string{ } return "" }, + "lines": func(b *buffer.Buffer) string { + return strconv.Itoa(b.LinesNum()) + }, + "percentage": func(b *buffer.Buffer) string { + return strconv.Itoa((b.GetActiveCursor().Y + 1) * 100 / b.LinesNum()) + }, } func SetStatusInfoFnLua(fn string) { diff --git a/runtime/help/defaultkeys.md b/runtime/help/defaultkeys.md index b724ab56..31941491 100644 --- a/runtime/help/defaultkeys.md +++ b/runtime/help/defaultkeys.md @@ -83,6 +83,8 @@ can change it! | Alt-DownArrow | Move current line or selected lines down | | Alt-Backspace or Alt-Ctrl-h | Delete word left | | Ctrl-a | Select all | +| Tab | Indent selected text | +| Shift-Tab | Unindent selected text | ### Macros diff --git a/runtime/help/options.md b/runtime/help/options.md index 6b872398..89d85396 100644 --- a/runtime/help/options.md +++ b/runtime/help/options.md @@ -238,7 +238,7 @@ Here are the available options: given line and column 0. Note that with this option enabled it is not possible to open a file such as `file.txt:10:5`, where `:10:5` is part of the filename. It is also possible to open a file with a certain cursor location by using the - `+LINE,COL` flag syntax. See `micro -help` for the command line options. + `+LINE:COL` flag syntax. See `micro -help` for the command line options. default value: `false` @@ -333,7 +333,7 @@ Here are the available options: * `statusformatl`: format string definition for the left-justified part of the statusline. Special directives should be placed inside `$()`. Special - directives include: `filename`, `modified`, `line`, `col`, `opt`, `bind`. + directives include: `filename`, `modified`, `line`, `col`, `lines`, `percentage`, `opt`, `bind`. The `opt` and `bind` directives take either an option or an action afterward and fill in the value of the option or the key bound to the action. @@ -369,7 +369,11 @@ Here are the available options: default value: `4` -* `tabstospaces`: use spaces instead of tabs. +* `tabstospaces`: use spaces instead of tabs. Note: This option will be + overridden by [the `ftoptions` plugin](https://github.com/zyedidia/micro/blob/master/runtime/plugins/ftoptions/ftoptions.lua) + for certain filetypes. To disable this behavior, add `"ftoptions": false` to + your config. See [issue #2213](https://github.com/zyedidia/micro/issues/2213) + for more details. default value: `false` diff --git a/runtime/help/plugins.md b/runtime/help/plugins.md index d959488c..c2e202ac 100644 --- a/runtime/help/plugins.md +++ b/runtime/help/plugins.md @@ -401,7 +401,7 @@ There are 6 default plugins that come pre-installed with micro. These are * `autoclose`: automatically closes brackets, quotes, etc... * `comment`: provides automatic commenting for a number of languages -* `ftoptions`: alters some default options depending on the filetype +* `ftoptions`: alters some default options (notably indentation) depending on the filetype * `linter`: provides extensible linting for many languages * `literate`: provides advanced syntax highlighting for the Literate programming tool. diff --git a/runtime/syntax/git-commit.yaml b/runtime/syntax/git-commit.yaml index 9f8ef0d9..07a71c26 100644 --- a/runtime/syntax/git-commit.yaml +++ b/runtime/syntax/git-commit.yaml @@ -1,7 +1,7 @@ filetype: git-commit detect: - filename: "^(.*[\\/])?(COMMIT_EDITMSG|TAG_EDITMSG)$" + filename: "^(.*[\\/])?(COMMIT_EDITMSG|TAG_EDITMSG|MERGE_MSG|git-rebase-todo)$" rules: # File changes diff --git a/runtime/syntax/groovy.yaml b/runtime/syntax/groovy.yaml old mode 100755 new mode 100644 diff --git a/runtime/syntax/odin.yaml b/runtime/syntax/odin.yaml new file mode 100644 index 00000000..1326356c --- /dev/null +++ b/runtime/syntax/odin.yaml @@ -0,0 +1,64 @@ +filetype: odin + +detect: + filename: "\\.odin$" + +rules: + # Conditionals and control flow + - special: "\\b(asm|auto_cast|break|case|cast|context|continue|do|dynamic|fallthrough|return|transmute|using|where)\\b" + - statement: "\\b(else|for|if|switch|in|not_in|or_else|or_return|when)\\b" + - preproc: "\\b(assert|package|foreign|import|proc|defer|make|new|free|delete|copy|len|cap|append|raw_data)\\b" + - preproc: "\\b((size|align|offset|type|type_info|typeid)_of|offset_of_by_string)\\b" + - preproc: "\\b(swizzle|complex|quaternion|real|imag|jmag|kmag|conj|expand_to_tuple|min|max|abs|clamp|soa_zip|soa_unzip|transpose|outer_product|hadamard_product|matrix_flatten)\\b" + - symbol.operator: "[-+/*=<>!~%&|^@]|:\\s*=|:\\s*:|\\?" + + # Types + - symbol: "(,|\\.)" + - type: "\\b(b(8|16|32|64)|(i|u)(8|(16|32|64|128)(le|be)?)|f(16|32|64)(le|be)?|complex(32|64|128)|quaternion(64|128|256))\\b" + - type: "\\b(any|bool|byte|rune|u?int|uintptr|rawptr|c?string|map|matrix|typeid)\\b" + - type.keyword: "\\b(distinct|struct|enum|union|bit_set)\\b" + - constant.bool: "\\b(true|false|nil)\\b" + + # Brackets + - symbol.brackets: "(\\{|\\})" + - symbol.brackets: "(\\(|\\))" + - symbol.brackets: "(\\[|\\])" + + # Numbers and strings + - constant.number: "\\b(0b[01]*|0o[0-7]*|0x[0-9a-fA-F]*|[0-9_]+|0d[0-9]*|0z[0-9abAB]*)\\b|'.'" + + - constant.string: + start: "\"" + end: "\"" + skip: "\\\\." + rules: + - constant.specialChar: "%." + - constant.specialChar: "\\\\[abfnrtv'\\\"\\\\]" + - constant.specialChar: "\\\\([0-7]{1,3}|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8})" + + - constant.string: + start: "'" + end: "'" + skip: "\\\\." + rules: + - error: "..+" + - constant.specialChar: "%." + - constant.specialChar: "\\\\[abfnrtv'\\\"\\\\]" + - constant.specialChar: "\\\\([0-7]{1,3}|x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|U[0-9a-fA-F]{8})" + + - constant.string: + start: "`" + end: "`" + rules: [] + + - comment: + start: "//" + end: "$" + rules: + - todo: "TODO:?|NOTE(\\(.*\\))?:?" + + - comment: + start: "/\\*" + end: "\\*/" + rules: + - todo: "TODO:?|NOTE(\\(.*\\))?:?" diff --git a/runtime/syntax/perl.yaml b/runtime/syntax/perl.yaml index 3fcb8703..edcc9f05 100644 --- a/runtime/syntax/perl.yaml +++ b/runtime/syntax/perl.yaml @@ -1,32 +1,51 @@ filetype: perl detect: - filename: "\\.p[lm]$" + filename: "\\.pp[lmp]$" header: "^#!.*/(env +)?perl( |$)" rules: - - type: "\\b(accept|alarm|atan2|bin(d|mode)|c(aller|h(dir|mod|op|own|root)|lose(dir)?|onnect|os|rypt)|d(bm(close|open)|efined|elete|ie|o|ump)|e(ach|of|val|x(ec|ists|it|p))|f(cntl|ileno|lock|ork))\\b|\\b(get(c|login|peername|pgrp|ppid|priority|pwnam|(host|net|proto|serv)byname|pwuid|grgid|(host|net)byaddr|protobynumber|servbyport)|([gs]et|end)(pw|gr|host|net|proto|serv)ent|getsock(name|opt)|gmtime|goto|grep|hex|index|int|ioctl|join)\\b|\\b(keys|kill|last|length|link|listen|local(time)?|log|lstat|m|mkdir|msg(ctl|get|snd|rcv)|next|oct|open(dir)?|ord|pack|pipe|pop|printf?|push|q|qq|qx|rand|re(ad(dir|link)?|cv|do|name|quire|set|turn|verse|winddir)|rindex|rmdir|s|scalar|seek(dir)?)\\b|\\b(se(lect|mctl|mget|mop|nd|tpgrp|tpriority|tsockopt)|shift|shm(ctl|get|read|write)|shutdown|sin|sleep|socket(pair)?|sort|spli(ce|t)|sprintf|sqrt|srand|stat|study|substr|symlink|sys(call|read|tem|write)|tell(dir)?|time|tr(y)?|truncate|umask)\\b|\\b(un(def|link|pack|shift)|utime|values|vec|wait(pid)?|wantarray|warn|write)\\b" + - type: "\\b(accept|alarm|atan2|bin(d|mode)|c(aller|homp|h(dir|mod|op|own|root)|lose(dir)?|onnect|os|rypt)|d(bm(close|open)|efined|elete|ie|o|ump)|e(ach|of|val|x(ec|ists|it|p))|f(cntl|ileno|lock|ork))\\b|\\b(get(c|login|peername|pgrp|ppid|priority|pwnam|(host|net|proto|serv)byname|pwuid|grgid|(host|net)byaddr|protobynumber|servbyport)|([gs]et|end)(pw|gr|host|net|proto|serv)ent|getsock(name|opt)|gmtime|goto|grep|hex|index|int|ioctl|join)\\b|\\b(keys|kill|last|length|link|listen|local(time)?|log|lstat|m|mkdir|msg(ctl|get|snd|rcv)|next|oct|open(dir)?|ord|pack|pipe|pop|printf?|push|q|qq|qx|rand|re(ad(dir|link)?|cv|say|do|name|quire|set|turn|verse|winddir)|rindex|rmdir|s|scalar|seek(dir)?)\\b|\\b(se(lect|mctl|mget|mop|nd|tpgrp|tpriority|tsockopt)|shift|shm(ctl|get|read|write)|shutdown|sin|sleep|socket(pair)?|sort|spli(ce|t)|sprintf|sqrt|srand|stat|study|substr|symlink|sys(call|read|tem|write)|tell(dir)?|time|tr(y)?|truncate|umask)\\b|\\b(un(def|link|pack|shift)|utime|values|vec|wait(pid)?|wantarray|warn|write)\\b" - statement: "\\b(continue|else|elsif|do|for|foreach|if|unless|until|while|eq|ne|lt|gt|le|ge|cmp|x|my|sub|use|package|can|isa)\\b" - special: "\\-\\>" - symbol: "(,|\\.)" + + #regexes + - identifier.macro: "m?\\/.*?\\/[a-z]*" + - identifier.macro: "m?\\|.*?\\|[a-z]*" + - identifier.macro: "\\bs/.*?/.*?/[a-z]*" + - identifier.macro: "\\bs\\|.*?\\|.*?\\|[a-z]*" + + - constant.string: + start: '"' + end: '"' + skip: '\\"' + rules: + - identifier.var: '[\\$@%].[a-zA-Z0-9_]*' - - identifier: - start: "[\\$@%]" - end: "\\W" + - constant.string: + start: "'" + end: "'" + skip: "\\\\'" rules: [] - - - constant.string: "\"\\(.*\\)\"|qq?\\|.*\\||qq?\\{.*\\}|qq?\\/.*\\/" - - default: "[sm]/.*/" - - preproc: - start: "(^use| = new)" - end: ";" - rules: [] - + - comment: start: "#" end: "$" rules: [] + + - constant.string: "\"\\(.*\\)\"|qq?\\|.*\\||qq?\\{.*\\}|qq?\\/.*\\/" + - constant.number: "\\b([0-9]*[.])?[0-9]+" + - constant.number: "\\b[0-9]+" + - constant.number: "\\b0x[a-f0-9]+" + - constant.string.url: "`(.+?)`" + - identifier.var: '[\\$@%].[a-zA-Z0-9_]*' + + - preproc: + start: "(^use| = new)" + end: ";" + rules: [] - comment: start: "^="