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 Elm and C# to emacs-tree-sitter #79

Closed
wants to merge 3 commits into from

Conversation

theothornhill
Copy link
Contributor

Hello!
As a first step to fix emacs-csharp/csharp-mode#201 I think it is a good idea to add support for emacs-tree-sitter to csharp-mode. I also added elm-mode since I'm also working on a major mode for that one. I hope I understood your documentation correctly. If not, please point me in the proper direction, and I will amend the changes provided here.

Have a nice day!

@theothornhill
Copy link
Contributor Author

I’ve added a revision now, hopefully we are good to go?

As a side note: when building queries for these languages, should they be put here or in their respective major modes?

@shackra shackra added the enhancement New feature or request label Dec 11, 2020
@theothornhill
Copy link
Contributor Author

theothornhill commented Dec 11, 2020

I changed symbol name to underscore, and it seems to work, however, I saw you added another commit to deal with this? Should I revert that last commit? 😄

Edit: I'm getting confused :P rebased on you latest master, rolling back to not using c_sharp, but can't get it to work now. I'm guessing it is supposed to be underscores?

Add sources for tree-sitter-elm as well as registering it for elm-mode
@ubolonton
Copy link
Collaborator

I’ve added a revision now, hopefully we are good to go?

Yes, I'll make a release for tree-sitter-langs and then merge the PR this weekend. (The merge needs to happen after the release, so that the binaries are published before the latest code asks for them.)

As a side note: when building queries for these languages, should they be put here or in their respective major modes?

They should be in the major mode. It's briefly explained in #70 (comment). The main reason a major mode would need tree-sitter-langs is not the queries, but the pre-compiled binaries, which are a hassle to make.

I changed symbol name to underscore, and it seems to work, however, I saw you added another commit to deal with this? Should I revert that last commit? 😄

Yeah, you should use hyphen. I added that fix for this PR.

Edit: I'm getting confused :P rebased on you latest master, rolling back to not using c_sharp, but can't get it to work now. I'm guessing it is supposed to be underscores?

What was the error? With that commit this PR works for me.

@theothornhill
Copy link
Contributor Author

I’ve added a revision now, hopefully we are good to go?

Yes, I'll make a release for tree-sitter-langs and then merge the PR this weekend. (The merge needs to happen after the release, so that the binaries are published before the latest code asks for them.)

Great!

As a side note: when building queries for these languages, should they be put here or in their respective major modes?

They should be in the major mode. It's briefly explained in #70 (comment). The main reason a major mode would need tree-sitter-langs is not the queries, but the pre-compiled binaries, which are a hassle to make.

Ok, I've opened a new branch in csharp-mode

I changed symbol name to underscore, and it seems to work, however, I saw you added another commit to deal with this? Should I revert that last commit? smile

Yeah, you should use hyphen. I added that fix for this PR.

Ok, adding back the hyphen!

Edit: I'm getting confused :P rebased on you latest master, rolling back to not using c_sharp, but can't get it to work now. I'm guessing it is supposed to be underscores?

What was the error? With that commit this PR works for me.

When

;;; Link known major modes to languages in the bundle.
(pcase-dolist
    (`(,major-mode . ,lang-symbol)
     (reverse '((agda-mode       . agda)
                ;; ...
                (csharp-mode     . c-sharp) ;; <-- with hyphen
                ;; ...
                (tuareg-mode     . ocaml)
                (typescript-mode . typescript))))
  (setf (map-elt tree-sitter-major-mode-language-alist major-mode)
        lang-symbol))

I get File mode specification error: (error Cannot find shared library for language: c-sharp) when loading. But that might be load order etc. The .so file in bin is c_sharp.so

I'll just add another commit with hyphens everywhere, and you can take it from there?

Add csharp-mode as a major mode for editing C#
@theothornhill
Copy link
Contributor Author

I updated the hash to the new release that came yesterday - 4.4.1

@ubolonton
Copy link
Collaborator

ubolonton commented Dec 15, 2020

That commit required publishing a new version of, or rebuilding tree-sitter-langs.

I added a new commit that changes tree-sitter so that it can load c-sharp from a previously-published version of tree-sitter-langs as well.

It should work now, even before I publish the new binaries for tree-sitter-langs. I'll do that soon.

@ubolonton
Copy link
Collaborator

I published new binaries, rebased your commits and merged them.

Closing this manually as GitHub doesn't seem to handle rebased commits correctly.

@ubolonton ubolonton closed this Dec 16, 2020
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using tree-sitter in csharp-mode?
3 participants