Skip to content

Commit

Permalink
Update deps, introduce the new tree-sitter lifetimes
Browse files Browse the repository at this point in the history
  • Loading branch information
archseer committed May 27, 2021
1 parent b114cfa commit 094203c
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 31 deletions.
32 changes: 16 additions & 16 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

------

as you type completion!

- tree sitter:
- lua
- markdown
Expand All @@ -18,6 +20,9 @@
- [ ] document.on_type provider triggers
- [ ] completion isIncomplete support

- [ ] scroll wheel support
- [ ] matching bracket highlight

1
- [ ] respect view fullscreen flag
- [ ] Implement marks (superset of Selection/Range)
Expand Down
16 changes: 8 additions & 8 deletions helix-core/src/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -745,24 +745,24 @@ struct LocalScope<'a> {
local_defs: Vec<LocalDef<'a>>,
}

struct HighlightIter<'a, F>
struct HighlightIter<'a, 'tree: 'a, F>
where
F: FnMut(&str) -> Option<&'a HighlightConfiguration> + 'a,
{
source: RopeSlice<'a>,
byte_offset: usize,
injection_callback: F,
cancellation_flag: Option<&'a AtomicUsize>,
layers: Vec<HighlightIterLayer<'a>>,
layers: Vec<HighlightIterLayer<'a, 'tree>>,
iter_count: usize,
next_event: Option<HighlightEvent>,
last_highlight_range: Option<(usize, usize, usize)>,
}

struct HighlightIterLayer<'a> {
struct HighlightIterLayer<'a, 'tree: 'a> {
_tree: Option<Tree>,
cursor: QueryCursor,
captures: iter::Peekable<QueryCaptures<'a, Cow<'a, [u8]>>>,
captures: iter::Peekable<QueryCaptures<'a, 'tree, Cow<'a, [u8]>>>,
config: &'a HighlightConfiguration,
highlight_end_stack: Vec<usize>,
scope_stack: Vec<LocalScope<'a>>,
Expand Down Expand Up @@ -929,7 +929,7 @@ impl HighlightConfiguration {
}
}

impl<'a> HighlightIterLayer<'a> {
impl<'a, 'tree: 'a> HighlightIterLayer<'a, 'tree> {
/// Create a new 'layer' of highlighting for this document.
///
/// In the even that the new layer contains "combined injections" (injections where multiple
Expand Down Expand Up @@ -1193,7 +1193,7 @@ impl<'a> HighlightIterLayer<'a> {
}
}

impl<'a, F> HighlightIter<'a, F>
impl<'a, 'tree: 'a, F> HighlightIter<'a, 'tree, F>
where
F: FnMut(&str) -> Option<&'a HighlightConfiguration> + 'a,
{
Expand Down Expand Up @@ -1244,7 +1244,7 @@ where
}
}

