Skip to content

Commit 7ee0e33

Browse files
committed
Optimize the experience
1 parent 7c617d3 commit 7ee0e33

File tree

20 files changed

+261
-98
lines changed

20 files changed

+261
-98
lines changed

.github/workflows/build.yml

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
push:
55
branches:
66
- master
7+
- ofzo
78
merge_group:
89
schedule:
910
- cron: "00 01 * * *"

.github/workflows/release.yml

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
- '[0-9]+.[0-9]+.[0-9]+'
77
branches:
88
- 'patch/ci-release-*'
9+
- 'ofzo'
910
pull_request:
1011
paths:
1112
- '.github/workflows/release.yml'

helix-term/src/commands/lsp.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -1050,9 +1050,12 @@ pub fn hover(cx: &mut Context) {
10501050
};
10511051

10521052
// skip if contents empty
1053+
if contents.is_empty() {
1054+
return
1055+
}
10531056

10541057
let contents = ui::Markdown::new(contents, editor.syn_loader.clone());
1055-
let popup = Popup::new("hover", contents).auto_close(true);
1058+
let popup = Popup::new("hover", contents).auto_close(true).position(editor.cursor().0);
10561059
compositor.replace_or_push("hover", popup);
10571060
}
10581061
},

helix-term/src/commands/typed.rs

+7
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,13 @@ fn buffer_close(
222222
}
223223

224224
let document_ids = buffer_gather_paths_impl(cx.editor, args);
225+
226+
if let Some(name) = cx.editor.documents.get(&document_ids[0]) {
227+
if name.display_name() == SCRATCH_BUFFER_NAME {
228+
return quit(cx, args, event);
229+
}
230+
}
231+
225232
buffer_close_by_ids_impl(cx, &document_ids, false)
226233
}
227234

helix-term/src/main.rs

+1
Original file line numberDiff line numberDiff line change
@@ -156,5 +156,6 @@ FLAGS:
156156

157157
let exit_code = app.run(&mut EventStream::new()).await?;
158158

159+
print!("\x1b[6 q");
159160
Ok(exit_code)
160161
}

helix-term/src/ui/completion.rs

