Skip to content

Commit

Permalink
removing syntax highlighting
Browse files Browse the repository at this point in the history
The current implementation of syntax highlighting was only ever intended
as an initial proof of concept (largely due to performance reasons).
Finding a proper solution to this and supporting more than just Rust,
shell and the plumbing rules file types is going to be something that
requires proper thought and likely multiple changes to the internal data
structures.

I've considered using treesitter but I'm not overly happy with having to
track each edit twice (once for the buffer content and once for tree
sitter) so I'll need to see if there is a way to handle this without
baking in too many assumptions about the structure of buffer contents.
Given that a key part of ad is the assertion that all text inside of ad
is treated equally, I'm not a massive fan of having to set up different
syntax support for custom buffers and extension programs that users
write (or supporting rich markup inside of ad buffers).

If possible it would be nice to push this out to only live on the UI
side of things, and to support running ad in a headless mode capable of
driving a UI efficiently so that UI implementers were free to handle
that side of things in the way they want.
  • Loading branch information
sminez committed Nov 17, 2024
1 parent bc66d11 commit 8d49e11
Show file tree
Hide file tree
Showing 7 changed files with 136 additions and 452 deletions.
8 changes: 0 additions & 8 deletions src/buffer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use crate::{
editor::Action,
exec::IterBoundedChars,
fsys::InputFilter,
ftype::{lex::Tokenizer, try_tokenizer_for_path},
key::Input,
util::normalize_line_endings,
MAX_NAME_LEN, UNNAMED_BUFFER,
Expand Down Expand Up @@ -150,15 +149,13 @@ pub struct Buffer {
pub(crate) last_save: SystemTime,
pub(crate) dirty: bool,
pub(crate) input_filter: Option<InputFilter>,
pub(crate) tokenizer: Option<Tokenizer>,
edit_log: EditLog,
}

impl Buffer {
/// As the name implies, this method MUST be called with the full cannonical file path
pub(super) fn new_from_canonical_file_path(id: usize, path: PathBuf) -> io::Result<Self> {
let (kind, raw) = BufferKind::try_kind_and_content_from_path(path.clone())?;
let tokenizer = try_tokenizer_for_path(&path, raw.lines().next());

Ok(Self {
id,
Expand All @@ -170,7 +167,6 @@ impl Buffer {
last_save: SystemTime::now(),
dirty: false,
edit_log: EditLog::default(),
tokenizer,
input_filter: None,
})
}
Expand Down Expand Up @@ -267,7 +263,6 @@ impl Buffer {
last_save: SystemTime::now(),
dirty: false,
edit_log: Default::default(),
tokenizer: None,
input_filter: None,
}
}
Expand All @@ -284,7 +279,6 @@ impl Buffer {
last_save: SystemTime::now(),
dirty: false,
edit_log: EditLog::default(),
tokenizer: None,
input_filter: None,
}
}
Expand All @@ -309,7 +303,6 @@ impl Buffer {
last_save: SystemTime::now(),
dirty: false,
edit_log: EditLog::default(),
tokenizer: None,
input_filter: None,
}
}
Expand All @@ -327,7 +320,6 @@ impl Buffer {
last_save: SystemTime::now(),
dirty: false,
edit_log: EditLog::default(),
tokenizer: None,
input_filter: None,
}
}
Expand Down
Loading

0 comments on commit 8d49e11

Please sign in to comment.