Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion data/micro.json
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,19 @@
"default": false
},
"matchbrace": {
"description": "Whether to underline matching braces\nhttps://github.com/zyedidia/micro/blob/master/runtime/help/options.md#options",
"description": "Whether to show matching braces\nhttps://github.com/zyedidia/micro/blob/master/runtime/help/options.md#options",
"type": "boolean",
"default": true
},
"matchbracestyle": {
"description": "Whether to underline or highlight matching braces\nhttps://github.com/zyedidia/micro/blob/master/runtime/help/options.md#options",
"type": "string",
"enum": [
"underline",
"highlight"
],
"default": "underline"
},
"mkparents": {
"description": "Whether to create missing directories\nhttps://github.com/zyedidia/micro/blob/master/runtime/help/options.md#options",
"type": "boolean",
Expand Down
7 changes: 7 additions & 0 deletions internal/action/infocomplete.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,13 @@ func OptionValueComplete(b *buffer.Buffer) ([]string, []string) {
if strings.HasPrefix("terminal", input) {
suggestions = append(suggestions, "terminal")
}
case "matchbracestyle":
if strings.HasPrefix("underline", input) {
suggestions = append(suggestions, "underline")
}
if strings.HasPrefix("highlight", input) {
suggestions = append(suggestions, "highlight")
}
}
}
sort.Strings(suggestions)
Expand Down
20 changes: 10 additions & 10 deletions internal/buffer/buffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,7 @@ func (b *Buffer) FindMatchingBrace(braceType [2]rune, start Loc) (Loc, bool, boo
leftChar = curLine[start.X-1]
}
var i int
if startChar == braceType[0] || leftChar == braceType[0] {
if startChar == braceType[0] || (leftChar == braceType[0] && startChar != braceType[1]) {
for y := start.Y; y < b.LinesNum(); y++ {
l := []rune(string(b.LineBytes(y)))
xInit := 0
Expand Down Expand Up @@ -1046,24 +1046,24 @@ func (b *Buffer) FindMatchingBrace(braceType [2]rune, start Loc) (Loc, bool, boo
l := []rune(string(b.lines[y].data))
xInit := len(l) - 1
if y == start.Y {
if leftChar == braceType[1] {
xInit = start.X - 1
} else {
if startChar == braceType[1] {
xInit = start.X
} else {
xInit = start.X - 1
}
}
for x := xInit; x >= 0; x-- {
r := l[x]
if r == braceType[0] {
if r == braceType[1] {
i++
} else if r == braceType[0] {
i--
if i == 0 {
if leftChar == braceType[1] {
return Loc{x, y}, true, true
if startChar == braceType[1] {
return Loc{x, y}, false, true
}
return Loc{x, y}, false, true
return Loc{x, y}, true, true
}
} else if r == braceType[1] {
i++
}
}
}
Expand Down
128 changes: 73 additions & 55 deletions internal/config/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,18 @@ func init() {

// Options with validators
var optionValidators = map[string]optionValidator{
"autosave": validateNonNegativeValue,
"clipboard": validateClipboard,
"tabsize": validatePositiveValue,
"scrollmargin": validateNonNegativeValue,
"scrollspeed": validateNonNegativeValue,
"colorscheme": validateColorscheme,
"colorcolumn": validateNonNegativeValue,
"fileformat": validateLineEnding,
"encoding": validateEncoding,
"multiopen": validateMultiOpen,
"reload": validateReload,
"autosave": validateNonNegativeValue,
"clipboard": validateClipboard,
"tabsize": validatePositiveValue,
"scrollmargin": validateNonNegativeValue,
"scrollspeed": validateNonNegativeValue,
"colorscheme": validateColorscheme,
"colorcolumn": validateNonNegativeValue,
"fileformat": validateLineEnding,
"encoding": validateEncoding,
"multiopen": validateMultiOpen,
"reload": validateReload,
"matchbracestyle": validateMatchBraceStyle,
}

func ReadSettings() error {
Expand Down Expand Up @@ -274,50 +275,51 @@ func GetGlobalOption(name string) interface{} {
}

var defaultCommonSettings = map[string]interface{}{
"autoindent": true,
"autosu": false,
"backup": true,
"backupdir": "",
"basename": false,
"colorcolumn": float64(0),
"cursorline": true,
"diffgutter": false,
"encoding": "utf-8",
"eofnewline": true,
"fastdirty": false,
"fileformat": defaultFileFormat(),
"filetype": "unknown",
"hlsearch": false,
"incsearch": true,
"ignorecase": true,
"indentchar": " ",
"keepautoindent": false,
"matchbrace": true,
"mkparents": false,
"permbackup": false,
"readonly": false,
"reload": "prompt",
"rmtrailingws": false,
"ruler": true,
"relativeruler": false,
"savecursor": false,
"saveundo": false,
"scrollbar": false,
"scrollmargin": float64(3),
"scrollspeed": float64(2),
"smartpaste": true,
"softwrap": false,
"splitbottom": true,
"splitright": true,
"statusformatl": "$(filename) $(modified)($(line),$(col)) $(status.paste)| ft:$(opt:filetype) | $(opt:fileformat) | $(opt:encoding)",
"statusformatr": "$(bind:ToggleKeyMenu): bindings, $(bind:ToggleHelp): help",
"statusline": true,
"syntax": true,
"tabmovement": false,
"tabsize": float64(4),
"tabstospaces": false,
"useprimary": true,
"wordwrap": false,
"autoindent": true,
"autosu": false,
"backup": true,
"backupdir": "",
"basename": false,
"colorcolumn": float64(0),
"cursorline": true,
"diffgutter": false,
"encoding": "utf-8",
"eofnewline": true,
"fastdirty": false,
"fileformat": defaultFileFormat(),
"filetype": "unknown",
"hlsearch": false,
"incsearch": true,
"ignorecase": true,
"indentchar": " ",
"keepautoindent": false,
"matchbrace": true,
"matchbracestyle": "underline",
"mkparents": false,
"permbackup": false,
"readonly": false,
"reload": "prompt",
"rmtrailingws": false,
"ruler": true,
"relativeruler": false,
"savecursor": false,
"saveundo": false,
"scrollbar": false,
"scrollmargin": float64(3),
"scrollspeed": float64(2),
"smartpaste": true,
"softwrap": false,
"splitbottom": true,
"splitright": true,
"statusformatl": "$(filename) $(modified)($(line),$(col)) $(status.paste)| ft:$(opt:filetype) | $(opt:fileformat) | $(opt:encoding)",
"statusformatr": "$(bind:ToggleKeyMenu): bindings, $(bind:ToggleHelp): help",
"statusline": true,
"syntax": true,
"tabmovement": false,
"tabsize": float64(4),
"tabstospaces": false,
"useprimary": true,
"wordwrap": false,
}

func defaultFileFormat() string {
Expand Down Expand Up @@ -548,6 +550,22 @@ func validateReload(option string, value interface{}) error {
case "prompt", "auto", "disabled":
default:
return errors.New(option + " must be 'prompt', 'auto' or 'disabled'")
}

return nil
}

func validateMatchBraceStyle(option string, value interface{}) error {
val, ok := value.(string)

if !ok {
errors.New("Expected string type for matchbracestyle")
}

switch val {
case "underline", "highlight":
default:
return errors.New(option + " must be 'underline' or 'highlight'")
}

return nil
Expand Down
14 changes: 12 additions & 2 deletions internal/display/bufwindow.go
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,9 @@ func (w *BufWindow) displayBuffer() {
if found {
matchingBraces = append(matchingBraces, mb)
if !left {
matchingBraces = append(matchingBraces, curLoc)
if b.Settings["matchbracestyle"].(string) != "highlight" {
matchingBraces = append(matchingBraces, curLoc)
}
} else {
matchingBraces = append(matchingBraces, curLoc.Move(-1, b))
}
Expand Down Expand Up @@ -557,7 +559,15 @@ func (w *BufWindow) displayBuffer() {

for _, mb := range matchingBraces {
if mb.X == bloc.X && mb.Y == bloc.Y {
style = style.Underline(true)
if b.Settings["matchbracestyle"].(string) == "highlight" {
if s, ok := config.Colorscheme["match-brace"]; ok {
style = s
} else {
style = style.Reverse(true)
}
} else {
style = style.Underline(true)
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions runtime/colorschemes/atom-dark.micro
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ color-link color-column "#2D2F31"
#No extended types (bool in C, etc.)
#color-link type.extended "default"
#Plain brackets
color-link match-brace "#1D1F21,#62B1FE"
1 change: 1 addition & 0 deletions runtime/colorschemes/bubblegum.micro
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ color-link color-column "254"
#No extended types (bool in C, &c.) and plain brackets
color-link type.extended "241,231"
color-link symbol.brackets "241,231"
color-link match-brace "231,28"
1 change: 1 addition & 0 deletions runtime/colorschemes/cmc-16.micro
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,4 @@ color-link gutter-warning "red"
color-link color-column "cyan"
color-link underlined.url "underline blue, white"
color-link divider "blue"
color-link match-brace "black,cyan"
1 change: 1 addition & 0 deletions runtime/colorschemes/cmc-tc.micro
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@ color-link color-column "#f26522"
color-link constant.bool "bold #55ffff"
color-link constant.bool.true "bold #85ff85"
color-link constant.bool.false "bold #ff8585"
color-link match-brace "#1e2124,#55ffff"
1 change: 1 addition & 0 deletions runtime/colorschemes/darcula.micro
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ color-link color-column "#2C2C2C"
color-link type.extended "default"
#color-link symbol.brackets "default"
color-link symbol.tag "#AE81FF,#242424"
color-link match-brace "#242424,#7A9EC2"
1 change: 1 addition & 0 deletions runtime/colorschemes/default.micro
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ color-link color-column "#323232"
color-link type.extended "default"
#color-link symbol.brackets "default"
color-link symbol.tag "#AE81FF,#282828"
color-link match-brace "#282828,#AE81FF"
1 change: 1 addition & 0 deletions runtime/colorschemes/dracula-tc.micro
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ color-link cursor-line "#44475A,#F8F8F2"
color-link color-column "#44475A"
color-link type.extended "default"

color-link match-brace "#282A36,#FF79C6"
1 change: 1 addition & 0 deletions runtime/colorschemes/dukedark-tc.micro
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ color-link type "bold #3cc83c,#001e28"
color-link type.keyword "bold #5aaae6,#001e28"
color-link type.extended "#ffffff,#001e28"
color-link underlined "#608b4e,#001e28"
color-link match-brace "#001e28,#5aaae6"
1 change: 1 addition & 0 deletions runtime/colorschemes/dukelight-tc.micro
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ color-link type "bold #004080,#f0f0f0"
color-link type.keyword "bold #780050,#f0f0f0"
color-link type.extended "#000000,#f0f0f0"
color-link underlined "#3f7f5f,#f0f0f0"
color-link match-brace "#f0f0f0,#780050"
1 change: 1 addition & 0 deletions runtime/colorschemes/dukeubuntu-tc.micro
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ color-link type "bold #3cc83c,#2d0023"
color-link type.keyword "bold #5aaae6,#2d0023"
color-link type.extended "#ffffff,#2d0023"
color-link underlined "#886484,#2d0023"
color-link match-brace "#2d0023,#5aaae6"
1 change: 1 addition & 0 deletions runtime/colorschemes/geany.micro
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ color-link diff-modified "yellow"
color-link diff-deleted "red"
color-link gutter-error ",red"
color-link gutter-warning "red"
color-link match-brace "black,cyan"
1 change: 1 addition & 0 deletions runtime/colorschemes/gotham.micro
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ color-link gutter-warning "#EDB443,#11151C"
color-link cursor-line "#091F2E"
color-link color-column "#11151C"
color-link symbol "#99D1CE,#0C1014"
color-link match-brace "#0C1014,#D26937"
1 change: 1 addition & 0 deletions runtime/colorschemes/gruvbox-tc.micro
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ color-link cursor-line "#3c3836"
color-link color-column "#79740e"
color-link statusline "#ebdbb2,#665c54"
color-link tabbar "#ebdbb2,#665c54"
color-link match-brace "#282828,#d3869b"
1 change: 1 addition & 0 deletions runtime/colorschemes/gruvbox.micro
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ color-link cursor-line "237"
color-link color-column "237"
color-link statusline "223,237"
color-link tabbar "223,237"
color-link match-brace "235,72"
1 change: 1 addition & 0 deletions runtime/colorschemes/material-tc.micro
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ color-link tabbar "#80DEEA,#3b4d56"
color-link todo "bold #C792EA,#263238"
color-link type "#FFCB6B,#263238"
color-link underlined "underline #EEFFFF,#263238"
color-link match-brace "#263238,#C792EA"
1 change: 1 addition & 0 deletions runtime/colorschemes/monokai-dark.micro
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ color-link gutter-error "#CB4B16"
color-link gutter-warning "#E6DB74"
color-link cursor-line "#323232"
color-link color-column "#323232"
color-link match-brace "#1D0000,#AE81FF"
1 change: 1 addition & 0 deletions runtime/colorschemes/monokai.micro
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ color-link color-column "#323232"
color-link type.extended "default"
#color-link symbol.brackets "default"
color-link symbol.tag "#AE81FF,#282828"
color-link match-brace "#282828,#AE81FF"
1 change: 1 addition & 0 deletions runtime/colorschemes/one-dark.micro
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ color-link todo "#8B98AB"
color-link type "#66D9EF"
color-link type.keyword "#C678DD"
color-link underlined "#8996A8"
color-link match-brace "#21252C,#C678DD"
2 changes: 2 additions & 0 deletions runtime/colorschemes/railscast.micro
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,5 @@ color-link space "underline #e6e1dc,#2b2b2b"

#the Python syntax definition are wrong. This is not how you should do decorators!
color-link brightgreen "#edb753,#2b2b2b"

color-link match-brace "#2b2b2b,#a5c261"
1 change: 1 addition & 0 deletions runtime/colorschemes/simple.micro
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ color-link type.extended "default"
color-link symbol.brackets "default"
#Color shebangs the comment color
color-link preproc.shebang "comment"
color-link match-brace ",magenta"
1 change: 1 addition & 0 deletions runtime/colorschemes/solarized-tc.micro
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ color-link cursor-line "#003541"
color-link color-column "#003541"
color-link type.extended "#839496,#002833"
color-link symbol.brackets "#839496,#002833"
color-link match-brace "#002833,#268BD2"
1 change: 1 addition & 0 deletions runtime/colorschemes/solarized.micro
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ color-link cursor-line "black"
color-link color-column "black"
color-link type.extended "default"
color-link symbol.brackets "default"
color-link match-brace ",blue"
1 change: 1 addition & 0 deletions runtime/colorschemes/sunny-day.micro
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ color-link gutter-warning "88"
color-link cursor-line "229"
#color-link color-column "196"
color-link current-line-number "246"
color-line match-brace "230,22"
1 change: 1 addition & 0 deletions runtime/colorschemes/twilight.micro
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ color-link todo "#8B98AB"
color-link type "#F9EE98"
color-link type.keyword "#CDA869"
color-link underlined "#8996A8"
color-link match-brace "#141414,#E0C589"
1 change: 1 addition & 0 deletions runtime/colorschemes/zenburn.micro
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ color-link gutter-warning "174,237"
color-link cursor-line "238"
color-link color-column "238"
color-link current-line-number "188,237"
color-link match-brace "237,223"
1 change: 1 addition & 0 deletions runtime/help/colors.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ Here is a list of the colorscheme groups that you can use:
* divider (Color of the divider between vertical splits)
* message (Color of messages in the bottom line of the screen)
* error-message (Color of error messages in the bottom line of the screen)
* match-brace (Color of matching brackets when `matchbracestyle` is set to `highlight`)

Colorschemes must be placed in the `~/.config/micro/colorschemes` directory to
be used.
Expand Down
Loading