cscope_maps.nvim icon indicating copy to clipboard operation
cscope_maps.nvim copied to clipboard

Become LSP Provider

Open xdavidel opened this issue 11 months ago • 11 comments

I'm really glad I was able to find this awesome plugin! I was just doing some searching before writing my own solution to this problem.

My way of thinking led me to think about creating an LSP server for cscope DBs so it can be use alongside clangd or some other provider.

Would you be interested in this kind of change?

Either way - this is a cool solution and I'm definitely using it from now on.

xdavidel avatar Feb 27 '24 21:02 xdavidel

hey @xdavidel I'm not familiar with creating LSP server. Can you elaborate your idea? do you mean something like #23?

dhananjaylatkar avatar Feb 28 '24 15:02 dhananjaylatkar

An LSP is somewhat different than an autocomplete provider.

It actually has to implement the features of the protocol - so the end result might give both results from clangd and cscope if both of them are attach. That way we can use the built-in vim.lsp.buf.references with no worries.

Also about making the server - I thought it might be possible to use an approach like none-ls and hook into the LSP features instead of writing a server.

I realize this could take a lot and and your solution works perfectly (actually started using it today), but I was crious to hear if this sounds like something worth investing into.

xdavidel avatar Feb 28 '24 19:02 xdavidel

Thanks.

Didn't they stop null-ls because it was getting hard to manage?

Anyway I'll look into it and see if it's feasible.

dhananjaylatkar avatar Feb 29 '24 09:02 dhananjaylatkar

I second this approach as well. I think not only would it allow us to use the same conventional LSP mappings, but also allow faster & more concentrated navigation because cscope sounds more like conventional copen with grep, except for the speed of course.

kqvanity avatar Apr 29 '24 07:04 kqvanity

Hi @xdavidel / @xquilt cscope_lsp can only support following actions if implemented -

vim.lsp.buf.incoming_calls()  [callHierarchy/incomingCalls]
vim.lsp.buf.outgoing_calls()  [callHierarchy/outgoingCalls]
vim.lsp.buf.definition()      [textDocument/definition]
vim.lsp.buf.references()      [textDocument/references]

Would that be enough to call it "lsp"?

dhananjaylatkar avatar Apr 30 '24 18:04 dhananjaylatkar

Hi @xdavidel / @xquilt cscope_lsp can only support following actions if implemented -

vim.lsp.buf.incoming_calls()  [callHierarchy/incomingCalls]
vim.lsp.buf.outgoing_calls()  [callHierarchy/outgoingCalls]
vim.lsp.buf.definition()      [textDocument/definition]
vim.lsp.buf.references()      [textDocument/references]

Would that be enough to call it "lsp"?

Well, according to the capabilities documentation I would argue Yes.

Seems to me other capabilities can be achieve using some work and combine with clangd / ccls / etc. we will have a complete solution.

xdavidel avatar Apr 30 '24 20:04 xdavidel

cool. i'll start the implementation

dhananjaylatkar avatar May 01 '24 04:05 dhananjaylatkar

@xdavidel / @xquilt

I have implemented definition support.

Try it out and provide feedback

https://github.com/dhananjaylatkar/cscope_lsp

dhananjaylatkar avatar May 03 '24 19:05 dhananjaylatkar

@xdavidel / @xquilt

I have implemented definition support.

Try it out and provide feedback

https://github.com/dhananjaylatkar/cscope_lsp

That was quick. Will try that ASAP.

P.S: kudos for using TJs starting point for LSP

xdavidel avatar May 04 '24 18:05 xdavidel

@dhananjaylatkar Thanks for the work. I've tested it on a dir composed of multiple Android projects and it does work, but there are a couple of gotcha

  • It won't return definitions if the symbol doesn't have an import directive within the same file
  • Definitions aren't confined to the project's root dir

I was wondering if go is your language of choice or if is it just because of the skeleton project by TJ. If you can consider Rust, I'd love to contribute to the project

kqvanity avatar May 04 '24 18:05 kqvanity

@xquilt

Thanks for testing.

Can you open issues on cscope_lsp repo? We can discuss there.

Yeah, this is the first time I'm writing a "big" golang project. But also I've been looking for an opportunity to write golang so it works out for me.

I don't see any upside of moving to Rust and I prefer the simplicity of golang so, I won't be doing rewrite in Rust anytime soon.

dhananjaylatkar avatar May 04 '24 19:05 dhananjaylatkar

Closing this issue.

See https://github.com/dhananjaylatkar/cscope_lsp

dhananjaylatkar avatar May 18 '24 12:05 dhananjaylatkar