Closed hugoArregui closed 1 year ago
Hmm, I am not able to repro it. Is this just for typescript-ts-mode
or all treesit modes? Also, how are you installing the package?
Very sorry, I tried in a clean installation and I was not able to reproduce it either, it's obviously something from my config, will try to debug it. Thank you!
Also running into this, pointers would be appreciated. evil-textobj-tree-sitter
config -
(use-package evil-textobj-tree-sitter
:after evil
:straight t
:config
;; bind `function.outer`(entire function block) to `f` for use in things like `vaf`, `yaf`
(define-key evil-outer-text-objects-map "f" (evil-textobj-tree-sitter-get-textobj "function.outer"))
;; bind `function.inner`(function block without name and args) to `f` for use in things like
(define-key evil-inner-text-objects-map "f" (evil-textobj-tree-sitter-get-textobj "function.inner")))
Running against a simple JS file:
function foo(bar) {
console.log(bar);
}
function foo2(bar) {
console.log(bar);
}
function foo3(bar) {
console.log(bar);
}
Where I know tree-sitter is working (output is from treesit-explore-mode
):
(program
(function_declaration function name: (identifier)
parameters: (formal_parameters ( (identifier) ))
body:
(statement_block {
(expression_statement
(call_expression
function: (member_expression object: (identifier) . property: (property_identifier))
arguments: (arguments ( (identifier) )))
;)
}))
(function_declaration function name: (identifier)
parameters: (formal_parameters ( (identifier) ))
body:
(statement_block {
(expression_statement
(call_expression
function: (member_expression object: (identifier) . property: (property_identifier))
arguments: (arguments ( (identifier) )))
;)
}))
(function_declaration function name: (identifier)
parameters: (formal_parameters ( (identifier) ))
body:
(statement_block {
(expression_statement
(call_expression
function: (member_expression object: (identifier) . property: (property_identifier))
arguments: (arguments ( (identifier) )))
;)
})))
When I then run yif
while inside of one of the functions above, I get the output Wrong type argument: treesit-query-p, nil
.
If it helps, I've also linked to my current config here: https://github.com/lararosekelley/emacs.d
It's a work in progress but the other Evil/Tree-sitter related things seem to be working, just trying to nail this one down!
@lararosekelley what is the major mode of the buffer for the JS code?
If you are using js-ts-mode
, it is likely that https://github.com/meain/evil-textobj-tree-sitter/commit/bce236e5d2cc2fa4eae7d284ffd19ad18d46349a has fixed your issue.
That sounds right then! Thank you for the quick reply :pray:
I'm using typescript with typescript-ts-mode and I defined the text objects suggested in the doc:
but I get the error
evil-textobj-tree-sitter--treesit-get-nodes: Wrong type argument: treesit-query-p, nil
every time I try to do something with the object. I'm using emacs 29.1 with the built in tree-sitter implementation.Thanks!