deaddyfreddy · 2022-07-12 19:08
you may like functions/macros like `pcase-lambda`, `null`, `when`, `seq-filter`, `-keep` and `thread-last`. `major-mode`: `query` could be a `defcustom` alist (so you don't have to edit code to add new modes). `<` and `>` are multi-arity functions,
meain · 2022-07-12 19:37
Aah yup, I really got to improve my lisp-fu quite a bit.
txgvnn · 2022-07-15 14:09
That is amazing! I love showing header line and imenu by using tree-sitter.
I want to switch to use tree-sitter instead of lsp-mode. Will you create a package for that? Example tree-sitter-header name?
meain · 2022-07-15 17:34
I have thought about creating a package around this `tree-sitter-nav`, both navigation and header info. But it might be a while before I get to it though. This blog post only covers how to do this for config file and not necessary code.
I have the code to display the current function and classname using tree-sitter [here](https://github.com/meain/dotfiles/blob/1b3a7260415ff9b351e28a95ba71962621984216/emacs/.config/emacs/init.el#L2287-L2301) in my dotfiles, but have not worked out the imenu part thought it should not be that hard.
As of now, it is kinda usable, but only for the languages that I use(go, python, rust). It might be a bit harder to write all the queries for all languages. Also for things like go, even though interfaces can be treated like an equivalent of a class, picking them up and displaying them along with functions might require some tinkering.
ref: https://blog.meain.io/2022/more-treesitter-emacs/#show-current-class%2Ffunction-name-in-modeline
That said, if you try to set this up from my dotfiles and do run into issues feel free to reach out to me.
txgvnn · 2022-07-16 03:40
I think you can begin a new package with some languages you are supporting. Then everyone (maybe me), who work on their languages, will contribute to the package.
Seems it is very good, if we can create a package in this namespace https://github.com/emacs-tree-sitter
meain · 2022-07-16 07:22
Hmm, I think I will get started with something simple. Now the next problem is my laziness. ;D
txgvnn · 2022-07-18 16:30
Ya, I understand :D. Please let me know if you create any package for that. I'd like to learn about it.
Shivalicious · 2022-07-19 17:36
Looks very useful, and probably a good thing to integrate with [which-function-mode](https://www.emacswiki.org/emacs/WhichFuncMode).
meain · 2022-07-20 04:40
I was using which-func mode for some other usecases, but didn't realize that I could just hook this into that. It would be much cleaner than what I am doing in my current setup. Thank you.
txgvnn · 2022-07-26 02:44
I've just learn how to write queries and I build some queries for languages I use
```
('sh-mode "(function_definition (word) @name) @item")
('go-mode "(type_declaration (type_spec (type_identifier) @name)) @item
(function_declaration (identifier) @name) @item
(method_declaration (field_identifier) @name) @item")
('python-mode "(function_definition (identifier) @name) @item")
```
meain · 2022-07-26 14:54
It is actually much simpler for code:
https://github.com/meain/dotfiles/blob/278f863cb687c63ce3a9e0f419ca5ad16be2da2e/emacs/.config/emacs/init.el#L2391-L2405