Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add syntax highlighting for Solidity #1854

Merged
merged 6 commits into from
Mar 22, 2022

Conversation

slinlee
Copy link
Contributor

@slinlee slinlee commented Mar 22, 2022

image

TODO:

  • Add fork of tree-sitter-solidity that includes src/ and the generated files.
  • Add queries for highlighting

Resolves #1853

@slinlee
Copy link
Contributor Author

slinlee commented Mar 22, 2022

@the-mikedavis I've got another basic question. After adding the highlight queries, when I try to open a .sol file I get this error:

thread 'main' panicked at 'Could not parse queries for language "solidity". Are your grammars out of sync? Try running 'hx --grammar fetch' and 'hx --grammar build'. This query could not be parsed: QueryError { row: 0, column: 0, offset: 0, message: "Incompatible language version 11. Expected minimum 13, maximum 14", kind: Language }', helix-core/src/syntax.rs:384:43
stack backtrace:
   0: rust_begin_unwind
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/std/src/panicking.rs:498:5
   1: core::panicking::panic_fmt
             at /rustc/9d1b2106e23b1abd32fce1f17267604a5102f57a/library/core/src/panicking.rs:116:14
   2: helix_core::syntax::LanguageConfiguration::initialize_highlight
   3: once_cell::imp::OnceCell<T>::initialize::{{closure}}
   4: once_cell::imp::initialize_inner
   5: once_cell::imp::OnceCell<T>::initialize
   6: helix_view::document::Document::set_language
   7: helix_view::document::Document::open
   8: helix_view::editor::Editor::open
   9: helix_term::application::Application::new
  10: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
  11: tokio::park::thread::CachedParkThread::block_on
  12: tokio::runtime::thread_pool::ThreadPool::block_on
  13: tokio::runtime::Runtime::block_on
  14: hx::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

It happens both with an existing file, or creating a new one: hx new.sol

@archseer
Copy link
Member

Looks like the parser was generated with an old tree-sitter CLI

@slinlee slinlee changed the title Add tree-sitter support for Solidity Add syntax highlighting for Solidity Mar 22, 2022
@slinlee
Copy link
Contributor Author

slinlee commented Mar 22, 2022

Looks like the parser was generated with an old tree-sitter CLI

Thanks! Note to myself: don't use the tree-sitter-cli installed via npm. It's older and has fewer features.

@slinlee slinlee marked this pull request as ready for review March 22, 2022 16:21
Copy link
Member

@the-mikedavis the-mikedavis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

@the-mikedavis the-mikedavis merged commit 3e78b8f into helix-editor:master Mar 22, 2022
@slinlee slinlee deleted the solidity branch March 22, 2022 17:39
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add syntax highlighting for Solidity
3 participants