Comments (8)
Imenu support would be really great
from elisp-tree-sitter.
I still haven't looked into #199 in details, but like @mohkale noted in that issue, I think arbitrary recursion is the single biggest challenge, specifically capturing the full paths of all nested items, not just the leaf identifiers. Queries alone are probably not expressive enough, so some sort of principled extension would be needed. On that front, I think it's worth exploring the newly introduced stack graphs, and the related graph DSL:
(function_definition
name: (identifier) @name) @function
{
node @function.def
attr (@function.def) kind = "definition"
attr (@function.def) symbol = @name
edge @function.containing_scope -> @function.def
}
I went through associated StrangeLoop talk. @dcreager illustrated the concepts very well.
from elisp-tree-sitter.
Hi! I was playing around with this to try and see what kind of imenu integration I can get going, but I am getting a (wrong-type-argument user-ptrp nil)
when running a test function, with the following stacktrace:
ts-make-query(nil [(function_item (identifier) @name)])
tree-sitter-query([(function_item (identifier) @name)])
(seq-map #'(lambda (capture) (let* ((x474 (car capture)) (x475 (cdr capture))) (let ((node x475)) (progn (print ts-node-text node) (cons (ts-node-text node) (ts-node-start-position node)))))) (tree-sitter-query [(function_item (identifier) @name)]))
(save-current-buffer (set-buffer (current-buffer)) (seq-map #'(lambda (capture) (let* ((x474 (car capture)) (x475 (cdr capture))) (let ((node x475)) (progn (print ts-node-text node) (cons ... ...))))) (tree-sitter-query [(function_item (identifier) @name)])))
ts-identifiers()
It seems that the error is coming from within the Rust module? So I am not sure how I should go about to debug.
For reference, this is what the function I'm testing looks like:
(defun ts-identifiers()
(interactive)
(with-current-buffer (current-buffer)
(seq-map (lambda (capture)
(pcase-let ((`(_ . ,node) capture))
(print ts-node-text node)
(cons (ts-node-text node) (ts-node-start-position node))))
(tree-sitter-query [(function_item (identifier) @name)])))
)
from elisp-tree-sitter.
This line ts-make-query(nil [(function_item (identifier) @name)])
means that tree-sitter-language
was nil when tree-sitter-query
called ts-make-query .
It probably means tree-sitter-mode
was not turned on in that buffer.
Also note that tree-sitter-query
is more like a debugging aid currently. It creates a new query object every time. You'd better off create a query object once, and use ts-query-matches
or ts-query-captures
instead.
from elisp-tree-sitter.
I see. Got it working again, thanks! Will start experimenting and move towards using tree-query-matches
to get imenu integration working.
from elisp-tree-sitter.
I'm interested in implementing this. Do you have any tips for how to approach it? I was thinking maybe reusing the queries we use for highlighting (in emacs-tree-sitter/tree-sitter-langs
) or adding a new file in the same place for imenu queries.
from elisp-tree-sitter.
@DamienCassou See #199. It's still at the draft stage and I'm not sure what the best approach moving forward should be :/.
from elisp-tree-sitter.
Hi! Is there any update on this feature? Thanks :)
from elisp-tree-sitter.
Related Issues (20)
- Doesn't highlight Rust documentation code examples
- Swift support, revisited. HOT 1
- wrong ELF class: ELFCLASS64 on RPI4 HOT 1
- `Unsupported Operating System: OpenBSD` HOT 7
- bin/build not work on linux because builtin cd will output the folder name. HOT 1
- tree-sitter languages download of windows binaries failed with error
- tsc-lang-abi-too-new when installing new language HOT 11
- Crash when large file contains an ERROR node
- Invalid version syntax: ‘[email protected] HOT 2
- Colors look wrong in haskell mode. HOT 3
- `tree-sitter-debug-mode` is broken
- Crash when loading one particular Markdown file HOT 7
- Reporting Vulnerability
- (ts-fold-indicators-mode) not working when running emacs from terminal
- How do I add a new grammer to this mode? HOT 2
- why the submodule langs pointed to an old commit?
- tree-sitter-hl-mode doesn't honor the :extend font face in single line comments HOT 1
- request to rebuild tsc-dyn.so with older Linux OS
- Provide `aarch64` build of `tsc-dyn.so` for AArch64 Linux
- Repetitions and Predicate Problems
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from elisp-tree-sitter.