leon-barrett / just-mode.el

Emacs mode for justfiles
GNU General Public License v3.0
37 stars 6 forks source link

quotes break comment styling #11

Open aronatkins opened 6 months ago

aronatkins commented 6 months ago

Single and double quotes confuse comment styling.

Here is a simple justfile showing the problem:

# Comment styled comment. But wait.
#
# It is very difficult to justify contractions when it can't be styled
# as a comment. Isn't this lovely?
#
# Another comment styled comment.
#
# Double quotes are also a challenge if we "quote text" inside comments.
#
# A final comment styled comment.

When viewed, it looks like (notice the black not grey text, and the green strings).

image

This may be fallout from https://github.com/leon-barrett/just-mode.el/pull/10.

leon-barrett commented 6 months ago

Thanks, I think I've fixed it with commit https://github.com/leon-barrett/just-mode.el/commit/11f5fd232f62b97714344e0aea89d5f815dc539d

Please reopen this issue if it's not improved.

aronatkins commented 6 months ago

Your change made styling better. Comments are styled correctly in isolation, but the quoting still causes code to be seen as strings.

export ONE=1
# open single quote '
export TWO=2
# close single quote '
export THREE=3
# open double quote "
export FOUR=4
# close double quote "
export FIVE=5
image
aronatkins commented 6 months ago

I am unable to reopen with my permissions.

leon-barrett commented 6 months ago

You are quite right. My little bit of reading suggests that we'll either need to use something more advanced like `syntax-propertize-function' or a treesitter grammar like https://github.com/IndianBoy42/tree-sitter-just . I don't know enough about either of them to do that right now. I'm very open to pull requests!

Until I get around to that, I'll roll back the latest changes. I think having names like a#b look like comments is better than having single quotes in commas mess up syntax, though I admit that neither is great.

leon-barrett commented 1 month ago

I believe this is fixed in just-ts-mode, which uses a tree-sitter grammar for better parsing. It is not yet published in MELPA.