Merge remote-tracking branch 'fabian1409/feat/border_type'

This commit is contained in:
Kalle Carlbark 2025-04-01 22:41:11 +02:00
commit 7db2913019
9 changed files with 183 additions and 15 deletions
book/src
helix-term/src/ui
helix-tui/src/widgets
helix-view/src
runtime/themes

View file

@ -57,6 +57,7 @@
| `trim-final-newlines` | Whether to automatically remove line-endings after the final one on write | `false` |
| `trim-trailing-whitespace` | Whether to automatically remove whitespace preceding line endings on write | `false` |
| `popup-border` | Draw border around `popup`, `menu`, `all`, or `none` | `none` |
| `rounded-corners` | Set to `true` to draw rounded border corners | `false` |
| `indent-heuristic` | How the indentation for a newly inserted line is computed: `simple` just copies the indentation level from the previous line, `tree-sitter` computes the indentation based on the syntax tree and `hybrid` combines both approaches. If the chosen heuristic is not available, a different one will be used as a fallback (the fallback order being `hybrid` -> `tree-sitter` -> `simple`). | `hybrid`
| `jump-label-alphabet` | The characters that are used to generate two character jump labels. Characters at the start of the alphabet are used first. | `"abcdefghijklmnopqrstuvwxyz"`
| `end-of-line-diagnostics` | Minimum severity of diagnostics to render at the end of the line. Set to `disable` to disable entirely. Refer to the setting about `inline-diagnostics` for more details | "disable"

View file

