vscode-meson icon indicating copy to clipboard operation
vscode-meson copied to clipboard

Intellisense not listing files when plugin active

Open markmaker opened this issue 10 months ago • 8 comments

Description

Intellisense does not seem to list the project C/C++ files correctly, when under control of the meson plugin. It only sees files currently open in the IDE, or #include-d by the open files. "Go to Definition", "Find All References" etc. only work in that limited scope.

As soon as I deactivated the plugin it started to work again.

Our workspace is special in that the meson project is in a subdirectory (actually a git submodule). Maybe that could be the reason. The meson build commands work correctly, and the project is still correctly shown in the tree. But Intellisense is broken.

markmaker avatar Mar 26 '24 15:03 markmaker

Sounds pretty special to your environment. A language server is only going to be useful for the files it knows about, those in the compilation database.

tristan957 avatar Mar 27 '24 14:03 tristan957

Sounds pretty special to your environment.

I don't know how you mean that. I consider it perfectly normal to have the main meson project in a subdirectory, especially since this is a git submodule that covers the C/C++ part of a larger project.

The Meson sidebar discovers the project perfectly:

Side Bar

The build comands work:

Meson: build

But IntelliSense is broken, as described above. When I enable the Meson plugin, I get this "Configuration Provider" set in Extensions > C/C++ > IntelliSense:

Configuration Provider

Then it no longer works. And I can't change the value, it is always set back to "mesonbuild.mesonbuild".

However, I just found how to disable that. Add this to .vscode/settings.json

"mesonbuild.modifySettings": false,

This seems to make it behave.

Still, this appears to be a bug.

markmaker avatar Mar 27 '24 18:03 markmaker

What does "intellisense not listing files" mean?

tristan957 avatar Mar 27 '24 19:03 tristan957

Somehow IntelliSense needs to know which .cpp files to scan. I assumed it will use the builddir/compile_commands.json 'file' entries. I set the C_Cpp › Default: Compile Commands correctly, but somehow it is not used by IntelliSense, or at least not to list the files, as long as "Configuration Provider" is set to "mesonbuild.mesonbuild".

markmaker avatar Mar 27 '24 20:03 markmaker

How do you know it isn't used?

tristan957 avatar Mar 27 '24 20:03 tristan957

Like I initially described, "Go to Definition", "Find All References" etc. only work in the limited scope of opened files. As soon as I remove Meson plugin from the equation, either by disabling it, or by "mesonbuild.modifySettings": false, (and restarting the IDE), IntelliSense starts to scan all files. "Go to Definition", "Find All References" etc. start to work.

markmaker avatar Mar 27 '24 21:03 markmaker

I don't understand your project layout. Do you have C/C++ files outside of the submodule that you're trying to use "Go to Definition" or "Find All References" on?

tristan957 avatar Mar 27 '24 21:03 tristan957

There is a toplevel project, that contains various git submodules. The submodules cover different technologies and/or programming languages. One of them is a C/C++ project with a meson.build file.

-- top
  |-- cpp project
  |  |-- meson.build
  |  |-- subprojects
  |  |   ` - various
  |  |-- src
  |     |-- file1.cpp
  |     |-- file2.cpp
  |-- other stuff

This should be a normal use case.

And like I said: the other functions like building or showing the project tree, work.

markmaker avatar Mar 27 '24 21:03 markmaker