tree-sitter-langs icon indicating copy to clipboard operation
tree-sitter-langs copied to clipboard

Update tree-sitter-swift

Open DivineDominion opened this issue 3 years ago • 5 comments

The https://github.com/tree-sitter/tree-sitter-swift repository's README says the repo is abandoned and one should use https://github.com/alex-pinkus/tree-sitter-swift instead.

This PR changes the repository reference to match.

script/compile and script/test is working 👍

Edit: Noticed the issue; fixes #72

DivineDominion avatar Sep 08 '22 11:09 DivineDominion

Looks like this is failing on this test

jsmestad avatar Sep 10 '22 19:09 jsmestad

Those tests are failing because the grammar only supports emojis when compiled using tree-sitter version 0.20.5 or newer. I recall from previous discussions that emacs-tree-sitter uses 0.19.5, so I think that's expected.

alex-pinkus avatar Sep 11 '22 19:09 alex-pinkus

I'm pretty new with all things tree-sitter, so any advise from you how to best resolve the situation? E.g. wait for emacs-tree-sitter to update the dependency before considering to merge this?

DivineDominion avatar Sep 12 '22 10:09 DivineDominion

Conversely, I'm pretty new to how the emacs-tree-sitter plugin works :)

Apart from not supporting emojis, the grammar behaves totally fine against older tree-sitter versions; there should be no issues merging this if there's some way to ignore those specific tests. It would still be a big improvement over what users are getting out-of-the-box today.

If it's not possible to ignore specific tests, I wonder if you could skip all of them; I run tests on every commit in CI and I still test highlight queries against 0.19.0, so the chance of breakage seems quite low.

This would also be a good reason to upgrade to a newer tree-sitter version, but I don't know what that entails :)

alex-pinkus avatar Sep 20 '22 03:09 alex-pinkus

I've been using it for few weeks and it works great.

@alex-pinkus added some more keywords for highligtning. To get them themable we need to define them:

(defface tree-sitter-hl-face:repeat
  '((t :inherit tree-sitter-hl-face:keyword
       :foreground "#666bb2"))
  "Face for loops (for, in etc)."
  :group 'tree-sitter-hl-faces)

(defface tree-sitter-hl-face:parameter
  '((t :inherit tree-sitter-hl-face:label
       :foreground "#666bb2"))
  "Face for parameters in function calls."
  :group 'tree-sitter-hl-faces)

(defface tree-sitter-hl-face:conditional
  '((t :inherit tree-sitter-hl-face:property
       :foreground "#666bb2"))
  "Face for if/switch."
  :group 'tree-sitter-hl-faces)

(defface tree-sitter-hl-face:include
  '((t :inherit tree-sitter-hl-face:property
       :foreground "#666bb2"))
  "Import/include face."
  :group 'tree-sitter-hl-faces)

(defface tree-sitter-hl-face:boolean
  '((t :inherit tree-sitter-hl-face:property
       :foreground "#666bb2"))
  "Face for true/false."
  :group 'tree-sitter-hl-faces)

(defface tree-sitter-hl-face:keyword.return
  '((t :inherit tree-sitter-hl-face:property
       :foreground "#666bb2"))
  "Face for 'return'."
  :group 'tree-sitter-hl-faces)

(defface tree-sitter-hl-face:keyword.operator
  '((t :inherit tree-sitter-hl-face:property
       :foreground "#666bb2"))
  "Face for operator."
  :group 'tree-sitter-hl-faces)

(defface tree-sitter-hl-face:keyword.function
  '((t :inherit tree-sitter-hl-face:property
       :foreground "#666bb2"))
  "Face for 'func' keyword."
  :group 'tree-sitter-hl-faces)

I don't know where they belong, I've written my own "swift-mode" extensions that loads them the first time I enter a swift-buffer (along with setup of LSP (eglot). The foreground color is just a dummy though.

konrad1977 avatar Sep 20 '22 05:09 konrad1977

We should probably update the tree-sitter version used in the CI. It requires a bit of rework of our test script. Let me see if I can get to that soon ish :D.

meain avatar Nov 27 '22 04:11 meain

Can you rebase this so the CI can test it? Thanks!

jcs090218 avatar Sep 04 '23 04:09 jcs090218

@jcs090218 Done. Updates the submodule HEAD as well

DivineDominion avatar Sep 04 '23 07:09 DivineDominion

Thank you!

jcs090218 avatar Sep 04 '23 09:09 jcs090218