Open vid512 opened 3 months ago
Thanks for the heads-up @vid512.
I will try to update the plugin when I have time to use meson compile
. At the time of writing this plugin there were no such command :)
Currently you can try the following workaround. Just add the following line to your .vimrc
.
let g:meson_ninja_command = 'meson compile'
It was easier than I thought.
@vid512, please try the latest version. I only tested this on Linux.
Nope. Now :make
vim command tries to execute :!make 2>&1 | tee ...
. Even if I define g:meson_ninja_command
to meson compile
, same thing happens.
Mesonic seems to be loaded correctly. The g:meson_loaded
is true, commands like :MesonTest
work fine.
(BTW, do you know how I can copy output of Vim command to clipboard, so I can paste it here? )
Also providing :MesonCompile
, just like with other meson commands, would maybe be nice. It was my first intuition to try, after learning about other :MesonXxx commands.
More info: This problem seenm only to happen if the source file being edited is inside subdirectory. When the .cpp file is in same directory as meson.build, :make
works correctly and executes meson compile
When the .cpp file is in same directory as meson.build, :make works correctly and executes meson compile
@vid512 You are supposed to open all files from the root of your project 😀 This is how most Vim plugins work. There is simply no way of automatically determining where is the root of the project because meson.build
can be nested.
Nope. Now :make vim command tries to execute :!make 2>&1 | tee .... Even if I define g:meson_ninja_command to meson compile, same thing happens.
This means mesonic
has not found meson.build
file in the current directory. Is there such a file?
Also providing :MesonCompile, just like with other meson commands, would maybe be nice. It was my first intuition to try, after learning about other :MesonXxx commands.
I can do that for the sake of less confusion, but it will not solve your problem I guess. Also there is no :Ninja
command because it is run automatically much like meson compile
.
(BTW, do you know how I can copy output of Vim command to clipboard, so I can paste it here? )
Depends on the terminal you use. I do not work with Windows much. In Alacritty this should be ctrlshiftc.
You are supposed to open all files from the root of your project 😀 This is how most Vim plugins work.
I was under impression that mesonic
scans parent directories looking for meson.build, to allow running in subdirectories. I'm not sure anymore, how I got this idea. Just starting experimenting with higher-level IDE-like Vim plugins, so this wasn't obvious to me.
Is this assumption required only during mesonic
setup, or does it expect that current working directory == project root during later actions as well? I am thinking of writing some kind of wrapper over plugin(s) initialization, that would use the correct root directory. At least to get some experience with lua vim scripting.
There is simply no way of automatically determining where is the root of the project because meson.build can be nested.
What could go wrong if topmost meson.build was assumed to be project root?
Depends on the terminal you use. I do not work with Windows much.
I meant a way in Vim itself giving you access to command output (eg. if it is longer than terminal can display at once).
I was under impression that mesonic scans parent directories looking for meson.build, to allow running in subdirectories.
Yes that is correct. It was so long ago I don't remember :) However, you still need meson.build
in the current directory to activate the plugin.
What could go wrong if topmost meson.build was assumed to be project root?
After checking the code I can confirm it works like this. Although this does not cover 100% cases.
I meant a way in Vim itself giving you access to command output (eg. if it is longer than terminal can display at once).
If you're talking about :make
output :copen
should open the window with the output. For :!cmd
the best way is to redirect to a file via shell.
What are your thoughts about always running this lookup, even if meson.build
is not in current dir?
If this is a problem speed-wise (especially when opening files outside meson project), then maybe there could be a user-configurable maximum "depth" for this initial lookup. This could be defaulted to small-enough value (like 5 directories up). Or it could even be defaulted to 0, and only enabled by users who desire this functionality.
When building with mesonic
:make
command, it tries to executeninja
executable directly (from current PATH on Windows), regardless of whatninja
executable the meson build was configured to use.Particulary on Windows, where meson can autodetect compiler, it is possible that there is no ninja present in path. Or one can have different build directories, each configured to use different ninja executable, from different Visual Studio installation, etc.
IMO mesonic shouldn't ignore this part of Meson setup and shouldn't invoke ninja directly. The correct approach should be to use
meson compile
command, and let it do whatever it is configured to do. Or at least support:MesonCompile
Vim command, which usesmeson compile
, for cases where the difference matters.Set up build and compile from command line:
When I open foo.cpp in Vim and use
:make
, it tries to execute a:!ninja ...
command. But because ninja.exe is not in path, I getshell returned 255
, andE40: Can't open errorfile ...
. (sorry for not giving full log, I don't know how to copy command output from Vim)