on master help sign in
Add undercurl config option #6196 (#6253)
d479adfJonatan Pettersson
book/src/configuration.md+1
@@ -53,6 +53,7 @@ signal to the Helix process on Unix operating systems, such as by using the comm
53| `completion-replace` | Set to `true` to make completions always replace the entire word and not just the part before the cursor | `false` |
53| `completion-replace` | Set to `true` to make completions always replace the entire word and not just the part before the cursor | `false` |
54| `auto-info` | Whether to display info boxes | `true` |
54| `auto-info` | Whether to display info boxes | `true` |
55| `true-color` | Set to `true` to override automatic detection of terminal truecolor support in the event of a false negative | `false` |
55| `true-color` | Set to `true` to override automatic detection of terminal truecolor support in the event of a false negative | `false` |
56+| `undercurl` | Set to `true` to override automatic detection of terminal undercurl support in the event of a false negative | `false` |
56| `rulers` | List of column positions at which to display the rulers. Can be overridden by language specific `rulers` in `languages.toml` file | `[]` |
57| `rulers` | List of column positions at which to display the rulers. Can be overridden by language specific `rulers` in `languages.toml` file | `[]` |
57| `bufferline` | Renders a line at the top of the editor displaying open buffers. Can be `always`, `never` or `multiple` (only shown if more than one buffer is in use) | `never` |
58| `bufferline` | Renders a line at the top of the editor displaying open buffers. Can be `always`, `never` or `multiple` (only shown if more than one buffer is in use) | `never` |
58| `color-modes` | Whether to color the mode indicator with different colors depending on the mode itself | `false` |
59| `color-modes` | Whether to color the mode indicator with different colors depending on the mode itself | `false` |
helix-term/src/application.rs+1−1
@@ -134,7 +134,7 @@ impl Application {
134 let syn_loader = std::sync::Arc::new(syntax::Loader::new(syn_loader_conf));
134 let syn_loader = std::sync::Arc::new(syntax::Loader::new(syn_loader_conf));
135
135
136 #[cfg(not(feature = "integration"))]
136 #[cfg(not(feature = "integration"))]
137− let backend = CrosstermBackend::new(stdout());
137+ let backend = CrosstermBackend::new(stdout(), &config.editor);
138
138
139 #[cfg(feature = "integration")]
139 #[cfg(feature = "integration")]
140 let backend = TestBackend::new(120, 150);
140 let backend = TestBackend::new(120, 150);
helix-tui/src/backend/crossterm.rs+9−5
@@ -14,7 +14,10 @@ use crossterm::{
14 terminal::{self, Clear, ClearType},
14 terminal::{self, Clear, ClearType},
15 Command,
15 Command,
16};
16};
17+use helix_view::{
18+ editor::Config as EditorConfig,
17−use helix_view::graphics::{Color, CursorKind, Modifier, Rect, UnderlineStyle};
19+ graphics::{Color, CursorKind, Modifier, Rect, UnderlineStyle},
20+};
18use once_cell::sync::OnceCell;
21use once_cell::sync::OnceCell;
19use std::{
22use std::{
20 fmt,
23 fmt,
@@ -39,14 +42,15 @@ impl Capabilities {
39 /// Detect capabilities from the terminfo database located based
42 /// Detect capabilities from the terminfo database located based
40 /// on the $TERM environment variable. If detection fails, returns
43 /// on the $TERM environment variable. If detection fails, returns
41 /// a default value where no capability is supported.
44 /// a default value where no capability is supported.
42− pub fn from_env_or_default() -> Self {
45+ pub fn from_env_or_default(config: &EditorConfig) -> Self {
43 match termini::TermInfo::from_env() {
46 match termini::TermInfo::from_env() {
44 Err(_) => Capabilities::default(),
47 Err(_) => Capabilities::default(),
45 Ok(t) => Capabilities {
48 Ok(t) => Capabilities {
46 // Smulx, VTE: https://unix.stackexchange.com/a/696253/246284
49 // Smulx, VTE: https://unix.stackexchange.com/a/696253/246284
47 // Su (used by kitty): https://sw.kovidgoyal.net/kitty/underlines
50 // Su (used by kitty): https://sw.kovidgoyal.net/kitty/underlines
48 // WezTerm supports underlines but a lot of distros don't properly install it's terminfo
51 // WezTerm supports underlines but a lot of distros don't properly install it's terminfo
52+ has_extended_underlines: config.undercurl
49− has_extended_underlines: t.extended_cap("Smulx").is_some()
53+ || t.extended_cap("Smulx").is_some()
50 || t.extended_cap("Su").is_some()
54 || t.extended_cap("Su").is_some()
51 || vte_version() >= Some(5102)
55 || vte_version() >= Some(5102)
52 || matches!(term_program().as_deref(), Some("WezTerm")),
56 || matches!(term_program().as_deref(), Some("WezTerm")),
@@ -65,10 +69,10 @@ impl<W> CrosstermBackend<W>
65where
69where
66 W: Write,
70 W: Write,
67{
71{
68− pub fn new(buffer: W) -> CrosstermBackend<W> {
72+ pub fn new(buffer: W, config: &EditorConfig) -> CrosstermBackend<W> {
69 CrosstermBackend {
73 CrosstermBackend {
70 buffer,
74 buffer,
71− capabilities: Capabilities::from_env_or_default(),
75+ capabilities: Capabilities::from_env_or_default(config),
72 supports_keyboard_enhancement_protocol: OnceCell::new(),
76 supports_keyboard_enhancement_protocol: OnceCell::new(),
73 }
77 }
74 }
78 }
helix-tui/src/lib.rs+9−3
@@ -25,10 +25,12 @@
25//! use std::io;
25//! use std::io;
26//! use helix_tui::Terminal;
26//! use helix_tui::Terminal;
27//! use helix_tui::backend::CrosstermBackend;
27//! use helix_tui::backend::CrosstermBackend;
28+//! use helix_view::editor::Config;
28//!
29//!
29//! fn main() -> Result<(), io::Error> {
30//! fn main() -> Result<(), io::Error> {
30//! let stdout = io::stdout();
31//! let stdout = io::stdout();
32+//! let config = Config::default();
31−//! let backend = CrosstermBackend::new(stdout);
33+//! let backend = CrosstermBackend::new(stdout, &config);
32//! let mut terminal = Terminal::new(backend)?;
34//! let mut terminal = Terminal::new(backend)?;
33//! Ok(())
35//! Ok(())
34//! }
36//! }
@@ -56,11 +58,13 @@
56//! use helix_tui::backend::CrosstermBackend;
58//! use helix_tui::backend::CrosstermBackend;
57//! use helix_tui::widgets::{Widget, Block, Borders};
59//! use helix_tui::widgets::{Widget, Block, Borders};
58//! use helix_tui::layout::{Layout, Constraint, Direction};
60//! use helix_tui::layout::{Layout, Constraint, Direction};
61+//! use helix_view::editor::Config;
59//!
62//!
60//! fn main() -> Result<(), io::Error> {
63//! fn main() -> Result<(), io::Error> {
61//! terminal::enable_raw_mode().unwrap();
64//! terminal::enable_raw_mode().unwrap();
62//! let stdout = io::stdout();
65//! let stdout = io::stdout();
66+//! let config = Config::default();
63−//! let backend = CrosstermBackend::new(stdout);
67+//! let backend = CrosstermBackend::new(stdout, &config);
64//! let mut terminal = Terminal::new(backend)?;
68//! let mut terminal = Terminal::new(backend)?;
65//! // terminal.draw(|f| {
69//! // terminal.draw(|f| {
66//! // let size = f.size();
70//! // let size = f.size();
@@ -86,11 +90,13 @@
86//! use helix_tui::backend::CrosstermBackend;
90//! use helix_tui::backend::CrosstermBackend;
87//! use helix_tui::widgets::{Widget, Block, Borders};
91//! use helix_tui::widgets::{Widget, Block, Borders};
88//! use helix_tui::layout::{Layout, Constraint, Direction};
92//! use helix_tui::layout::{Layout, Constraint, Direction};
93+//! use helix_view::editor::Config;
89//!
94//!
90//! fn main() -> Result<(), io::Error> {
95//! fn main() -> Result<(), io::Error> {
91//! terminal::enable_raw_mode().unwrap();
96//! terminal::enable_raw_mode().unwrap();
92//! let stdout = io::stdout();
97//! let stdout = io::stdout();
98+//! let config = Config::default();
93−//! let backend = CrosstermBackend::new(stdout);
99+//! let backend = CrosstermBackend::new(stdout, &config);
94//! let mut terminal = Terminal::new(backend)?;
100//! let mut terminal = Terminal::new(backend)?;
95//! // terminal.draw(|f| {
101//! // terminal.draw(|f| {
96//! // let chunks = Layout::default()
102//! // let chunks = Layout::default()
helix-view/src/editor.rs+3
@@ -263,6 +263,8 @@ pub struct Config {
263 pub cursor_shape: CursorShapeConfig,
263 pub cursor_shape: CursorShapeConfig,
264 /// Set to `true` to override automatic detection of terminal truecolor support in the event of a false negative. Defaults to `false`.
264 /// Set to `true` to override automatic detection of terminal truecolor support in the event of a false negative. Defaults to `false`.
265 pub true_color: bool,
265 pub true_color: bool,
266+ /// Set to `true` to override automatic detection of terminal undercurl support in the event of a false negative. Defaults to `false`.
267+ pub undercurl: bool,
266 /// Search configuration.
268 /// Search configuration.
267 #[serde(default)]
269 #[serde(default)]
268 pub search: SearchConfig,
270 pub search: SearchConfig,
@@ -737,6 +739,7 @@ impl Default for Config {
737 statusline: StatusLineConfig::default(),
739 statusline: StatusLineConfig::default(),
738 cursor_shape: CursorShapeConfig::default(),
740 cursor_shape: CursorShapeConfig::default(),
739 true_color: false,
741 true_color: false,
742+ undercurl: false,
740 search: SearchConfig::default(),
743 search: SearchConfig::default(),
741 lsp: LspConfig::default(),
744 lsp: LspConfig::default(),
742 terminal: get_terminal_provider(),
745 terminal: get_terminal_provider(),