Unnamed repository; edit this file 'description' to name the repository.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# Author: Two-Six<[email protected]>

"ui.background" = {bg="nord6"}
"ui.text" = "nord0"
"ui.selection" = {bg="nord7", fg="nord6"}
"ui.cursorline" = {bg="nord4"}
"ui.statusline" = {bg="nord4", fg="nord0"}
"ui.statusline.inactive" = {bg="nord5", fg="nord0"}
"ui.cursor.match" = {bg="nord8"}
"ui.cursor" = {bg="nord10", fg="nord6"}
"ui.cursorline.primary" = {bg="nord5"}
"ui.linenr" = {fg="nord7"}
"ui.linenr.selected" = {fg="nord0", bg="nord5"}
"ui.menu" = {bg="nord4",fg="nord0"}
"ui.menu.selected" = {bg="nord5"}
"ui.popup" = {bg="nord4"}
"ui.popup.info" = {bg="nord4",fg="nord0"}
"ui.help" = {bg="nord4",fg="nord0"}
"ui.window" = {bg="nord4"}


"ui.statusline.normal" = { fg = "nord0", bg = "nord8" }
"ui.statusline.insert" = { fg = "nord0", bg = "nord13" }
"ui.statusline.select" = { fg = "nord0", bg = "nord15" }

# Virtual/invisible text
"ui.virtual" = "nord8"
"ui.virtual.ruler" = {bg="nord4"}
"ui.virtual.inlay-hint" = { fg = "nord3", modifiers = ["italic"] }
"ui.virtual.jump-label" = { fg = "nord11", modifiers = ["bold"] }



"diagnostic.error" = { underline = { color = "nord11", style = "curl" } }
"diagnostic.warning" = { underline = { color = "nord13", style = "curl" } }
"diagnostic.info" = { underline = { color = "nord13", style = "curl" } }
"diagnostic.hint" = { underline = { color = "nord13", style = "curl" } }
"diagnostic.unnecessary" = { modifiers = ["dim"] }
"diagnostic.deprecated" = { modifiers = ["crossed_out"] }

"constant.numeric" = {fg="nord15"}
"constant.builtin" = {fg="nord15"}

"keyword" = {fg="nord2"}
"keyword.control" = {fg="nord2"}
"keyword.function" = {fg="nord2"}

"function" = {fg="nord3"}
"function.macro" = {fg="nord10", modifiers=["bold"]}
"function.method" = {fg="nord0"}
"function.builtin" = {fg="nord10"}

"variable.builtin" = {fg="nord3"}
"variable.other" = {fg="nord3"}
"variable" = {fg="nord0"}

"string" = "nord14"
"comment" = "nord7"
"namespace" = {fg="nord10"}
"attribute" = {fg="nord10"}
"type" = {fg="nord10"}

"markup.heading" = {fg="nord0", modifiers=["bold"]}
"markup.raw" = {fg="nord10"}
"markup.link.url" = {fg="nord3"}
"markup.link.text" = {fg="nord12"}
"markup.quote" = {fg="nord3", modifiers=["italic"]}

"diff.plus" = {fg = "nord14"}
"diff.delta" = {fg = "nord13"}
"diff.minus" = {fg = "nord11"}


