neoclide / coc-tsserver

Tsserver extension for coc.nvim that provide rich features like VSCode for javascript & typescript
MIT License
1.05k stars 68 forks source link

`<Plug>(coc-funcobj-i)` can't recognize getter/setter functions #371

Closed persytry closed 1 month ago

persytry commented 2 years ago
xmap if <Plug>(coc-funcobj-i)
omap if <Plug>(coc-funcobj-i)
xmap af <Plug>(coc-funcobj-a)
omap af <Plug>(coc-funcobj-a)

Above four map cannot work for getter/setter functions. .eg typescript

get fn():number{
    return 1;
}
set fn(v:number){
   this.v = v;
}
persytry commented 2 years ago
class c{
    constructor(){
        ...
    }
}

The function constructor cannot to be recognized either.

chemzqm commented 2 years ago

It's expected since they're reported as properties. Use other tools tree-sister might helps

persytry commented 2 years ago

I understand tree-sister and COC do similar things, but I prefer the COC approach. I don't think it's worth introducing another language parser because of this one problem. Getters, setters, and constructor methods are treated only as properties, which I don't think makes sense; they should be both properties and functions (or methods). If they can be thought of as functions (or methods), then they aren't can't fix, are they?