+25-26
Original file line numberDiff line numberDiff line change
@@ -64,31 +64,31 @@ impl menu::Item for CompletionItem {
6464

6565
let kind = match self {
6666
CompletionItem::Lsp(LspCompletionItem { item, .. }) => match item.kind {
67-
Some(lsp::CompletionItemKind::TEXT) => "text",
68-
Some(lsp::CompletionItemKind::METHOD) => "method",
69-
Some(lsp::CompletionItemKind::FUNCTION) => "function",
70-
Some(lsp::CompletionItemKind::CONSTRUCTOR) => "constructor",
71-
Some(lsp::CompletionItemKind::FIELD) => "field",
72-
Some(lsp::CompletionItemKind::VARIABLE) => "variable",
73-
Some(lsp::CompletionItemKind::CLASS) => "class",
74-
Some(lsp::CompletionItemKind::INTERFACE) => "interface",
75-
Some(lsp::CompletionItemKind::MODULE) => "module",
76-
Some(lsp::CompletionItemKind::PROPERTY) => "property",
77-
Some(lsp::CompletionItemKind::UNIT) => "unit",
78-
Some(lsp::CompletionItemKind::VALUE) => "value",
79-
Some(lsp::CompletionItemKind::ENUM) => "enum",
80-
Some(lsp::CompletionItemKind::KEYWORD) => "keyword",
81-
Some(lsp::CompletionItemKind::SNIPPET) => "snippet",
82-
Some(lsp::CompletionItemKind::COLOR) => "color",
83-
Some(lsp::CompletionItemKind::FILE) => "file",
84-
Some(lsp::CompletionItemKind::REFERENCE) => "reference",
85-
Some(lsp::CompletionItemKind::FOLDER) => "folder",
86-
Some(lsp::CompletionItemKind::ENUM_MEMBER) => "enum_member",
87-
Some(lsp::CompletionItemKind::CONSTANT) => "constant",
88-
Some(lsp::CompletionItemKind::STRUCT) => "struct",
89-
Some(lsp::CompletionItemKind::EVENT) => "event",
90-
Some(lsp::CompletionItemKind::OPERATOR) => "operator",
91-
Some(lsp::CompletionItemKind::TYPE_PARAMETER) => "type_param",
67+
Some(lsp::CompletionItemKind::TEXT) => "󰉿",
68+
Some(lsp::CompletionItemKind::METHOD) => "󰆧",
69+
Some(lsp::CompletionItemKind::FUNCTION) => "󰊕",
70+
Some(lsp::CompletionItemKind::CONSTRUCTOR) => "",
71+
Some(lsp::CompletionItemKind::FIELD) => "󰜢",
72+
Some(lsp::CompletionItemKind::VARIABLE) => "󰀫",
73+
Some(lsp::CompletionItemKind::CLASS) => "󰠱",
74+
Some(lsp::CompletionItemKind::INTERFACE) => "",
75+
Some(lsp::CompletionItemKind::MODULE) => "",
76+
Some(lsp::CompletionItemKind::PROPERTY) => "󰜢",
77+
Some(lsp::CompletionItemKind::UNIT) => "󰑭",
78+
Some(lsp::CompletionItemKind::VALUE) => "󰎠",
79+
Some(lsp::CompletionItemKind::ENUM) => "",
80+
Some(lsp::CompletionItemKind::KEYWORD) => "󰌋",
81+
Some(lsp::CompletionItemKind::SNIPPET) => "",
82+
Some(lsp::CompletionItemKind::COLOR) => "󰏘",
83+
Some(lsp::CompletionItemKind::FILE) => "󰈙",
84+
Some(lsp::CompletionItemKind::REFERENCE) => "󰈇",
85+
Some(lsp::CompletionItemKind::FOLDER) => "󰉋",
86+
Some(lsp::CompletionItemKind::ENUM_MEMBER) => "",
87+
Some(lsp::CompletionItemKind::CONSTANT) => "󰏿",
88+
Some(lsp::CompletionItemKind::STRUCT) => "󰙅",
89+
Some(lsp::CompletionItemKind::EVENT) => "",
90+
Some(lsp::CompletionItemKind::OPERATOR) => "󰆕",
91+
Some(lsp::CompletionItemKind::TYPE_PARAMETER) => "",
9292
Some(kind) => {
9393
log::error!("Received unknown completion item kind: {:?}", kind);
9494
""
@@ -97,7 +97,6 @@ impl menu::Item for CompletionItem {
9797
},
9898
CompletionItem::Other(core::CompletionItem { kind, .. }) => kind,
9999
};
100-
101100
menu::Row::new([
102101
menu::Cell::from(Span::styled(
103102
label,

helix-term/src/ui/editor.rs

+53-18
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ impl EditorView {
100100
let mut decorations = DecorationManager::default();
101101

102102
if is_focused && config.cursorline {
103-
decorations.add_decoration(Self::cursorline(doc, view, theme));
103+
decorations.add_decoration(Self::cursorline(doc, view, theme, &editor.mode));
104104
}
105105

106106
if is_focused && config.cursorcolumn {
@@ -236,15 +236,17 @@ impl EditorView {
236236
Self::render_diagnostics(doc, view, inner, surface, theme);
237237
}
238238

239-
let statusline_area = view
240-
.area
241-
.clip_top(view.area.height.saturating_sub(1))
242-
.clip_bottom(config.commandline as u16); // -1 from bottom to remove commandline
239+
if editor.status_msg.is_none() {
240+
let statusline_area = view
241+
.area
242+
.clip_top(view.area.height.saturating_sub(1))
243+
.clip_bottom(config.commandline as u16); // -1 from bottom to remove commandline
243244

244-
let mut context =
245-
statusline::RenderContext::new(editor, doc, view, is_focused, &self.spinners);
245+
let mut context =
246+
statusline::RenderContext::new(editor, doc, view, is_focused, &self.spinners);
246247

247-
statusline::render(&mut context, statusline_area, surface);
248+
statusline::render(&mut context, statusline_area, surface);
249+
}
248250
}
249251

250252
pub fn render_rulers(
@@ -480,12 +482,35 @@ impl EditorView {
480482
let cursorkind = cursor_shape_config.from_mode(mode);
481483
let cursor_is_block = cursorkind == CursorKind::Block;
482484

483-
let selection_scope = theme
484-
.find_scope_index_exact("ui.selection")
485-
.expect("could not find `ui.selection` scope in the theme!");
486-
let primary_selection_scope = theme
487-
.find_scope_index_exact("ui.selection.primary")
488-
.unwrap_or(selection_scope);
485+
// let selection_scope = theme
486+
// .find_scope_index_exact("ui.selection")
487+
// .expect("could not find `ui.selection` scope in the theme!");
488+
489+
let selection_scope = match mode {
490+
Mode::Normal => theme.find_scope_index_exact("ui.selection.normal"),
491+
Mode::Select => theme.find_scope_index_exact("ui.selection.select"),
492+
Mode::Insert => theme.find_scope_index_exact("ui.selection.insert"),
493+
}
494+
.unwrap_or(
495+
theme
496+
.find_scope_index_exact("ui.selection")
497+
.expect("could not find `ui.selection` scope in the theme!"),
498+
);
499+
500+
// let primary_selection_scope = theme
501+
// .find_scope_index_exact("ui.selection.primary")
502+
// .unwrap_or(selection_scope);
503+
504+
let primary_selection_scope = match mode {
505+
Mode::Normal => theme.find_scope_index_exact("ui.selection.primary.normal"),
506+
Mode::Select => theme.find_scope_index_exact("ui.selection.primary.select"),
507+
Mode::Insert => theme.find_scope_index_exact("ui.selection.primary.insert"),
508+
}
509+
.unwrap_or(
510+
theme
511+
.find_scope_index_exact("ui.selection.primary")
512+
.expect("could not find `ui.selection.primary` scope in the theme!"),
513+
);
489514

490515
let base_cursor_scope = theme
491516
.find_scope_index_exact("ui.cursor")
@@ -795,7 +820,7 @@ impl EditorView {
795820
}
796821

797822
/// Apply the highlighting on the lines where a cursor is active
798-
pub fn cursorline(doc: &Document, view: &View, theme: &Theme) -> impl Decoration {
823+
pub fn cursorline(doc: &Document, view: &View, theme: &Theme, mode: &Mode) -> impl Decoration {
799824
let text = doc.text().slice(..);
800825
// TODO only highlight the visual line that contains the cursor instead of the full visual line
801826
let primary_line = doc.selection(view.id).primary().cursor_line(text);
@@ -812,7 +837,13 @@ impl EditorView {
812837
.map(|range| range.cursor_line(text))
813838
.collect();
814839

815-
let primary_style = theme.get("ui.cursorline.primary");
840+
let primary_style = match mode {
841+
Mode::Normal => theme.try_get("ui.cursorline.primary.normal"),
842+
Mode::Select => theme.try_get("ui.cursorline.primary.select"),
843+
Mode::Insert => theme.try_get("ui.cursorline.primary.insert"),
844+
}
845+
.unwrap_or(theme.get("ui.cursorline.primary"));
846+
816847
let secondary_style = theme.get("ui.cursorline.secondary");
817848
let viewport = view.area;
818849

@@ -1581,7 +1612,7 @@ impl Component for EditorView {
15811612
let mut status_msg_width = 0;
15821613

15831614
// commandline
1584-
let commandline_msg_pos = if config.commandline { 1 } else { 2 };
1615+
let commandline_msg_pos = 1; //if config.commandline { 1 } else { 1 };
15851616

15861617
// render status msg
15871618
if let Some((status_msg, severity)) = &cx.editor.status_msg {
@@ -1620,7 +1651,11 @@ impl Component for EditorView {
16201651
};
16211652
surface.set_string(
16221653
area.x + area.width.saturating_sub(key_width + macro_width),
1623-
area.y + area.height.saturating_sub(commandline_msg_pos),
1654+
area.y
1655+
+ area
1656+
.height
1657+
.saturating_sub(commandline_msg_pos)
1658+
.saturating_sub(1),
16241659
disp.get(disp.len().saturating_sub(key_width as usize)..)
16251660
.unwrap_or(&disp),
16261661
style,

helix-term/src/ui/lsp.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ impl Component for SignatureHelp {
142142
}
143143

144144
let sep_style = Style::default();
145-
let borders = BorderType::line_symbols(BorderType::Plain);
145+
let borders = BorderType::line_symbols(BorderType::Rounded);
146146
for x in sig_text_area.left()..sig_text_area.right() {
147147
if let Some(cell) = surface.get_mut(x, sig_text_area.bottom()) {
148148
cell.set_symbol(borders.horizontal).set_style(sep_style);

helix-term/src/ui/markdown.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,8 @@ impl Markdown {
314314
}
315315
}
316316
Event::Rule => {
317-
lines.push(Spans::from(Span::styled("---", code_style)));
318-
lines.push(Spans::default());
317+
lines.push(Spans::from(Span::styled("────────────", code_style)));
318+
// lines.push(Spans::default());
319319
}
320320
// TaskListMarker(bool) true if checked
321321
_ => {

helix-term/src/ui/menu.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -392,9 +392,9 @@ impl<T: Item + 'static> Component for Menu<T> {
392392

393393
let mut cell;
394394
for i in 0..win_height {
395-
cell = &mut surface[(area.right() - 1, area.top() + i as u16)];
395+
cell = &mut surface[(area.right(), area.top() + i as u16)];
396396

397-
let half_block = if render_borders { "▌" } else { "▐" };
397+
let half_block = "▋";
398398

399399
if scroll_line <= i && i < scroll_line + scroll_height {
400400
// Draw scroll thumb

helix-term/src/ui/picker.rs

+27-13
Original file line numberDiff line numberDiff line change
@@ -599,16 +599,22 @@ impl<T: 'static + Send + Sync, D: 'static + Send + Sync> Picker<T, D> {
599599
(size, _) if size > MAX_FILE_SIZE_FOR_PREVIEW => {
600600
CachedPreview::LargeFile
601601
}
602-
_ => Document::open(&path, None, None, editor.config.clone())
603-
.map(|doc| {
604-
// Asynchronously highlight the new document
605-
helix_event::send_blocking(
606-
&self.preview_highlight_handler,
607-
path.clone(),
608-
);
609-
CachedPreview::Document(Box::new(doc))
610-
})
611-
.unwrap_or(CachedPreview::NotFound),
602+
_ => Document::open(
603+
&path,
604+
None,
605+
None,
606+
editor.config.clone(),
607+
&editor.diff_providers,
608+
)
609+
.map(|doc| {
610+
// Asynchronously highlight the new document
611+
helix_event::send_blocking(
612+
&self.preview_highlight_handler,
613+
path.clone(),
614+
);
615+
CachedPreview::Document(Box::new(doc))
616+
})
617+
.unwrap_or(CachedPreview::NotFound),
612618
},
613619
)
614620
.unwrap_or(CachedPreview::NotFound);
@@ -673,12 +679,20 @@ impl<T: 'static + Send + Sync, D: 'static + Send + Sync> Picker<T, D> {
673679

674680
// -- Separator
675681
let sep_style = cx.editor.theme.get("ui.background.separator");
676-
let borders = BorderType::line_symbols(BorderType::Plain);
682+
let header_style = cx.editor.theme.get("ui.picker.header");
683+
let borders = BorderType::line_symbols(BorderType::Rounded);
677684
for x in inner.left()..inner.right() {
678685
if let Some(cell) = surface.get_mut(x, inner.y + 1) {
679686
cell.set_symbol(borders.horizontal).set_style(sep_style);
680687
}
681688
}
689+
if self.columns.len() > 1 {
690+
for x in inner.left()..inner.right() {
691+
if let Some(cell) = surface.get_mut(x, inner.y + 2) {
692+
cell.set_symbol(" ").set_style(header_style);
693+
}
694+
}
695+
}
682696

683697
// -- Render the contents:
684698
// subtract area of prompt from top
@@ -776,7 +790,7 @@ impl<T: 'static + Send + Sync, D: 'static + Send + Sync> Picker<T, D> {
776790
let mut table = Table::new(options)
777791
.style(text_style)
778792
.highlight_style(selected)
779-
.highlight_symbol(" > ")
793+
.highlight_symbol(" ")
780794
.column_spacing(1)
781795
.widths(&self.widths);
782796

@@ -945,7 +959,7 @@ impl<I: 'static + Send + Sync, D: 'static + Send + Sync> Component for Picker<I,
945959
self.show_preview && self.file_fn.is_some() && area.width > MIN_AREA_WIDTH_FOR_PREVIEW;
946960

947961
let picker_width = if render_preview {
948-
area.width / 2
962+
area.width / 3
949963
} else {
950964
area.width
951965
};

helix-term/src/ui/popup.rs

+14-11
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,18 @@ impl<T: Component> Popup<T> {
124124
}
125125

126126
fn render_info(&mut self, viewport: Rect, editor: &Editor) -> RenderInfo {
127-
let mut position = editor.cursor().0.unwrap_or_default();
128-
if let Some(old_position) = self
127+
let position = self
129128
.position
130-
.filter(|old_position| old_position.row == position.row)
131-
{
132-
position = old_position;
133-
} else {
134-
self.position = Some(position);
135-
}
129+
.or_else(|| editor.cursor().0)
130+
.unwrap_or_default();
131+
// if let Some(old_position) = self
132+
// .position
133+
// .filter(|old_position| old_position.row == position.row)
134+
// {
135+
// position = old_position;
136+
// } else {
137+
// self.position = Some(position);
138+
// }
136139

137140
let is_menu = self
138141
.contents
@@ -349,12 +352,12 @@ impl<T: Component> Component for Popup<T> {
349352
let scroll_line = (win_height - scroll_height) * scroll
350353
/ std::cmp::max(1, len.saturating_sub(win_height));
351354

352-
let mut cell;
355+
// let mut cell;
353356
for i in 0..win_height {
354-
cell =
357+
let cell =
355358
&mut surface[(inner.right() - 1 + border as u16, inner.top() + i as u16)];
356359

357-
let half_block = if render_borders { "▌" } else { "▐" };
360+
let half_block = "▋";
358361

359362
if scroll_line <= i && i < scroll_line + scroll_height {
360363
// Draw scroll thumb

0 commit comments

Comments
 (0)