Civitasv / cmake-tools.nvim

CMake integration in Neovim
GNU General Public License v3.0
371 stars 64 forks source link

CMakeRun no longer executes the executable #77

Closed allstdcpp closed 1 year ago

allstdcpp commented 1 year ago

Bug description I have just upgrade to the latest version and CMakeRun no longer executes the compiled binary I have been using a simple CMakeLists file which use to work.

cmake_minimum_required(VERSION 3.26) project(avl-tree)

set(CMAKE_CXX_STANDARD 20)

add_executable(avl-tree main.cpp) target_link_libraries(avl-tree PRIVATE -fsanitize=undefined,address) target_compile_options(avl-tree PRIVATE -fsanitize=undefined,address)

I also have a very simple cmake.lua plugin which has also worked before some recent changes in this project.

local M = {}

M.plugin = { "Civitasv/cmake-tools.nvim", config = function() local cmake = require("cmake-tools") cmake.setup({ cmake_command = "cmake", cmake_build_directory = "", cmake_build_directory_prefix = "cmakebuild", cmake_generate_options = { "-D", "CMAKE_EXPORT_COMPILE_COMMANDS=1" }, cmake_generate_on_save = false, cmake_build_options = {}, cmake_console_size = 10, cmake_show_console = true, cmake_variants_message = { short = { show = true }, long = { show = true, max_length = 40 }, }, cmake_quickfix_opts = { show = "always", position = "belowright", size = 10, }, })

    vim.keymap.set("n", "<leader>cg", function()
        vim.cmd.CMakeOpen()
        vim.cmd.CMakeGenerate()
    end)
    vim.keymap.set("n", "<leader>cb", function()
        vim.cmd.CMakeOpen()
        vim.cmd.CMakeBuild()
    end)
    vim.keymap.set("n", "<leader>cr", function()
        vim.cmd.CMakeOpen()
        vim.cmd.CMakeRun()
    end)
    vim.keymap.set("n", "<leader>cc", function()
        vim.cmd.CMakeClose()
    end)
    vim.keymap.set("n", "<leader>cl", function()
        vim.cmd.CMakeOpen()
        vim.cmd.CMakeClean()
    end)
end,

} return M

When you run now a window opens with the following:

cd /usr/home/xxxx/projects/cpp/avl-tree/cmake_build_Debug &&

an the program no longer runs and outputs in this window.

Hope this helps.

Blair

rohit-kumar-j commented 1 year ago

I do not get this error, can you kindly test your project/setup with a previous commit (where it was successful) and update this?

lazy.nvim example:

{
    'Civitasv/cmake-tools.nvim',
    commit = "...",
}

Maybe going back in reverse to a commit that works can reveal the bug.

allstdcpp commented 1 year ago

Works in commit 98ea713. This seems to be broken after the "Multi Terminals and Persistent Buffers" work.

Civitasv commented 1 year ago

Is there a error? Use :messages to see.

rohit-kumar-j commented 1 year ago

I still could not get an error running with your config. Seems like the keymap for <leader>cr might not require vim.cmd.CMakeOpen(). Can you try it without that?

... with just :CMakeRun

hsetlik commented 1 year ago

Getting the same issue, I have my <leader>cr keymap assigned to <cmd>CMakeRun<cr> and the executable isn't launching. @Civitasv I did take a look at :messages but it doesn't show any errors there.

Civitasv commented 1 year ago

I did take a look at :messages but it doesn't show any errors there.

Weird, I wonder if it works if you type :CMakeRun directly?

hsetlik commented 1 year ago

Just tried typing the command directly and it does the same thing as the key binding. The target that's supposed to launch is a macOS desktop app, once the build finishes the terminal does this:

❯ cd (main build folder)/Debug/AudioPluginHost.app/Contents/MacOS &&
cmdand>

But the app doesn't launch.

Civitasv commented 1 year ago

Maybe it’s an os specific problem. I will check today.

rohit-kumar-j commented 1 year ago

Yes, seems like an os specific problem. I think when we do a nvim_chan_send() to the terminal, it does not register the return character.

I had a simialr issue with sending the enter key in windows. In linux, '\n' emulated the enter key, but in windows, i had to explicitly concatenate a string.char(13) which emulated the Enter key on windows.

Perhaps Mac has this problem as well.

allstdcpp commented 1 year ago

I tried running this directly with :CMakeRun on the current head and it still does not work.

allstdcpp commented 1 year ago

Also nothing shows under :messages

RolandStolz commented 1 year ago

I'm having the same issue under macOS Ventura 13.3.1. Looks like it is a problem specific to mac.

RolandStolz commented 1 year ago

Just tried typing the command directly and it does the same thing as the key binding. The target that's supposed to launch is a macOS desktop app, once the build finishes the terminal does this:

❯ cd (main build folder)/Debug/AudioPluginHost.app/Contents/MacOS &&
cmdand>

But the app doesn't launch.

It gives the exact same output for me. However, if I type ./ExecName immediately afterwards, the executable is run. Is it intended to work like that?

Civitasv commented 1 year ago

Is it intended to work like that?

No, it’s not intended. So there is no ./ExecName at end of the command?

Civitasv commented 1 year ago

The latest commit should solve this problem, try it. @STZRoland

RolandStolz commented 1 year ago

The latest commit should solve this problem, try it. @STZRoland

Yes it works now, you are a legend!!