Giter Site home page Giter Site logo

astro-ts-mode's People

Contributors

sorixelle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

emacsmirror

astro-ts-mode's Issues

Indentation error

This example shows an indentation error

---
---
<!doctype html>
<html lang="en">
    <head>
        <BaseHead title={SITE_TITLE} description={SITE_DESCRIPTION} />
    </head>
    <body>
        <Header />
        <mainain>
            <ol class="posts list">
		{
page.data.map((post) => (
    <li class="post">
        <PostSummary {post} />
    </li>
))
}
	    </ol
	    <p>Pagination {page.size}/{page.total}</p>
	    {page.total > 2 ? (
		<Pagination
		    length={page.lastPage}
		    currentUrl={page.url.current}
		    currentPage={page.currentPage}
		    firstUrl={`/${first_path}`}
		    prevUrl={page.url.prev}
		    nextUrl={page.url.next}
		    lastUrl={`/${first_path}/${page.lastPage}`}
		/>
	    ) : null}
        </main>
        <Footer />
    </body>
</html>

CSS syntax highlighting applied across whole file if no `<style>` tag is present

Currently, if there's no <style> tags in the file, astro-mode attempts to syntax highlight everything outside the frontmatter as if it were CSS.

I've done some digging and I think this is an Emacs bug (unless I'm misunderstanding how I'm supposed to use treesit-range-settings). Will need to come up with a workaround.

Technical explanation When there's no style_element nodes in the document, treesit-parser-included-ranges returns nil for the CSS range, which makes sense. However, treesit-parser-root-node doesn't seem to return the correct node in this case. I'd expect that it would just return nil, since if there's a nil range (ie. no CSS content in the document), there shouldn't be a root node, but it instead returns a stylesheet node spanning the full range of the document, which doesn't seem correct. Because treesit's font locking applies to the whole root node, it ends up applying CSS highlighting to the whole document.

Just passing on a tip

Thanks for making this. I'd been using the same TS grammar as you, but had kind of hacked together my own astro-ts-mode. This is much nicer than the one I had. I wanted to pass along a tip for configuration, there's some great synergy that can be achieved with the use of treesit-auto.

Here's what my use-package statement looks like with treesit-auto and astro-ts-mode:

    (use-package astro-ts-mode
      :after (treesit-auto)
      :config
      (setq astro-ts-auto-recipe
            (make-treesit-auto-recipe
             :lang 'astro
             :ts-mode 'astro-ts-mode
             :url "https://github.com/virchau13/tree-sitter-astro"
             :revision "master"
             :source-dir "src"))
      (add-to-list 'treesit-auto-recipe-list astro-ts-auto-recipe))

Feel free to close this, just wanted to pass this along to you. Thanks again!

Syntax highlighting issue.

Hi,

First, I'd like to thank you for making this mode.
I've just started learning Astro, and I am glad someone has already made a mode for it.

I've followed the instructions to set up Astro mode, and everything works fine, except the highlighting is a bit off for some reason.
Please see the screenshot below. And if you can point me in the right direction, I am willing to do some work contributing to this project.

Again, thanks for making this. Save me the misery of using VScode
Screenshot 2023-07-19 at 22 27 17

Config to set indentation to 4 spaces

(use-package astro-ts-mode
  :config
  (setq astro-ts-mode-indent-offset 4)
  :init
  (add-hook 'astro-ts-mode-hook (lambda () (setq indent-tabs-mode nil)))
  )

Syntax highlighting becomes garbled when deleting other language blocks

When deleting a whole block of code highlighted in another language (eg. <style> tags, <script> tags, inline interpolations), astro-mode still tries to highlight the text that took it's place as the language that was deleted, which often isn't necessarily correct. An example:

Before:
image

After:
image

Technical explanation When treesit-update-ranges calculates the new ranges for a parser that had all it's ranges removed (ie. treesit-query-range for that parser returns nil), treesit--merge-ranges still returns the old range. This behavior is incorrect - since the new range no longer exists, the merged range should also be zero.

`treesit-ready-p` is not available

I am on emacs version 29.0.92, compiled form source form the emacs git repo. using the emacs-29 branch.

the (treesit-ready-p 'lang) does not exist.
Had to change it to (treesit-language-available-p 'lang) for it to work.
On lines: 177, 180, 183 and 218.

redisplay error: Note type error at frontmatter

so, I don't know if this is a problem with emacs 29.3's treesit or astro-ts-mode, or what, but I'm consisitently getting this error when attempting to enable astro-ts-mode on any astro file:

redisplay--pre-redisplay-functions: (treesit-query-error "Node type error at" 32 "(frontmatter (raw_text) @cap) (interpolation (raw_text) @cap) (script_element (raw_text) @cap)" "Debug the query with `treesit-query-validate'")

I've ruled out treesit-auto, I've ensured I'm using the same version of the treesitter grammar that I'm using in other editors, where it works fine. Any ideas?

Error during redisplay: (jit-lock-function 1) signaled (treesit-query-error "Node type error at" 2 "

Hi Sorixelle,

Thanks a lot for the package. I have followed your installation instructions without any errors, specifically:

  • installed from MELPA
  • manually installed the grammars using treesit-install-language-grammar

When I open a .astro file the major mode is not detected (it remains Fundamental in the mode line) but it is activated if I do M-x astro-ts-mode (I see the change in the mode line). However, no code is highlighted and tree-sitter throws the error below:

Screenshot from 2024-03-05 09-37-13

Any help would be really appreciated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.