neocmakelsp icon indicating copy to clipboard operation
neocmakelsp copied to clipboard

[feature] working with fileapi

Open daniilrozanov opened this issue 10 months ago • 7 comments

We already have cool plugin that allows to build and run project based on cmake. Unfortunately it doesn't support navigation through project from the perspective of cmake. I mean, sometimes you want to list all your targets, or only executable or static libs. Maybe you want to jump to its definition, or list all targets that use current file. Not only targets, but projects, directories and other sometimes you may want to navigate through.

For all of that, lsp server needs to read fileapi reply at <build>/.cmake/api/v1/reply. Because of inside fileapi's codemodel json contains path to source, plugin can be initialised as it doing now. But additionally it will be able to support much more requests from client.

My idea is it to add ability to pass to root_dir the <build>/.cmake/api/v1/reply path. So pipeline would be cmake-tools generates project -> neocmake starts at reply dir -> getting list of targets or projects or whatever from neocmake -> go to or build target with cmake-tools or show by telescope or whatever.

I understand it is a big new feature, so at least, what to you think about it?

daniilrozanov avatar Apr 14 '24 02:04 daniilrozanov

Sure, I will work on that!!

Decodetalkers avatar Apr 14 '24 09:04 Decodetalkers

@Decodetalkers Cool, thank you! Then I propose to discuss new possibilities in this thread. I tried to write a plugin that would allow similar actions, but then I thought that it would be better to have this functionality in the LSP server and then make PR to cmake-tools.nvim to support them. Unfortunately I don't know Rust, but as I imagine some of the new features will be an extension of LSP. I definitely can write some plugin similar to clang_extension to support new features.

daniilrozanov avatar Apr 14 '24 11:04 daniilrozanov

Emm. I cannot find the .cmake folder, where is it?

Decodetalkers avatar Apr 14 '24 12:04 Decodetalkers

@Decodetalkers You need to create it. Actually, not .cmake, but query file. One option is

cmake -E capabilities | jq '.fileApi' > <build>/.cmake/api/v1/query/client-<client>/query.json

After that, if you run cmake -B <build>, all possible files will be created by cmake in <build>/.cmake/api/v1/reply

daniilrozanov avatar Apr 14 '24 12:04 daniilrozanov

<client> is any string. cmake -E capabilities output contains all possible kinds of replies supported by your cmake version. Note, this feature released since cmake 3.15, i suppose this is not an issue. More details in doc

daniilrozanov avatar Apr 14 '24 13:04 daniilrozanov

https://github.com/Decodetalkers/neocmakelsp/pull/91

Decodetalkers avatar Jul 26 '24 11:07 Decodetalkers

now I am working on collect cache.. but I do not understand other files very much...

Decodetalkers avatar Jul 26 '24 11:07 Decodetalkers