@ -21,8 +21,11 @@ use nucleo::{
pattern::{Atom, AtomKind, CaseMatching, Normalization},
Config, Utf32Str,
};
use tui::text::Spans;
use tui::{buffer::Buffer as Surface, text::Span};
use tui::{
buffer::Buffer as Surface,
text::{Span, Spans},
widgets::BorderType,
};
use std::cmp::Reverse;
@ -585,7 +588,12 @@ impl Component for Completion {
if cx.editor.popup_border() {
use tui::widgets::{Block, Widget};
Widget::render(Block::bordered(), doc_area, surface);
let border_type = BorderType::new(cx.editor.config().rounded_corners);
Widget::render(
Block::bordered().border_type(border_type),
doc_area,
surface,
);
}
markdown_doc.render(doc_area, surface, cx);

View file

@ -3,7 +3,7 @@ use helix_view::graphics::{Margin, Rect};
use helix_view::info::Info;
use tui::buffer::Buffer as Surface;
use tui::text::Text;
use tui::widgets::{Block, Paragraph, Widget};
use tui::widgets::{Block, BorderType, Paragraph, Widget};
impl Component for Info {
fn render(&mut self, viewport: Rect, surface: &mut Surface, cx: &mut Context) {
@ -23,9 +23,11 @@ impl Component for Info {
));
surface.clear_with(area, popup_style);
let border_type = BorderType::new(cx.editor.config().rounded_corners);
let block = Block::bordered()
.title(self.title.as_ref())
.border_style(popup_style);
.border_style(popup_style)
.border_type(border_type);
let margin = Margin::horizontal(1);
let inner = block.inner(area).inner(margin);

View file

@ -674,12 +674,13 @@ impl<T: 'static + Send + Sync, D: 'static + Send + Sync> Picker<T, D> {
let background = cx.editor.theme.get("ui.background");
surface.clear_with(area, background);
const BLOCK: Block<'_> = Block::bordered();
let border_type = BorderType::new(cx.editor.config().rounded_corners);
let block: Block<'_> = Block::bordered().border_type(border_type);
// calculate the inner area inside the box
let inner = BLOCK.inner(area);
let inner = block.inner(area);
BLOCK.render(area, surface);
block.render(area, surface);
// -- Render the input bar:
@ -863,14 +864,15 @@ impl<T: 'static + Send + Sync, D: 'static + Send + Sync> Picker<T, D> {
let directory = cx.editor.theme.get("ui.text.directory");
surface.clear_with(area, background);
const BLOCK: Block<'_> = Block::bordered();
let border_type = BorderType::new(cx.editor.config().rounded_corners);
let block: Block<'_> = Block::bordered().border_type(border_type);
// calculate the inner area inside the box
let inner = BLOCK.inner(area);
let inner = block.inner(area);
// 1 column gap on either side
let margin = Margin::horizontal(1);
let inner = inner.inner(margin);
BLOCK.render(area, surface);
block.render(area, surface);
if let Some((preview, range)) = self.get_preview(cx.editor) {
let doc = match preview.document() {

View file

@ -5,7 +5,7 @@ use crate::{
};
use tui::{
buffer::Buffer as Surface,
widgets::{Block, Widget},
widgets::{Block, BorderType, Widget},
};
use helix_core::Position;
@ -323,8 +323,9 @@ impl<T: Component> Component for Popup<T> {
let mut inner = area;
if render_borders {
let border_type = BorderType::new(cx.editor.config().rounded_corners);
inner = area.inner(Margin::all(1));
Widget::render(Block::bordered(), area, surface);
Widget::render(Block::bordered().border_type(border_type), area, surface);
}
let border = usize::from(render_borders);

View file

@ -9,7 +9,7 @@ use std::sync::Arc;
use std::{borrow::Cow, ops::RangeFrom};
use tui::buffer::Buffer as Surface;
use tui::text::Span;
use tui::widgets::{Block, Widget};
use tui::widgets::{Block, BorderType, Widget};
use helix_core::{
unicode::segmentation::GraphemeCursor, unicode::width::UnicodeWidthStr, Position,
@ -494,9 +494,11 @@ impl Prompt {
let background = theme.get("ui.help");
surface.clear_with(area, background);
let border_type = BorderType::new(cx.editor.config().rounded_corners);
let block = Block::bordered()
// .title(self.title.as_str())
.border_style(background);
.border_style(background)
.border_type(border_type);
let inner = block.inner(area).inner(Margin::horizontal(1));

View file

@ -17,6 +17,14 @@ pub enum BorderType {
}
impl BorderType {
pub fn new(rounded: bool) -> Self {
if rounded {
Self::Rounded
} else {
Self::default()
}
}
pub fn line_symbols(border_type: Self) -> line::Set {
match border_type {
Self::Plain => line::NORMAL,

View file

@ -398,6 +398,8 @@ pub struct Config {
pub smart_tab: Option<SmartTabConfig>,
/// Draw border around popups.
pub popup_border: PopupBorderConfig,
/// Draw rounded border corners
pub rounded_corners: bool,
/// Which indent heuristic to use when a new line is inserted
#[serde(default)]
pub indent_heuristic: IndentationHeuristic,
@ -1061,6 +1063,7 @@ impl Default for Config {
trim_trailing_whitespace: false,
smart_tab: Some(SmartTabConfig::default()),
popup_border: PopupBorderConfig::None,
rounded_corners: false,
indent_heuristic: IndentationHeuristic::default(),
jump_label_alphabet: ('a'..='z').collect(),
inline_diagnostics: InlineDiagnosticsConfig::default(),

141
runtime/themes/nordic.toml Normal file
View file

@ -0,0 +1,141 @@
# Nordic theme for Helix
# From https://github.com/5-pebbles/nordic-helix
# Author : Owen Friedman <5-pebble@protonmail.com>
# License: MIT License
# Syntax Highlighting
"attribute" = { fg = "yellow_base" }
"type" = { fg = "yellow_bright" }
"type.enum.variant" = { fg = "cyan_bright" }
"constructor" = { fg = "cyan_bright" }
"constant" = { fg = "magenta_bright" }
"constant.character" = { fg = "green_base" }
"constant.character.escape" = { fg = "magenta_bright" }
"string" = { fg = "green_base" }
"string.regex" = { fg = "magenta_bright" }
"comment" = { fg = "gray4", modifiers = ["italic"] }
"variable" = { fg = "white0" }
"variable.builtin" = { fg = "blue0" }
"variable.other.member" = { fg = "cyan_bright" }
"label" = { fg = "orange_base", modifiers = ["bold"] }
"punctuation.delimiter" = { fg = "gray5", modifiers = ["italic"] }
"punctuation.special" = { fg = "orange_base" }
"keyword" = { fg = "orange_base" }
"operator" = { fg = "white0" }
"function" = { fg = "blue2" }
"function.macro" = { fg = "red_base" }
"tag" = { fg = "blue1" }
"namespace" = { fg = "yellow_dim" }
"special" = { fg = "orange_base" } # fuzzy highlight (picker)
# Markup Formatting
"markup.heading.1" = { fg = "yellow_base", modifiers = ["bold"] }
"markup.heading.2" = { fg = "orange_base", modifiers = ["bold"] }
"markup.heading.3" = { fg = "magenta_base", modifiers = ["bold"] }
"markup.heading.4" = { fg = "green_base" }
"markup.heading.5" = { fg = "blue2", modifiers = ["italic"] }
"markup.heading.6" = { fg = "cyan_base", modifiers = ["italic"] }
"markup.bold" = { modifiers = ["bold"] }
"markup.italic" = { modifiers = ["italic"] }
"markup.list" = { fg = "orange_base" }
"markup.link" = { fg = "blue1", "underline.style" = "line" }
"markup.quote" = { fg = "gray4", modifiers = ["italic"] }
# Diffs
"diff.plus" = { fg = "green_base" }
"diff.minus" = { fg = "red_base" }
"diff.delta" = { fg = "blue1" }
# UI
"ui.background" = { fg = "white0", bg = "black2" }
"ui.cursor" = { fg = "black1", bg = "gray4" }
"ui.cursor.primary" = { fg = "black1", bg = "white0" }
"ui.cursor.match" = { modifiers = ["bold"] }
"ui.linenr" = { fg = "gray2" }
"ui.linenr.selected" = { fg = "gray4" }
"ui.statusline" = { fg = "white0", bg = "black0" }
"ui.statusline.inactive" = { fg = "gray4", bg = "black0" }
"ui.popup" = { bg = "black1" }
"ui.window" = { fg = "gray4" }
"ui.help" = { bg = "black1" }
"ui.text.focus" = { bg = "gray2" }
"ui.virtual.ruler" = { bg = "gray1" }
"ui.menu" = { bg = "black1" }
"ui.menu.selected" = { bg = "gray4" }
"ui.menu.scroll" = { fg = "gray4", bg = "gray0" } # fg sets thumb color, bg sets track color of scrollbar
"ui.selection" = { bg = "gray2" }
"ui.cursorline.primary" = { bg = "gray1" }
# Diagnostic Messages
"error" = { fg = "red_base" }
"warning" = { fg = "yellow_base" }
"info" = { fg = "blue1" }
"hint" = { fg = "green_base" }
"diagnostic.error" = { underline = { color = "red_base", style = "curl" } }
"diagnostic.warning" = { underline = { color = "yellow_base", style = "curl" } }
"diagnostic.info" = { underline = { color = "blue1", style = "curl" } }
"diagnostic.hint" = { underline = { color = "green_base", style = "curl" } }
# Color Palette
[palette]
# Black
black0 = "#191D24"
black1 = "#1E222A"
black2 = "#222630"
# Gray
gray0 = "#242933"
# Polar night
gray1 = "#2E3440"
gray2 = "#3B4252"
gray3 = "#434C5E"
gray4 = "#4C566A"
# a light blue/gray
# from @nightfox.nvim
gray5 = "#60728A"
# White
# reduce_blue variant
white0 = "#C0C8D8"
# Snow storm
white1 = "#D8DEE9"
white2 = "#E5E9F0"
white3 = "#ECEFF4"
# Blue
# Frost
blue0 = "#5E81AC"
blue1 = "#81A1C1"
blue2 = "#88C0D0"
# Cyan:
cyan_base = "#8FBCBB"
cyan_bright = "#9FC6C5"
cyan_dim = "#80B3B2"
# Aurora (from Nord theme)
# Red
red_base = "#BF616A"
red_bright = "#C5727A"
red_dim = "#B74E58"
# Orange
orange_base = "#D08770"
orange_bright = "#D79784"
orange_dim = "#CB775D"
# Yellow
yellow_base = "#EBCB8B"
yellow_bright = "#EFD49F"
yellow_dim = "#E7C173"
# Green
green_base = "#A3BE8C"
green_bright = "#B1C89D"
green_dim = "#97B67C"
# Magenta
magenta_base = "#B48EAD"
magenta_bright = "#BE9DB8"
magenta_dim = "#A97EA1"