mirror of https://github.com/helix-editor/helix
Compare commits
11 Commits
eebbd641b8
...
97161a32ca
Author | SHA1 | Date |
---|---|---|
|
97161a32ca | |
|
4281228da3 | |
|
395a71bf53 | |
|
1e4bf6704a | |
|
b01fbb4a22 | |
|
f75a26cb9b | |
|
21ae1c98fb | |
|
7b8a4b7a51 | |
|
715d4ae2d5 | |
|
22b184b570 | |
|
26efba0dc3 |
|
@ -112,8 +112,8 @@
|
|||
| iex | ✓ | | | | |
|
||||
| ini | ✓ | | | | |
|
||||
| ink | ✓ | | | | |
|
||||
| inko | ✓ | ✓ | ✓ | | |
|
||||
| janet | ✓ | | | | |
|
||||
| inko | ✓ | ✓ | ✓ | ✓ | |
|
||||
| janet | ✓ | | ✓ | | |
|
||||
| java | ✓ | ✓ | ✓ | | `jdtls` |
|
||||
| javascript | ✓ | ✓ | ✓ | ✓ | `typescript-language-server` |
|
||||
| jinja | ✓ | | | | |
|
||||
|
|
|
@ -356,7 +356,7 @@ fn directory_content(path: &Path) -> Result<Vec<(PathBuf, bool)>, std::io::Error
|
|||
.map(|entry| {
|
||||
(
|
||||
entry.path(),
|
||||
entry.file_type().is_ok_and(|file_type| file_type.is_dir()),
|
||||
std::fs::metadata(entry.path()).is_ok_and(|metadata| metadata.is_dir()),
|
||||
)
|
||||
})
|
||||
.collect();
|
||||
|
|
|
@ -308,7 +308,10 @@ impl<T: 'static + Send + Sync, D: 'static + Send + Sync> Picker<T, D> {
|
|||
F: Fn(&mut Context, &T, Action) + 'static,
|
||||
{
|
||||
let columns: Arc<[_]> = columns.into_iter().collect();
|
||||
let matcher_columns = columns.iter().filter(|col| col.filter).count() as u32;
|
||||
let matcher_columns = columns
|
||||
.iter()
|
||||
.filter(|col: &&Column<T, D>| col.filter)
|
||||
.count() as u32;
|
||||
assert!(matcher_columns > 0);
|
||||
let matcher = Nucleo::new(
|
||||
Config::DEFAULT,
|
||||
|
|
|
@ -374,6 +374,30 @@ impl<'a> Text<'a> {
|
|||
self.lines.len()
|
||||
}
|
||||
|
||||
/// Patch text with a new style. Only updates fields that are in the new style.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
/// # use helix_tui::text::Text;
|
||||
/// # use helix_view::graphics::{Color, Style};
|
||||
/// let style1 = Style::default().fg(Color::Yellow);
|
||||
/// let style2 = Style::default().fg(Color::Yellow).bg(Color::Black);
|
||||
/// let mut half_styled_text = Text::styled(String::from("The first line\nThe second line"), style1);
|
||||
/// let full_styled_text = Text::styled(String::from("The first line\nThe second line"), style2);
|
||||
/// assert_ne!(half_styled_text, full_styled_text);
|
||||
///
|
||||
/// half_styled_text.patch_style(Style::default().bg(Color::Black));
|
||||
/// assert_eq!(half_styled_text, full_styled_text);
|
||||
/// ```
|
||||
pub fn patch_style(&mut self, style: Style) {
|
||||
for line in &mut self.lines {
|
||||
for span in &mut line.0 {
|
||||
span.style = span.style.patch(style);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Apply a new style to existing text.
|
||||
///
|
||||
/// # Examples
|
||||
|
@ -386,13 +410,13 @@ impl<'a> Text<'a> {
|
|||
/// let styled_text = Text::styled(String::from("The first line\nThe second line"), style);
|
||||
/// assert_ne!(raw_text, styled_text);
|
||||
///
|
||||
/// raw_text.patch_style(style);
|
||||
/// raw_text.set_style(style);
|
||||
/// assert_eq!(raw_text, styled_text);
|
||||
/// ```
|
||||
pub fn patch_style(&mut self, style: Style) {
|
||||
pub fn set_style(&mut self, style: Style) {
|
||||
for line in &mut self.lines {
|
||||
for span in &mut line.0 {
|
||||
span.style = span.style.patch(style);
|
||||
span.style = style;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,8 +38,15 @@ impl Cell<'_> {
|
|||
/// Set the `Style` of this cell.
|
||||
pub fn style(mut self, style: Style) -> Self {
|
||||
self.style = style;
|
||||
self.content.set_style(style);
|
||||
self
|
||||
}
|
||||
|
||||
/// Set the `Style` of this cell.
|
||||
pub fn set_style(&mut self, style: Style) {
|
||||
self.style = style;
|
||||
self.content.set_style(style);
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, T> From<T> for Cell<'a>
|
||||
|
@ -453,6 +460,9 @@ impl Table<'_> {
|
|||
};
|
||||
if is_selected {
|
||||
buf.set_style(table_row_area, self.highlight_style);
|
||||
for cell in &mut table_row.cells {
|
||||
cell.set_style(self.highlight_style);
|
||||
}
|
||||
}
|
||||
let mut col = table_row_start_col;
|
||||
for (width, cell) in columns_widths.iter().zip(table_row.cells.iter()) {
|
||||
|
|
|
@ -0,0 +1,128 @@
|
|||
use helix_tui::text::{Span, Spans, StyledGrapheme, Text};
|
||||
use helix_view::graphics::{Color, Modifier, Style};
|
||||
|
||||
// Text
|
||||
#[test]
|
||||
fn text_width() {
|
||||
let text = Text::from("The first line\nThe second line");
|
||||
assert_eq!(15, text.width());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn text_height() {
|
||||
let text = Text::from("The first line\nThe second line");
|
||||
assert_eq!(2, text.height());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn patch_style() {
|
||||
let style1 = Style::default().fg(Color::Yellow);
|
||||
let style2 = Style::default().fg(Color::Yellow).bg(Color::Black);
|
||||
let mut half_styled_text =
|
||||
Text::styled(String::from("The first line\nThe second line"), style1);
|
||||
let full_styled_text = Text::styled(String::from("The first line\nThe second line"), style2);
|
||||
assert_ne!(half_styled_text, full_styled_text);
|
||||
|
||||
half_styled_text.patch_style(Style::default().bg(Color::Black));
|
||||
assert_eq!(half_styled_text, full_styled_text);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn set_style() {
|
||||
let style = Style::default()
|
||||
.fg(Color::Yellow)
|
||||
.add_modifier(Modifier::ITALIC);
|
||||
let mut raw_text = Text::raw("The first line\nThe second line");
|
||||
let styled_text = Text::styled(String::from("The first line\nThe second line"), style);
|
||||
assert_ne!(raw_text, styled_text);
|
||||
|
||||
raw_text.set_style(style);
|
||||
assert_eq!(raw_text, styled_text);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn text_extend() {
|
||||
let style = Style::default()
|
||||
.fg(Color::Yellow)
|
||||
.add_modifier(Modifier::ITALIC);
|
||||
let mut text = Text::from("The first line\nThe second line");
|
||||
assert_eq!(2, text.height());
|
||||
|
||||
// Adding two more unstyled lines
|
||||
text.extend(Text::raw("These are two\nmore lines!"));
|
||||
assert_eq!(4, text.height());
|
||||
|
||||
// Adding a final two styled lines
|
||||
text.extend(Text::styled("Some more lines\nnow with more style!", style));
|
||||
assert_eq!(6, text.height());
|
||||
}
|
||||
|
||||
// Span
|
||||
|
||||
#[test]
|
||||
fn styled_graphemes() {
|
||||
let style = Style::default().fg(Color::Yellow);
|
||||
let span = Span::styled("Text", style);
|
||||
let style = Style::default().fg(Color::Green).bg(Color::Black);
|
||||
let styled_graphemes = span.styled_graphemes(style);
|
||||
assert_eq!(
|
||||
vec![
|
||||
StyledGrapheme {
|
||||
symbol: "T",
|
||||
style: Style {
|
||||
fg: Some(Color::Yellow),
|
||||
bg: Some(Color::Black),
|
||||
underline_color: None,
|
||||
underline_style: None,
|
||||
add_modifier: Modifier::empty(),
|
||||
sub_modifier: Modifier::empty(),
|
||||
},
|
||||
},
|
||||
StyledGrapheme {
|
||||
symbol: "e",
|
||||
style: Style {
|
||||
fg: Some(Color::Yellow),
|
||||
bg: Some(Color::Black),
|
||||
underline_color: None,
|
||||
underline_style: None,
|
||||
add_modifier: Modifier::empty(),
|
||||
sub_modifier: Modifier::empty(),
|
||||
},
|
||||
},
|
||||
StyledGrapheme {
|
||||
symbol: "x",
|
||||
style: Style {
|
||||
fg: Some(Color::Yellow),
|
||||
bg: Some(Color::Black),
|
||||
underline_color: None,
|
||||
underline_style: None,
|
||||
add_modifier: Modifier::empty(),
|
||||
sub_modifier: Modifier::empty(),
|
||||
},
|
||||
},
|
||||
StyledGrapheme {
|
||||
symbol: "t",
|
||||
style: Style {
|
||||
fg: Some(Color::Yellow),
|
||||
bg: Some(Color::Black),
|
||||
underline_color: None,
|
||||
underline_style: None,
|
||||
add_modifier: Modifier::empty(),
|
||||
sub_modifier: Modifier::empty(),
|
||||
},
|
||||
},
|
||||
],
|
||||
styled_graphemes.collect::<Vec<StyledGrapheme>>()
|
||||
);
|
||||
}
|
||||
|
||||
// Spans
|
||||
|
||||
#[test]
|
||||
fn spans_width() {
|
||||
let spans = Spans::from(vec![
|
||||
Span::styled("My", Style::default().fg(Color::Yellow)),
|
||||
Span::raw(" text"),
|
||||
]);
|
||||
assert_eq!(7, spans.width());
|
||||
}
|
|
@ -65,6 +65,7 @@ julia = { command = "julia", timeout = 60, args = [ "--startup-file=no", "--hist
|
|||
just-lsp = { command = "just-lsp" }
|
||||
koka = { command = "koka", args = ["--language-server", "--lsstdio"] }
|
||||
koto-ls = { command = "koto-ls" }
|
||||
kotlin-lsp = { command = "kotlin-lsp", args = ["--stdio"] }
|
||||
kotlin-language-server = { command = "kotlin-language-server" }
|
||||
lean = { command = "lean", args = [ "--server", "--memory=1024" ] }
|
||||
ltex-ls = { command = "ltex-ls" }
|
||||
|
@ -1021,6 +1022,7 @@ shebangs = []
|
|||
comment-token = "#"
|
||||
language-servers = [ "nil", "nixd" ]
|
||||
indent = { tab-width = 2, unit = " " }
|
||||
formatter = { command = "nixfmt" }
|
||||
|
||||
[[grammar]]
|
||||
name = "nix"
|
||||
|
@ -3068,7 +3070,7 @@ formatter = { command = "inko", args = ["fmt", "-"] }
|
|||
|
||||
[[grammar]]
|
||||
name = "inko"
|
||||
source = { git = "https://github.com/inko-lang/tree-sitter-inko", rev = "7860637ce1b43f5f79cfb7cc3311bf3234e9479f" }
|
||||
source = { git = "https://github.com/inko-lang/tree-sitter-inko", rev = "f58a87ac4dc6a7955c64c9e4408fbd693e804686" }
|
||||
|
||||
[[language]]
|
||||
name = "bicep"
|
||||
|
@ -4242,10 +4244,11 @@ comment-token = "#"
|
|||
block-comment-tokens = ["#-", "-#"]
|
||||
indent = { tab-width = 2, unit = " " }
|
||||
language-servers = ["koto-ls"]
|
||||
formatter = {command = "koto", args = ["--format"]}
|
||||
|
||||
[[grammar]]
|
||||
name = "koto"
|
||||
source = { git = "https://github.com/koto-lang/tree-sitter-koto", rev = "b420f7922d0d74905fd0d771e5b83be9ee8a8a9a" }
|
||||
source = { git = "https://github.com/koto-lang/tree-sitter-koto", rev = "2ffc77c14f0ac1674384ff629bfc207b9c57ed89" }
|
||||
|
||||
[[language]]
|
||||
name = "gpr"
|
||||
|
|
|
@ -78,7 +78,7 @@
|
|||
] @keyword.operator
|
||||
|
||||
[
|
||||
"class"
|
||||
"type"
|
||||
"trait"
|
||||
] @keyword.storage.type
|
||||
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
(class
|
||||
name: _ @definition.struct)
|
||||
|
||||
(trait
|
||||
name: _ @definition.interface)
|
||||
|
||||
(external_function
|
||||
name: _ @definition.function)
|
||||
|
||||
(method
|
||||
name: _ @definition.function)
|
||||
|
||||
(define_constant
|
||||
name: _ @definition.constant)
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,28 @@
|
|||
; aligns forms to the second position if there's two in a line:
|
||||
; (-> 10
|
||||
; (* 2)
|
||||
; (print))
|
||||
(par_tup_lit . (sym_lit) @first . (_) @anchor
|
||||
(#set! "scope" "tail")
|
||||
(#same-line? @first @anchor)
|
||||
; anything that doesn't match should be indented normally
|
||||
; from https://github.com/janet-lang/spork/blob/5601dc883535473bca28351cc6df04ed6c656c65/spork/fmt.janet#L87C12-L93C38
|
||||
(#not-match? @first "^(fn|match|with|with-dyns|def|def-|var|var-|defn|defn-|varfn|defmacro|defmacro-|defer|edefer|loop|seq|tabseq|catseq|generate|coro|for|each|eachp|eachk|case|cond|do|defglobal|varglobal|if|when|when-let|when-with|while|with-syms|with-vars|if-let|if-not|if-with|let|short-fn|try|unless|default|forever|upscope|repeat|forv|compwhen|compif|ev/spawn|ev/do-thread|ev/spawn-thread|ev/with-deadline|label|prompt|forever)$")) @align
|
||||
|
||||
; everything else should be indented normally:
|
||||
;
|
||||
; (let [foo 10]
|
||||
; (print foo))
|
||||
;
|
||||
; (foo
|
||||
; bar)
|
||||
(par_tup_lit . (sym_lit)) @indent
|
||||
|
||||
; for `{}` and `[]`:
|
||||
; {:foo 10
|
||||
; :bar 20}
|
||||
(struct_lit . (_) @anchor) @align
|
||||
|
||||
; [foo
|
||||
; bar]
|
||||
(sqr_tup_lit . (_) @anchor) @align
|
|
@ -0,0 +1,2 @@
|
|||
((comment) @injection.content
|
||||
(#set! injection.language "comment"))
|
|
@ -5,11 +5,13 @@
|
|||
"*"
|
||||
"/"
|
||||
"%"
|
||||
"^"
|
||||
"+="
|
||||
"-="
|
||||
"*="
|
||||
"/="
|
||||
"%="
|
||||
"^="
|
||||
"=="
|
||||
"!="
|
||||
"<"
|
||||
|
@ -99,12 +101,18 @@
|
|||
(export
|
||||
(identifier) @namespace)
|
||||
|
||||
(call
|
||||
function: (identifier) @function.method)
|
||||
(chain
|
||||
start: (identifier) @function)
|
||||
|
||||
(chain
|
||||
lookup: (identifier) @variable.other.member)
|
||||
|
||||
(call
|
||||
function: (identifier)) @function
|
||||
|
||||
(call_arg
|
||||
(identifier) @variable.other.member)
|
||||
|
||||
[
|
||||
(true)
|
||||
(false)
|
||||
|
@ -139,13 +147,10 @@
|
|||
|
||||
(self) @variable.builtin
|
||||
|
||||
(variable
|
||||
type: (identifier) @type)
|
||||
(type
|
||||
_ @type)
|
||||
|
||||
(arg
|
||||
(_ (identifier) @variable.parameter))
|
||||
|
||||
(ellipsis) @variable.parameter
|
||||
|
||||
(function
|
||||
output_type: (identifier) @type)
|
||||
|
|
|
@ -11,10 +11,6 @@
|
|||
(call_args
|
||||
((call_arg) @parameter.inside . ","? @parameter.around) @parameter.around)
|
||||
|
||||
(chain
|
||||
call: (tuple
|
||||
((element) @parameter.inside . ","? @parameter.around) @parameter.around))
|
||||
|
||||
(map
|
||||
((entry_inline) @entry.inside . ","? @entry.around) @entry.around)
|
||||
|
||||
|
|
Loading…
Reference in New Issue