[palette]
nord0 = "#2E3440"
nord1 = "#3B4252"
nord2 = "#434C5E"
nord3 = "#4C566A"
nord4 = "#D8DEE9"
nord5 = "#E5E9F0"
nord6 = "#ECEFF4"
nord7 = "#8FBCBB"
nord8 = "#88C0D0"
nord9 = "#81A1C1"
nord10 = "#5E81AC"
nord11 = "#BF616A"
nord12 = "#D08770"
nord13 = "#EBCB8B"
nord14 = "#A3BE8C"
nord15 = "#B48EAD"
i range values only, that works. 1 } else { // We use max(1) here because all grapeheme clusters--even illformed // ones--should have at least some width so they can be edited // properly. UnicodeWidthStr::width(g).max(1) } } #[must_use] pub fn nth_prev_grapheme_boundary(slice: RopeSlice, char_idx: usize, n: usize) -> usize { // Bounds check debug_assert!(char_idx <= slice.len_chars()); // We work with bytes for this, so convert. let mut byte_idx = slice.char_to_byte(char_idx); // Get the chunk with our byte index in it. let (mut chunk, mut chunk_byte_idx, mut chunk_char_idx, _) = slice.chunk_at_byte(byte_idx); // Set up the grapheme cursor. let mut gc = GraphemeCursor::new(byte_idx, slice.len_bytes(), true); // Find the previous grapheme cluster boundary. for _ in 0..n { loop { match gc.prev_boundary(chunk, chunk_byte_idx) { Ok(None) => return 0, Ok(Some(n)) => { byte_idx = n; break; } Err(GraphemeIncomplete::PrevChunk) => { let (a, b, c, _) = slice.chunk_at_byte(chunk_byte_idx - 1); chunk = a; chunk_byte_idx = b; chunk_char_idx = c; } Err(GraphemeIncomplete::PreContext(n)) => { let ctx_chunk = slice.chunk_at_byte(n - 1).0; gc.provide_context(ctx_chunk, n - ctx_chunk.len()); } _ => unreachable!(), } } } let tmp = byte_to_char_idx(chunk, byte_idx - chunk_byte_idx); chunk_char_idx + tmp } /// Finds the previous grapheme boundary before the given char position. pub fn prev_grapheme_boundary(slice: RopeSlice, char_idx: usize) -> usize { nth_prev_grapheme_boundary(slice, char_idx, 1) } #[must_use] pub fn nth_next_grapheme_boundary(slice: RopeSlice, char_idx: usize, n: usize) -> usize { // Bounds check debug_assert!(char_idx <= slice.len_chars()); // We work with bytes for this, so convert. let mut byte_idx = slice.char_to_byte(char_idx); // Get the chunk with our byte index in it. let (mut chunk, mut chunk_byte_idx, mut chunk_char_idx, _) = slice.chunk_at_byte(byte_idx); // Set up the grapheme cursor. let mut gc = GraphemeCursor::new(byte_idx, slice.len_bytes(), true); // Find the nth next grapheme cluster boundary. for _ in 0..n { loop { match gc.next_boundary(chunk, chunk_byte_idx) { Ok(None) => return slice.len_chars(), Ok(Some(n)) => { byte_idx = n; break; } Err(GraphemeIncomplete::NextChunk) => { chunk_byte_idx += chunk.len(); let (a, _, c, _) = slice.chunk_at_byte(chunk_byte_idx); chunk = a; chunk_char_idx = c; } Err(GraphemeIncomplete::PreContext(n)) => { let ctx_chunk = slice.chunk_at_byte(n - 1).0; gc.provide_context(ctx_chunk, n - ctx_chunk.len()); } _ => unreachable!(), } } } let tmp = byte_to_char_idx(chunk, byte_idx - chunk_byte_idx); chunk_char_idx + tmp } /// Finds the next grapheme boundary after the given char position. pub fn next_grapheme_boundary(slice: RopeSlice, char_idx: usize) -> usize { nth_next_grapheme_boundary(slice, char_idx, 1) } /// Returns whether the given char position is a grapheme boundary. pub fn is_grapheme_boundary(slice: RopeSlice, char_idx: usize) -> bool { // Bounds check debug_assert!(char_idx <= slice.len_chars()); // We work with bytes for this, so convert. let byte_idx = slice.char_to_byte(char_idx); // Get the chunk with our byte index in it. let (chunk, chunk_byte_idx, _, _) = slice.chunk_at_byte(byte_idx); // Set up the grapheme cursor. let mut gc = GraphemeCursor::new(byte_idx, slice.len_bytes(), true); // Determine if the given position is a grapheme cluster boundary. loop { match gc.is_boundary(chunk, chunk_byte_idx) { Ok(n) => return n, Err(GraphemeIncomplete::PreContext(n)) => { let (ctx_chunk, ctx_byte_start, _, _) = slice.chunk_at_byte(n - 1); gc.provide_context(ctx_chunk, ctx_byte_start); } Err(_) => unreachable!(), } } } /// An iterator over the graphemes of a `RopeSlice`. #[derive(Clone)] pub struct RopeGraphemes<'a> { text: RopeSlice<'a>, chunks: Chunks<'a>, cur_chunk: &'a str, cur_chunk_start: usize, cursor: GraphemeCursor, } impl<'a> RopeGraphemes<'a> { #[must_use] pub fn new(slice: RopeSlice) -> RopeGraphemes { let mut chunks = slice.chunks(); let first_chunk = chunks.next().unwrap_or(""); RopeGraphemes { text: slice, chunks, cur_chunk: first_chunk, cur_chunk_start: 0, cursor: GraphemeCursor::new(0, slice.len_bytes(), true), } } } impl<'a> Iterator for RopeGraphemes<'a> { type Item = RopeSlice<'a>; fn next(&mut self) -> Option<RopeSlice<'a>> { let a = self.cursor.cur_cursor(); let b; loop { match self .cursor .next_boundary(self.cur_chunk, self.cur_chunk_start) { Ok(None) => { return None; } Ok(Some(n)) => { b = n; break; } Err(GraphemeIncomplete::NextChunk) => { self.cur_chunk_start += self.cur_chunk.len(); self.cur_chunk = self.chunks.next().unwrap_or(""); } _ => unreachable!(), } } if a < self.cur_chunk_start { let a_char = self.text.byte_to_char(a); let b_char = self.text.byte_to_char(b); Some(self.text.slice(a_char..b_char)) } else { let a2 = a - self.cur_chunk_start; let b2 = b - self.cur_chunk_start; Some((&self.cur_chunk[a2..b2]).into()) } } }