|
11 | 11 | -- highlight: The highlight group to apply to this text. |
12 | 12 |
|
13 | 13 | local highlights = require("neo-tree.ui.highlights") |
| 14 | +local utils = require("neo-tree.utils") |
14 | 15 |
|
15 | 16 | local M = {} |
16 | 17 |
|
@@ -86,25 +87,72 @@ M.git_status = function(config, node, state) |
86 | 87 | end |
87 | 88 | end |
88 | 89 |
|
| 90 | + local symbols = config.symbols or {} |
| 91 | + local status |
89 | 92 | local highlight = highlights.FILE_NAME |
| 93 | + local staged = symbols.unstaged |
| 94 | + local staged_hl = highlights.GIT_CONFLICT |
| 95 | + |
| 96 | + if git_status:sub(2, 2) == " " then |
| 97 | + staged = symbols.staged |
| 98 | + staged_hl = highlights.GIT_ADDED |
| 99 | + end |
| 100 | + |
90 | 101 | if git_status:match("?$") then |
| 102 | + staged = nil |
| 103 | + status = symbols.untracked |
| 104 | + staged_hl = highlights.GIT_UNTRACKED |
91 | 105 | highlight = highlights.GIT_UNTRACKED |
92 | | - elseif git_status:match("U") then |
| 106 | + elseif git_status == "UU" then |
| 107 | + staged = symbols.unmerged |
| 108 | + staged_hl = highlights.GIT_UNMERGED |
| 109 | + status = symbols.conflict |
93 | 110 | highlight = highlights.GIT_CONFLICT |
94 | 111 | elseif git_status == "AA" then |
| 112 | + staged = symbols.unmerged |
| 113 | + staged_hl = highlights.GIT_UNMERGED |
| 114 | + status = symbols.conflict |
| 115 | + highlight = highlights.GIT_CONFLICT |
| 116 | + elseif git_status:match("U") then |
| 117 | + staged = symbols.unmerged |
| 118 | + staged_hl = highlights.GIT_UNMERGED |
| 119 | + status = symbols.conflict |
95 | 120 | highlight = highlights.GIT_CONFLICT |
96 | 121 | elseif git_status:match("M") then |
| 122 | + status = symbols.modified |
97 | 123 | highlight = highlights.GIT_MODIFIED |
98 | | - elseif git_status:match("[ACRT]") then |
| 124 | + elseif git_status:match("R") then |
| 125 | + status = symbols.renamed |
| 126 | + highlight = highlights.modified |
| 127 | + elseif git_status:match("[ACT]") then |
| 128 | + status = symbols.added |
99 | 129 | highlight = highlights.GIT_ADDED |
100 | 130 | elseif git_status:match("!") then |
| 131 | + staged = nil |
| 132 | + status = symbols.ignored |
101 | 133 | highlight = highlights.GIT_IGNORED |
102 | 134 | end |
103 | 135 |
|
104 | | - return { |
105 | | - text = " [" .. git_status .. "]", |
106 | | - highlight = config.highlight or highlight, |
107 | | - } |
| 136 | + if status then |
| 137 | + local components = {} |
| 138 | + components[1] = { |
| 139 | + text = " " .. status, |
| 140 | + highlight = highlight, |
| 141 | + } |
| 142 | + if staged then |
| 143 | + components[2] = { |
| 144 | + text = " " .. staged, |
| 145 | + highlight = staged_hl, |
| 146 | + } |
| 147 | + end |
| 148 | + return components |
| 149 | + else |
| 150 | + return { |
| 151 | + text = " [" .. git_status .. "]", |
| 152 | + highlight = config.highlight or highlight, |
| 153 | + } |
| 154 | + end |
| 155 | + |
108 | 156 | end |
109 | 157 |
|
110 | 158 | M.filtered_by = function(config, node, state) |
|
0 commit comments