Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Language is either not supported or WIP... c++mode #2

Open
marlinstrub opened this issue Nov 4, 2022 · 7 comments
Open

Language is either not supported or WIP... c++mode #2

marlinstrub opened this issue Nov 4, 2022 · 7 comments

Comments

@marlinstrub
Copy link

This package looks very promising. When I try ts-docstr-at-point I get the error Language is either not supported or WIP... c++mode.

I load tree-sitter and ts-docstr as follows:

(use-package tree-sitter
  :straight (tree-sitter :host github :repo "emacs-tree-sitter/elisp-tree-sitter"))

(use-package tree-sitter-langs
  :straight (tree-sitter-langs :host github :repo "emacs-tree-sitter/tree-sitter-langs"))

(use-package msgu
  :straight (msgu :host github :repo "jcs-elpa/msgu"))

(use-package ts-docstr 
  :straight (ts-docstr :host github :repo "emacs-vs/ts-docstr"))

I then visit a cpp file and call M-x ts-docstr-at-point on a function.

Am I doing this wrong?

@jcs090218
Copy link
Member

Make sure you have tree-sitter-mode enabled in your buffer!

@marlinstrub
Copy link
Author

Ah my bad, I had indeed misconfigured tree-sitter. I think it's setup correctly now, at least syntax highlighting works with it.

I'm not sure if I'm using this package correctly though. Let me try to explain what I'm doing. I created a test file with the following content:

ss1

If I insert a new line above line 1 and type M-x ts-docstr-at-point I get the following:

ss2

If I then place the cursor on line 7 (above auto baz ...) and type M-x ts-docstr-at-point again, nothing happens.

I noticed that the syntax highlighting is wrong after the first invocation of ts-docstr-at-point. I can fix it by temporarily removing the second star of the opening comment identifier (/**). If I do that and then place the cursor on line 7 and type M-x ts-docstr-at-point again, another comment is inserted:

ss3

Notice how the syntax highlighting of that second comment is wrong again.

I observe the same behaviour when I try with emacs -Q and load only the relevant packages. I'm on emacs version 29.0.50 (commit 8a5678906f).

Any pointers on how to fix this behaviour are much appreciated!

@jcs090218
Copy link
Member

Yeah, I have the same experience and I suspect the issue is from the upstream tree-sitter-langs. I think if you edit buffer with or without this package you will experience something like that (any packages/operations that modified the buffer directly). Can you try and confirm the behavior?

Emacs devel is working on built-in tree-sitter, so I'm not quite sure the route of all tree-sitter packages (ts-docstr, ts-fold, tree-sitter-langs, etc). I think we will eventually replace all Elisp API with the built-in one. Then I guess this issue will then be resolved?

@marlinstrub
Copy link
Author

Mhh. I don't use many packages that directly edit the buffer, but yasnippet works, for example. Did you have a particular package in mind that you wanted me to test?

I agree that it could well be a problem with upstream tree-sitter.

@nicodebo
Copy link

nicodebo commented Nov 7, 2022

I think I have the same issue on python. After M-x ts-docstr-at-point the syntax highlighting seems to be broken in the whole buffer. After saving, the syntax highlighting is back to normal.

@jcs090218
Copy link
Member

We might need to refresh the AST or font-lock highlighting after the insertion.

@ratnesh1729
Copy link

Thanks for the library. I face the same issue for python mode

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants