neoclide / coc.nvim

Nodejs extension host for vim & neovim, load extensions like VSCode and host language servers.
Other
24.42k stars 953 forks source link

Support call hierarchies #1649

Closed MattSPalmer closed 3 years ago

MattSPalmer commented 4 years ago

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:

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.

chemzqm commented 4 years ago

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

m-pilia commented 4 years ago

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.

hoschi commented 4 years ago

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

vn-ki commented 4 years ago

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.

chemzqm commented 4 years ago

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

hoschi commented 4 years ago

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.

m-pilia commented 4 years ago

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.

ckipp01 commented 4 years ago

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

yyb196 commented 4 years ago

look forward to using this feature too, pls support it

HackerQacker commented 4 years ago

Me too!

ssh352 commented 3 years ago

yes really need call hierarchy thank you

pidgeon777 commented 3 years ago

I'm also interested in a call tree viewer, too.