Coc.nvim: Support call hierarchies

Created on 11 Mar 2020  路  11Comments  路  Source: neoclide/coc.nvim

Is your feature request related to a problem? Please describe.

No problem other than tracking feature parity with tsserver (here is the companion issue for coc-tsserver) and VSCode.

Describe the solution you'd like

Support for retrieving call hierarchies in tree form for named callables.

class MainThing {
  static do() {
    utilA();
  }
}

//    X-- cursor 
const doLotsOfThings () => {
  MainThing.do();
  utilB();
}

// 
// :CocList callHierarchy --maxDepth 3

OUTPUT

--------------------------------------------------------------
doLotsOfThings()
  calls
    MainThing.do()
      utilA()
    utilB()
  is called by
    Scheduler.run

I believe the minimal required UI would be list-based, similar to the 'outline' list. It could take a "max depth" argument to control the indentation.

Actions on list items might include:

  • go to definition
  • get references
  • re-request hierarchy using same args but with this callable as the root.

Describe alternatives you've considered

I _think_ you could do this with existing LSP features in a coc extension, but without language-server-level support there would likely be a problem with N+1 queries.

Additional context

I'm not sure which API the project's maintainers prioritize, that of VSCode, Microsoft's LSP spec, or both. So I'm likewise unsure how important it is that as of this writing, the proposal issue has yet to be adopted by Microsoft, though the latest release of VSCode supports it.

enhancement

Most helpful comment

Sure, we will add support for call hierarchies, we need create a module for tree view at first.

All 11 comments

Sure, we will add support for call hierarchies, we need create a module for tree view at first.

Last year I made a module for tree view (pure VimL), you can copy it if you think it is useful (it is MIT licensed). I would love to see call hierarchies supported directly in coc.nvim.

https://github.com/lambdalisue/fern.vim is a general purpose tree viewer, but in beta stage.

It's asynchronous and pure vimscript too. I too vote for fern. I beg to not reinvent the wheel like you did with coc-lists.

It's bad idea to bind it with other vim plugin for some feature to work.

Sure, we will add support for call hierarchies, we need create a module for tree view at first.

Sorry then, I got the quoted part that you want exactly that.

It's bad idea to bind it with other vim plugin for some feature to work.

You can copy and reuse the source I linked to implement your internal view module, if you think it can save some work. No external dependency. A copy of that code in used also inside vim-lsp to visualise hierarchies here.

It's asynchronous and pure vimscript too. I too vote for fern. I beg to not reinvent the wheel like you did with coc-lists.

So it is the code I linked, with the difference that mine is not in alpha stage (it's used in production in two vim plugins) and it is completely standalone, it does not use Vital.

Having support for this would be great. I know in coc-metals we ended up building this in from scratch to account for the Metals Tree View Protocol

look forward to using this feature too, pls support it

Me too!

yes really need call hierarchy thank you

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ctaylo21 picture ctaylo21  路  4Comments

cvlmtg picture cvlmtg  路  3Comments

aareman picture aareman  路  3Comments

iago-lito picture iago-lito  路  3Comments

npearson72 picture npearson72  路  3Comments