fn insert_layer(&mut self, mut layer: HighlightIterLayer<'a>) {
fn insert_layer(&mut self, mut layer: HighlightIterLayer<'a, 'tree>) {
if let Some(sort_key) = layer.sort_key() {
let mut i = 1;
while i < self.layers.len() {
Expand All @@ -1263,7 +1263,7 @@ where
}
}

impl<'a, F> Iterator for HighlightIter<'a, F>
impl<'a, 'tree: 'a, F> Iterator for HighlightIter<'a, 'tree, F>
where
F: FnMut(&str) -> Option<&'a HighlightConfiguration> + 'a,
{
Expand Down
4 changes: 4 additions & 0 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -674,6 +674,7 @@ pub fn search(cx: &mut Context) {

cx.push_layer(Box::new(prompt));
}
// can't search next for ""compose"" for some reason

pub fn _search_next(cx: &mut Context, extend: bool) {
if let Some(query) = register::get('\\') {
Expand Down Expand Up @@ -1670,6 +1671,9 @@ pub mod insert {

let head = pos + offs + text.len();

// TODO: range replace or extend
// range.replace(|range| range.is_empty(), head); -> fn extend if cond true, new head pos
// can be used with cx.mode to do replace or extend on most changes
ranges.push(Range::new(
if range.is_empty() {
head
Expand Down
5 changes: 1 addition & 4 deletions helix-term/src/ui/completion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ use lsp::CompletionItem;

impl menu::Item for CompletionItem {
fn filter_text(&self) -> &str {
self.filter_text
.as_ref()
.unwrap_or_else(|| &self.label)
.as_str()
self.filter_text.as_ref().unwrap_or(&self.label).as_str()
}

fn label(&self) -> &str {
Expand Down
7 changes: 7 additions & 0 deletions helix-term/src/ui/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,13 @@ impl EditorView {
// TODO: scope matching: biggest union match? [string] & [html, string], [string, html] & [ string, html]
// can do this by sorting our theme matches based on array len (longest first) then stopping at the
// first rule that matches (rule.all(|scope| scopes.contains(scope)))
// log::info!(
// "scopes: {:?}",
// spans
// .iter()
// .map(|span| theme.scopes()[span.0].as_str())
// .collect::<Vec<_>>()
// );
let style = match spans.first() {
Some(span) => theme.get(theme.scopes()[span.0].as_str()),
None => theme.get("ui.text"),
Expand Down
7 changes: 6 additions & 1 deletion helix-term/src/ui/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ fn parse<'a>(contents: &'a str, theme: Option<&Theme>) -> tui::text::Text<'a> {
None => text_style,
};

// TODO: replace tabs with indentation

let mut slice = &text[start..end];
while let Some(end) = slice.find('\n') {
// emit span up to newline
Expand Down Expand Up @@ -153,6 +155,7 @@ fn parse<'a>(contents: &'a str, theme: Option<&Theme>) -> tui::text::Text<'a> {
}
}
Event::Code(text) | Event::Html(text) => {
log::warn!("code {:?}", text);
let mut span = to_span(text);
span.style = code_style;
spans.push(span);
Expand All @@ -167,7 +170,9 @@ fn parse<'a>(contents: &'a str, theme: Option<&Theme>) -> tui::text::Text<'a> {
lines.push(Spans::default());
}
// TaskListMarker(bool) true if checked
_ => (),
_ => {
log::warn!("unhandled markdown event {:?}", event);
}
}
// build up a vec of Paragraph tui widgets
}
Expand Down
2 changes: 1 addition & 1 deletion helix-term/src/ui/prompt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ impl Component for Prompt {

fn cursor_position(&self, area: Rect, editor: &Editor) -> Option<Position> {
Some(Position::new(
area.height as usize,
area.y as usize,
area.x as usize + self.prompt.len() + self.cursor,
))
}
Expand Down
1 change: 1 addition & 0 deletions runtime/queries/go/indents.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ indent = [
"const_declaration",
"var_declaration",
"type_declaration",
"type_spec",
"function_declaration",
"method_declaration",
"composite_literal",
Expand Down
3 changes: 2 additions & 1 deletion shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pkgs.mkShell {
# https://github.com/rust-lang/rust/issues/55979
LD_LIBRARY_PATH="${stdenv.cc.cc.lib}/lib64:$LD_LIBRARY_PATH";

HELIX_RUNTIME=./runtime;
# HELIX_RUNTIME=./runtime;
HELIX_RUNTIME="/home/speed/src/helix/runtime";
}

2 changes: 2 additions & 0 deletions theme.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
"ui.text" = { fg = "#a4a0e8"} # lavender
"ui.text.focus" = { fg = "#dbbfef"} # lilac

"ui.menu.selected" = { fg = "#281733", bg = "#ffffff" } # revolver

"warning" = "#ffcd1c"
"error" = "#f47868"
"info" = "#6F44F0"
Expand Down

0 comments on commit 094203c

Please sign in to comment.