Skip to content

Commit d17758b

Browse files
committedMar 23, 2022
Adding a marker/color for staged/typechanged files. Adding a match arm for these Statuses in the Git status module. Updating the preview module to include these settings
1 parent 4381663 commit d17758b

File tree

5 files changed

+64
-0
lines changed

5 files changed

+64
-0
lines changed
 

‎nomad.toml

+4
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,14 @@
100100
#deleted_marker = "D"
101101
#modified_marker = "M"
102102
#renamed_marker = "R"
103+
#typechanged_marker = "TC"
103104
#untracked_marker = "U"
104105

105106
#staged_added_marker = "SA"
106107
#staged_deleted_marker = "SD"
107108
#staged_modified_marker = "SM"
108109
#staged_renamed_marker = "SR"
110+
#staged_typechanged_marker = "STC"
109111

110112

111113
#
@@ -127,12 +129,14 @@
127129
#deleted_color = "red"
128130
#modified_color = "d78700" # A shade of orange.
129131
#renamed_color = "red"
132+
#typechanged_color = "purple"
130133
#untracked_color = "767676" # A shade of gray.
131134

132135
#staged_added_color = "green"
133136
#staged_deleted_color = "red"
134137
#staged_modified_color = "d78700" # A shade of orange.
135138
#staged_renamed_color = "red"
139+
#staged_typechanged_color = "purple"
136140

137141

138142
#

‎src/config/models.rs

+8
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ pub struct Markers {
130130
pub staged_modified_marker: Option<String>,
131131
/// The string that marks a staged renamed file.
132132
pub staged_renamed_marker: Option<String>,
133+
/// The string that marks a staged typechanged file.
134+
pub staged_typechanged_marker: Option<String>,
135+
/// The string that marks a typechanged file.
136+
pub typechanged_marker: Option<String>,
133137
/// The string that marks an untracked file.
134138
pub untracked_marker: Option<String>,
135139
}
@@ -153,6 +157,10 @@ pub struct Colors {
153157
pub staged_modified_color: Option<String>,
154158
/// The color associated with staged renamed files.
155159
pub staged_renamed_color: Option<String>,
160+
/// The color associated with staged typechanged files.
161+
pub staged_typechanged_color: Option<String>,
162+
/// The color associated with typechanged files.
163+
pub typechanged_marker: Option<String>,
156164
/// The color associated with untracked files.
157165
pub untracked_color: Option<String>,
158166
}

‎src/config/preview.rs

+18
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ pub fn display_preview_tree(nomad_style: &NomadStyle) -> Result<(), NomadError>
5757
.renamed_color
5858
.paint(nomad_style.git.renamed_marker.to_string())
5959
));
60+
tree.add_empty_child(format!(
61+
"{} \u{f17a} typechanged file", // ""
62+
nomad_style
63+
.git
64+
.typechanged_color
65+
.paint(nomad_style.git.typechanged_marker.to_string())
66+
));
6067

6168
// Staged (index) Git changes.
6269
tree.add_empty_child(format!(
@@ -104,6 +111,17 @@ pub fn display_preview_tree(nomad_style: &NomadStyle) -> Result<(), NomadError>
104111
.staged_renamed_color
105112
.paint("staged renamed file")
106113
));
114+
tree.add_empty_child(format!(
115+
"{} \u{f17a} {}", // ""
116+
nomad_style
117+
.git
118+
.staged_typechanged_color
119+
.paint(nomad_style.git.staged_typechanged_marker.to_string()),
120+
nomad_style
121+
.git
122+
.staged_typechanged_color
123+
.paint("staged typechanged file")
124+
));
107125

108126
// Last working directory Git change.
109127
tree.add_empty_child(format!(

‎src/git/markers.rs

+22
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,17 @@ pub fn get_status_markers(
9292
.to_string()
9393
}
9494
}
95+
s if s.contains(Status::INDEX_TYPECHANGE) => {
96+
if args.no_colors {
97+
nomad_style.git.staged_typechanged_marker.clone()
98+
} else {
99+
nomad_style
100+
.git
101+
.staged_typechanged_color
102+
.paint(&nomad_style.git.staged_typechanged_marker)
103+
.to_string()
104+
}
105+
}
95106
s if s.contains(Status::WT_DELETED) => {
96107
if args.no_colors {
97108
nomad_style.git.deleted_marker.clone()
@@ -136,6 +147,17 @@ pub fn get_status_markers(
136147
.to_string()
137148
}
138149
}
150+
s if s.contains(Status::WT_TYPECHANGE) => {
151+
if args.no_colors {
152+
nomad_style.git.typechanged_marker.clone()
153+
} else {
154+
nomad_style
155+
.git
156+
.typechanged_color
157+
.paint(&nomad_style.git.typechanged_marker)
158+
.to_string()
159+
}
160+
}
139161
s if s.contains(Status::CONFLICTED) => {
140162
if args.no_colors {
141163
nomad_style.git.conflicted_marker.clone()

‎src/style/models.rs

+12
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,14 @@ pub struct GitStyle {
5050
pub staged_renamed_color: Style,
5151
/// The string that marks a staged renamed file.
5252
pub staged_renamed_marker: String,
53+
/// The color that marks a staged typechanged file.
54+
pub staged_typechanged_color: Style,
55+
/// The string that marks a staged typechanged file.
56+
pub staged_typechanged_marker: String,
57+
/// The color that marks a typechanged file.
58+
pub typechanged_color: Style,
59+
/// The string that marks a typechanged file.
60+
pub typechanged_marker: String,
5361
/// The color of the untracked file's marker.
5462
pub untracked_color: Style,
5563
/// The string that marks an untracked file.
@@ -175,6 +183,10 @@ impl Default for NomadStyle {
175183
staged_modified_marker: "SM".to_string(),
176184
staged_renamed_color: Colour::Fixed(172).bold(),
177185
staged_renamed_marker: "SR".to_string(),
186+
staged_typechanged_color: Colour::Purple.bold(),
187+
staged_typechanged_marker: "STC".to_string(),
188+
typechanged_color: Colour::Purple.bold(),
189+
typechanged_marker: "TC".to_string(),
178190
untracked_color: Colour::Fixed(243).bold(),
179191
untracked_marker: "U".to_string(),
180192
},

0 commit comments

Comments
 (0)
Please sign in to comment.