This PR upgrades the syntect dependency to the latest version. Since there are several major version bumps from the current version, there are breaking changes that ultimately affect the public API of scribe. The most notable changes are described below.
is now TokenSet::new(String, &'a SyntaxDefinition, &'a SyntaxSet) -> TokenSet<'a>
Workspace::new(&Path) -> Result<Workspace>
is now Workspace::new(&Path, Option<&Path>) -> Result<Workspace> to allow loading syntaxes during construction
Buffer tokenization
Tokenization previously only required a syntax definition, but now requires a SyntaxSet too. As a result, buffers are no longer able to produce a TokenSet using only their own fields. Given this added dependency, setting up tokenization is now the responsibility of Workspace::current_buffer_tokens.
Current workspace buffer
Accessing the workspace's current buffer was previously done using Workspace::current_buffer(&mut self). Despite the encapsulation benefits this accessor approach provides, Rust isn't smart enough to infer that we're only borrowing one field, and the entire workspace is borrowed for the given lifetime. This was incompatible with the new tokenization requirements, which use both the syntax set from the workspace and the definition from the buffer; calling current_buffer() on the workspace would make accessing its syntax_set impossible.
To solve this, the current buffer is now accessed directly as a field.
Error propagation
Syntect now returns proper errors instead of panicking. To make proper use of these, the TokenIterator type has been updated to handle Result-based returns. When an error is discovered, iteration is halted, and the error is stored in a public field on the iterator. This allows consumers to check for errors after iterating, rather than on every returned value during iteration.
This PR upgrades the
syntect
dependency to the latest version. Since there are several major version bumps from the current version, there are breaking changes that ultimately affect the public API ofscribe
. The most notable changes are described below.TL;DR
Removed
Buffer::tokens(&self)
Buffer::current_scope(&self)
Workspace::current_buffer(&mut self)
Workspace::contains_buffer_with_path(&self, &Path) -> bool
Added
Buffer::file_extension(&self) -> Option<String>
Workspace::current_buffer_tokens(&'a self) -> Option<TokenSet<'a>>
Changed
TokenIterator::new(&'a str, &'a SyntaxDefinition) -> TokenIterator<'a>
TokenIterator::new(&'a str, &'a SyntaxDefinition, &'a SyntaxSet) -> TokenIterator<'a>
TokenSet::new(String, &'a SyntaxDefinition) -> TokenSet<'a>
TokenSet::new(String, &'a SyntaxDefinition, &'a SyntaxSet) -> TokenSet<'a>
Workspace::new(&Path) -> Result<Workspace>
Workspace::new(&Path, Option<&Path>) -> Result<Workspace>
to allow loading syntaxes during constructionBuffer tokenization
Tokenization previously only required a syntax definition, but now requires a
SyntaxSet
too. As a result, buffers are no longer able to produce aTokenSet
using only their own fields. Given this added dependency, setting up tokenization is now the responsibility ofWorkspace::current_buffer_tokens
.Current workspace buffer
Accessing the workspace's current buffer was previously done using
Workspace::current_buffer(&mut self)
. Despite the encapsulation benefits this accessor approach provides, Rust isn't smart enough to infer that we're only borrowing one field, and the entire workspace is borrowed for the given lifetime. This was incompatible with the new tokenization requirements, which use both the syntax set from the workspace and the definition from the buffer; callingcurrent_buffer()
on the workspace would make accessing itssyntax_set
impossible.To solve this, the current buffer is now accessed directly as a field.
Error propagation
Syntect now returns proper errors instead of panicking. To make proper use of these, the TokenIterator type has been updated to handle Result-based returns. When an error is discovered, iteration is halted, and the error is stored in a public field on the iterator. This allows consumers to check for errors after iterating, rather than on every returned value during iteration.