Giter VIP home page Giter VIP logo

vim-cmake's People

Contributors

alexaut avatar andoku avatar cdelledonne avatar marwing avatar oj-lappi avatar sillydan1 avatar tcberner avatar vadz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

vim-cmake's Issues

Additional project generation options

Thank you very much for a such great plugin.

In order to use it personally I need some more project generation options:

let g:cmake_export_compile_commands = 1
let g:cmake_project_generator = 'ninja'
let g:cmake_cxx_compiler = 'path to executable'
let g:cmake_c_compiler = 'path to executable'
let g:cmake_toolchain_file = 'path to executable'

Or just an array of custom generation options:

let g:cmake_generate_options = []

I suppose they must be useful for another people.

Unable to set cmake_root_markers to empty list

Bug description

Unable to set cmake_root_markers to empty list via .vimrc. If let g:cmake_root_markers = [] is executed after launching vim, then the correct value can be set.

To Reproduce

  1. Add the following line in your .vimrc or init.vim file:
let g:cmake_root_markers = []
  1. Save the file and restart vim
  2. Execute let g:cmake_root_markers in vim.
  3. The output is ['.git', '.svn'] instead of []

Expected behavior

The output should be an empty list instead of the default list.

Behavior with minimal .vimrc

I am able to reproduce this issue with a minimal .vimrc

Screenshots

Other info

  • OS: Mac OS X 12.3
  • Vim/Neovim version: Neovim 0.6.0
  • Vim-CMake version (5th line in :help cmake): 0.6.2

Additional context

For the time being, I have modified the values in the list here to an empty list and installed your awesome plugin using the modified code. This issue is probably due to config_vars overriding the options set in the .vimrc file, but I could be wrong.

Possibly wrong Quickfix list in narrow terminals on Windows

Bug description

On Windows, ConPTY seems to be hard-wrapping lines that are longer than the PTY's width (possibly related issues: microsoft/terminal#405, mintty/mintty#971). Generating a Quickfix list of errors relies on error messages to be output on a single line, which is not the case for hard-wrapped error messages.

The effect is that the Quickfix feature does not work reliably.

We could try to work around this problem as mentioned in the issues linked above, but we're not sure whether that's feasible at all and what the complexity/maintenance cost would be.

To Reproduce

Run :CMakeBuild in a project with errors in a narrow terminal in Neovim on Windows, and observe that when error messages span multiple lines in the Vim-CMake console, the Quickfix list is incorrect.

Expected behavior

We would expect entire lines of output to be passed to the job's callback as single lines (e.g. ['This is a line of output', '']), not as multiple lines (e.g. ['This is a line', ' of output', '']).

Other info

  • OS: Windows
  • Vim/Neovim version: Neovim 0.8.0
  • Vim-CMake version (:echo cmake#GetInfo().version): 0.11.1
  • CMake version (cmake --version): 3.22.2

Change directory

Request description

When I change my directory, vim-cmake can locate where is the new CMakeLists file is

For example, when I build this project:
2022-08-28_21:41:19

And then try to build another project:
2022-08-28_21:45:44
It tries to build the old project

Alternatives solutions

Command that we can use to clear build history

Blank terminal after build or generate

Bug description

A clear and concise description of what the bug is.
After running :CMakeGenerate or :CMakeBuild, a blank terminal is generated but it was doing nothing. I have made sure that the command leads to cmake executable is correct. The terminal remains blank no matter how long I waited for it.

To Reproduce

Steps to reproduce the behavior:

  1. Run :CMakeGenerate or :CMakeBuild with default config

Expected behavior

A clear and concise description of what you expected to happen.
Successfully generate build files

Behavior with minimal .vimrc

A clear and concise description of what happens whe trying to reproduce the bug with a minimal .vimrc. Ideally, a minimal .vimrc only contains configuration for this plugin, and nothing else. If the minimal .vimrc used is more complicated, please post the content here.
The only configuration of this plugin is Plug 'cdelledonne/vim-cmake'.
This problem occurs without all other plugins too.

Screenshots

If applicable, add screenshots to help explain your problem.
image

Other info

  • OS: Windows 11
  • Vim/Neovim version: Neovim 0.7
  • Vim-CMake version (5th line in :help cmake): 0.6.2

Additional context

Add any other context about the problem here.

Close CMake Window on successfull CMakeBuild

Describe the solution you'd like
It would be awesome to have an option which closes the CMake window after a successful build. Just to avoid the two keystrokes for cq.

Thanks for the great plugin πŸ‘

Weird project root path

Bug description

I got a weird project root path output after I run CMakeGenerate:

image

the pwd is: /home/rave/tmp/test_project, but the project root path is pwd followed by a white space, which does not exist.

To Reproduce

Steps to reproduce the behavior:

  1. open project
  2. Type CMakeGenerate

Expected behavior

cmake build success.

Behavior with minimal .vimrc

my vim-cmake config:

    let g:cmake_link_compile_commands = 1
    let g:cmake_build_dir_location = './build'
    let g:cmake_build_options= ["-j8"]
    let g:cmake_log_file="/tmp/vim-cmake.log"

Screenshots

see Bug description section.

Other info

  • OS: Ubuntu 20.04
  • Vim/Neovim version: nvim v0.6.1
  • Vim-CMake version (5th line in :help cmake): 0.7.0

Log output

[2022-03-23 21:22:53] [ INFO] Loading Vim-CMake
[2022-03-23 21:22:53] [ INFO] Commands defined
[2022-03-23 21:22:53] [ INFO] Mappings defined
[2022-03-23 21:22:53] [ INFO] Vim-CMake loaded
[2022-03-23 21:22:56] [ INFO] Project root: /home/raven/tmp/test_project
[2022-03-23 21:22:56] [ INFO] Current config: Debug (/home/raven/tmp/test_project/build/Debug)
[2022-03-23 21:22:56] [DEBUG] Invoked: statusline.SetBuildInfo(Debug)
[2022-03-23 21:22:56] [DEBUG] Build configs: []
[2022-03-23 21:22:56] [ INFO] Configuration options:
[2022-03-23 21:22:56] [ INFO] > g:cmake_build_dir_location: './build'
[2022-03-23 21:22:56] [ INFO] > g:cmake_build_options: ['-j8']
[2022-03-23 21:22:56] [ INFO] > g:cmake_command: 'cmake'
[2022-03-23 21:22:56] [ INFO] > g:cmake_console_echo_cmd: 1
[2022-03-23 21:22:56] [ INFO] > g:cmake_console_position: 'botright'
[2022-03-23 21:22:56] [ INFO] > g:cmake_console_size: 15
[2022-03-23 21:22:56] [ INFO] > g:cmake_default_config: 'Debug'
[2022-03-23 21:22:56] [ INFO] > g:cmake_generate_options: []
[2022-03-23 21:22:56] [ INFO] > g:cmake_jump: 0
[2022-03-23 21:22:56] [ INFO] > g:cmake_jump_on_completion: 0
[2022-03-23 21:22:56] [ INFO] > g:cmake_jump_on_error: 1
[2022-03-23 21:22:56] [ INFO] > g:cmake_link_compile_commands: 1
[2022-03-23 21:22:56] [ INFO] > g:cmake_log_file: '/tmp/vim-cmake.log'
[2022-03-23 21:22:56] [ INFO] > g:cmake_native_build_options: []
[2022-03-23 21:22:56] [ INFO] > g:cmake_root_markers: ['.git', '.svn']
[2022-03-23 21:22:56] [DEBUG] API invoked: cmake#Generate(0, [])
[2022-03-23 21:22:56] [DEBUG] Invoked: buildsys.Generate(0, '')
[2022-03-23 21:22:56] [DEBUG] Invoked: terminal.Run(['cmake', '-D CMAKE_BUILD_TYPE=Debug', '-D CMAKE_EXPORT_COMPILE_COMMANDS=ON', '-S .', '-B build/Debug'], 'generate', [function('<SNR>80_RefreshConfigs'), function('<SNR>80_RefreshTargets'), function('<SNR>80_LinkCompileCommands')], [function('<SNR>80_RefreshConfigs')], [], [])
[2022-03-23 21:22:56] [DEBUG] Invoked: terminal.Open(v:false)
[2022-03-23 21:22:56] [DEBUG] Created console window
[2022-03-23 21:22:57] [DEBUG] Invoked: statusline.SetCmdInfo(Generating buildsystem...)
[2022-03-23 21:22:57] [DEBUG] Invoked console exit callback
[2022-03-23 21:22:57] [DEBUG] Invoked: statusline.SetCmdInfo()
[2022-03-23 21:22:57] [DEBUG] Invoked: terminal.Focus()
[2022-03-23 21:22:57] [DEBUG] Callback invoked: <SNR>80_RefreshConfigs()
[2022-03-23 21:22:57] [DEBUG] Build configs: []
[2022-03-23 21:23:01] [ INFO] Loading Vim-CMake
[2022-03-23 21:23:01] [ INFO] Commands defined
[2022-03-23 21:23:01] [ INFO] Mappings defined
[2022-03-23 21:23:01] [ INFO] Vim-CMake loaded

Everytime CMakeToggle is triggered, origin buffer lose syntax highlight

Bug description

After triggering :CMakeGenerate first time in every session, all text in origin buffer become white and have no highlight.
(If I reopen the file in the same buffer or run syntax on, do some editing and re-run :CMakeGenerate, this does not happen)

After testing, this behavior is actually triggered by everytime :CMakeToggle is triggered. It seems that on first :CMakeGenerate or everytime :CMakeRun is ran in text buffer :CMakeToggle is called. (Sorry I didn't have the time to dig into the code to check if it is true)

Expected behavior

Hightlight does not disappear from the first time.

Behavior with minimal .vimrc

Same behavior with a minimal .vimrc as following:

set nocompatible
let &runtimepath  = '~/.vim/bundle/vim-cmake,' . &runtimepath
filetype plugin indent on
syntax enable

Other info

  • OS: Fedora Plasma 38
  • Vim/Neovim version: Vim 9.0.2048
  • Vim-CMake version (:echo cmake#GetInfo().version):0.14.0
  • CMake version (cmake --version):3.27.7

Retrieve build targets using CMake's file API

Vim-CMake uses the help target to retrieve a list of available build targets. When running cmake --build <build_dir> --target help, there are a few differences between the output for Makefile systems and that for Ninja systemsβ€”e.g. the format is different, and Ninja systems also return a lot more entries.

To make the retrieval of build targets consistent and build tool-independent, we could use CMake's file api. From #57 (comment):

Fortunately CMake has a feature for this. It is called cmake-file-api(7) and is meant to be used by 'clients' to retrieve semantic information about the buildsystems CMake generates. So exactly what we want, especially with the Object Kind "codemodel".

Parsing JSON data should not be an issue, as both Vim and Neovim provide the function json_decode().

Command output with ninja build system broken

Bug description

When generating a ninja based build system instead of a Makefile based one the display of ninjas output during build doesn't work as it should. There are two components to this issue:

  1. Ninjas output only shows up when the command exits
  2. All output is displayed next to each other in a single line

To Reproduce

Steps to reproduce the behavior:

  1. Create a CMake project or use an existing one
  2. Make sure you have ninja installed
  3. open in vim/neovim and run :CMakeGenerate Debug -GNinja
  4. run :CMakeBuild
  5. wait for command to finish and see output

Expected behavior

I would expect ninjas output to be either shown as in a normal terminal or as when piped through a command like cat.
For reference run the following commands in the build folder:

ninja
ninja | cat

Behavior with minimal .vimrc

Same as above with empty vimrc/init.vim

Screenshots

Actual:
2022-07-28-095916_grim
Expected normal:
2022-07-28-095942_grim
Expected cat:
2022-07-28-100034_grim

Other info

  • OS: ArchLinux 5.18.14
  • Vim/Neovim version: NVIM v0.8.0-dev-726-gb971547c54
  • Vim-CMake version (5th line in :help cmake): 0.9.0 / d62f24d
  • CMake version (cmake --version): 3.23.2

Additional context

Ninja outputs carriage returns instead of newlines to only have one line of output. Vim-CMake removes carriage returns and waits for the entire line before sending it to the console window. I could experimentally patch the first part by just disabling the relevant bit of code but don't know what that entails other than the intended (code is probably there for a reason), the second part takes some more knowledge of the code than I have to do right probably.

Enable jump when :CMakeOpen

I'd like to be able to focus the cmake console window when running :CMakeOpen.
The reason is that I want to toggle line numbers in that window when it has been newly opened.

Even if I set :let g:cmake_jump=1, when calling :CMakeOpen the window focus is not on the cmake console window.

Perhaps adding a :CMakeFocus function could be a nice extension?
Or adding a conditional check on autoload/cmake/terminal.vim:370 like if g:cmake_jump==0 && ... since jumping works for generate/build etc.

E121: Undefined variable: s:cmake_version

Describe the bug
Trying to run CMakeGenerate, but getting error: Undefined variable: s:cmake_version
cmake is installed, version 3.19.2

To Reproduce
Steps to reproduce the behavior:

  1. Run :CMakeGenerate

Screenshots
Screenshot 2021-01-17 at 02 50 46

Other info

  • OS: Linux Manjaro
  • Vim/Neovim version: 8.2.1989
  • Vim-CMake version (5th line in :help cmake): 0.4.0

:CMakeGenerate only adds -DCMAKE_BUILD_TYPE flag on first time

Bug description

If I use commands:
:CMakeGenerate Debug or :CMakeGenerate! Debug
It adds -DCMAKE_BUILD_TYPE=Debug flag only if folder build/Debug doesn't exist.
If I run it the second time it doesn't add this flag

To Reproduce

Steps to reproduce the behavior:

  1. Run :CMakeGenerate! Debug
  2. Run :CMakeGenerate! Debug second time

Expected behavior

Expected to always add -DCMAKE_BUILD_TYPE=Debug or -DCMAKE_BUILD_TYPE=Release flags

Screenshots

First time running :CMakeGenerate! Debug:
Π‘Π½ΠΈΠΌΠΎΠΊ экрана 2021-07-15 Π² 00 43 49

Second time running :CMakeGenerate! Debug:
Π‘Π½ΠΈΠΌΠΎΠΊ экрана 2021-07-15 Π² 00 44 45

Other info

  • OS: MacOS Big Sur
  • Vim/Neovim version: 8.2.2681 (171)
  • Vim-CMake version (5th line in :help cmake): 0.6.1

Too many backslash character on directory that contains space

Bug description

The cmake command string that generated when calling :CMakeGenerate and :CMakeBuild has too many backslash character on directory with space character.

project directory

$ pwd
/tmp/directory with space/project

:CMakeGenerate output

Running command: cmake -D CMAKE_BUILD_TYPE=Debug -D CMAKE_EXPORT_COMPILE_COMMANDS=ON -S /tmp/directory\\\ with\\\ space/project -B /tmp/directory\\\\\\\\\\\\\\\ with\\\\\\\\\\\\\\\ space    
/project/Debug

:CMakeBuild output

Running command: cmake --build /tmp/directory\\\\\\\\\\\\\\\ with\\\\\\\\\\\\\\\ space/project/Debug

To Reproduce

Steps to reproduce the behavior:

  1. Create a new project directory inside a directory that contains space.
  2. Create some C file.
  3. Create CMakeLists.txt file for that C file.
  4. Open neovim.
  5. Run :CMakeGenerate and :CMakeBuild.

Expected behavior

Exactly one backslash character per space character.

Behavior with minimal .vimrc

The same as above.

minimal .vimrc

call plug#begin('~/.config/nvim/plugged')
Plug 'cdelledonne/vim-cmake'
call plug#end()

let g:cmake_link_compile_commands=1
nmap <leader>cg :CMakeGenerate<cr>
nmap <leader>cb :CMakeBuild<cr>

Screenshots

image

Other info

  • OS: Debian sid
  • Vim/Neovim version: 0.7.2
  • Vim-CMake version: 0.12.0
  • CMake version: 3.25.1

Additional context

log

[2022-12-21 15:43:50] [ INFO] Configuration options:
[2022-12-21 15:43:50] [ INFO] > g:cmake_build_dir_location: '.'
[2022-12-21 15:43:50] [ INFO] > g:cmake_build_options: []
[2022-12-21 15:43:50] [ INFO] > g:cmake_command: 'cmake'
[2022-12-21 15:43:50] [ INFO] > g:cmake_console_echo_cmd: 1
[2022-12-21 15:43:50] [ INFO] > g:cmake_console_position: 'botright'
[2022-12-21 15:43:50] [ INFO] > g:cmake_console_size: 15
[2022-12-21 15:43:50] [ INFO] > g:cmake_default_config: 'Debug'
[2022-12-21 15:43:50] [ INFO] > g:cmake_generate_options: []
[2022-12-21 15:43:50] [ INFO] > g:cmake_jump: 0
[2022-12-21 15:43:50] [ INFO] > g:cmake_jump_on_completion: 0
[2022-12-21 15:43:50] [ INFO] > g:cmake_jump_on_error: 1
[2022-12-21 15:43:50] [ INFO] > g:cmake_link_compile_commands: 1
[2022-12-21 15:43:50] [ INFO] > g:cmake_log_file: 'VIM_CMAKE_LOG'
[2022-12-21 15:43:50] [ INFO] > g:cmake_log_level: 'INFO'
[2022-12-21 15:43:50] [ INFO] > g:cmake_native_build_options: []
[2022-12-21 15:43:50] [ INFO] > g:cmake_reinit_on_dir_changed: 1
[2022-12-21 15:43:50] [ INFO] > g:cmake_restore_state: 1
[2022-12-21 15:43:50] [ INFO] > g:cmake_root_markers: ['.git', '.svn']
[2022-12-21 15:43:50] [ INFO] > g:cmake_statusline: 0
[2022-12-21 15:43:50] [ INFO] > g:cmake_test_command: 'ctest'
[2022-12-21 15:43:50] [ INFO] > g:cmake_test_options: []
[2022-12-21 15:43:50] [ INFO] Project root: /tmp/directory\ with\ space/project
[2022-12-21 15:43:50] [ INFO] Current config: Debug (/tmp/directory\\\\\\\ with\\\\\\\ space/project/Debug)

nvim_open_term error

I'm running neovim on Ubuntu 20.04 WSL and I'm having the following error when I run the :CMakeGenerate command.

Error detected while processing function cmake#Generate[2]..293[20]..290[17]..287[19]..74_CreateConsoleBuffer[2]..74_TermSetup: line 4: E117: Unknown function: nvim_open_term E15: Invalid expression: nvim_open_term(bufnr(''), l:options)

Any idea what I can do?

Error messages in vim on any Vim-CMake command

Bug description

Vim shows multiple errors when running any command from Vim-CMake. This does not happen in NeoVim.
The errors don't appear to break anything obvious based on some preliminary testing.

To Reproduce

Steps to reproduce the behavior:

  1. make sure there are no active vimrc or plugins
  2. clone/copy/symlink vim-cmake's master branch into ~/.vim/pack/local/start/vim-cmake
  3. open vim and run :CMakeOpen

As shell commands:

mv ~/.vim{,.bak_gh}; mv ~/.vimrc{,.bak_gh}
mkdir -p ~/.vim/pack/local/start/
git -C ~/.vim/pack/local/start clone https://github.com/cdelledonne/vim-cmake.git
git -C ~/.vim/pack/local/start/vim-cmake checkout fcd20af9758a38c98ece6660e5b2780eef93333e
vim +CMakeOpen

# to reset
rm -rf ~/.vim
mv ~/.vim{.bak_gh,}; mv ~/.vimrc{.bak_gh,}

Expected behavior

The code in question should not produce any errors at this stage.

Behavior with minimal .vimrc

Works without any vimrc

Screenshots

2022-10-31-222107_grim

Other info

  • OS: Arch Linux
  • Vim/Neovim version:
$ vim --version
VIM - Vi IMproved 9.0 (2022 Jun 28, compiled Oct 22 2022 19:58:44)
Included patches: 1-813
Compiled by Arch Linux
Huge version without GUI.
  • Vim-CMake version (:echo cmake#GetInfo().version): 0.11.1 (current master fcd20af)
  • CMake version (cmake --version): 3.24.2

Additional context

The error from the screenshot as text:

Error detected while processing /home/marwin/Workspace/vim/vim-cmake/autoload/cmake.vim[14]..function cmake#util#PrintNews[1]..<SNR>38_UpdateVersionNumber:
line   15:
E896: Argument of get() must be a List, Dictionary or Blob
Error detected while processing /home/marwin/Workspace/vim/vim-cmake/autoload/cmake.vim[24]..function 29[6]..18:
line    3:
E896: Argument of get() must be a List, Dictionary or Blob
Error detected while processing /home/marwin/Workspace/vim/vim-cmake/autoload/cmake.vim[24]..function 29:
line    6:
E896: Argument of get() must be a List, Dictionary or Blob
Error detected while processing /home/marwin/Workspace/vim/vim-cmake/autoload/cmake.vim[24]..function 29[6]..<SNR>30_SetCurrentConfig[11]..20[4]..18:
line    3:
E896: Argument of get() must be a List, Dictionary or Blob
Press ENTER or type command to continue

Originally reported by @marwing in #70 (comment)

Bug in function RefreshTests

Bug description

By CMakeGenerate crash with error by function RefreshTests, but there is no test declarate in the project. It is just "Hello World"

To Reproduce

Just run CMakeGenerate. Clear Debian 11 "bullseye"

  1. main.cpp
#include <iostream>

using namespace std;

int main () {
    cout << "Hello World!" << endl;
    return 0;
}
  1. CMakeLists.txt
cmake_minimum_required(VERSION 3.5)

project(foo LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

list(APPEND SOURCES main.cpp)

add_executable(foo ${SOURCES})

Behavior with minimal .vimrc

syntax on
set number
set scrolloff=3
set wrap
set showmatch
set autoread
set confirm
set noswapfile
set incsearch
set hlsearch
set ignorecase
set smartcase
filetype plugin on

" ##############################################################################
" Plug autoload
" ##############################################################################

" automatically downloads vim-plug to your machine if not found.
if empty(glob('~/.vim/autoload/plug.vim'))
silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
endif

" Define plugins to install
call plug#begin('~/.vim/plugged')
Plug 'cdelledonne/vim-cmake'
call plug#end()

let g:cmake_link_compile_commands = 1

Screenshots

Screenshot from 2022-09-15 16-09-48

Other info

  • OS: Debian 11 "bullseye"
  • Vim/Neovim version: VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Oct 01 2021 01:51:08)
    Included patches: 1-2434
    Extra patches: 8.2.3402, 8.2.3403, 8.2.3409, 8.2.3428
  • Vim-CMake version (5th line in :help cmake): 0.10.1
  • CMake version (cmake --version): 3.18.4

CMakeRun command support

Request description

Run an executable file inside vim/nvim using CMakeRun.

Desired behavior

After executing the CMakeBuild command, we will get a bunch of executable files. It would be very sweet if we could run those files inside vim/nvim, i.e. run :CMakeRun + exec file + args in vim/nvim.

Alternatives solutions

Run the file in a terminal window.

Add command to call ctest in build dir

Is your feature request related to a problem? Please describe.

It would be cool to also be able to run ctest -v in the current build directory

Describe the solution you'd like

A new command CTest that runs ctest in the current build dir.

[Request] Jump to errors

Your plugin its pretty well designed, I like the idea of using an unique window so I don't have to use the :colder command with ALE, also I can switch easily between buildings, but there is one problem, when an error occurs I cant jump to the line with that error.

I guess implementing this with the terminal window it would be like walking trough hell, so maybe it would be nice to have the option to decide if you want to use the terminal window or a quickfix, but I guess you will still have to write a lot of code to accomplish this.

Anyway I open the issue and maybe someone will come up with some idea.

E117: Unknown function: nvim_open_term

Bug description

Error when running :CMakeGenerate

Error detected while processing function cmake#Generate[2]..72[20]..69[17]..66[19]..<SNR>156_CreateConsoleBuffer[2]..<SNR>156_TermSetup:

E117: Unknown function: nvim_open_term
E15: Invalid expression: nvim_open_term(bufnr(''), l:options)

To Reproduce

Steps to reproduce the behavior:

  1. install vim-cmake
  2. open an cpp file, running `:CMakeGenerate"

Behavior with minimal .vimrc

call plug#begin('~/.config/nvim/plugged')
Plug 'cdelledonne/vim-cmake'
call plug#end()

let g:cmake_link_compile_commands=1
nmap <leader>cg :CMakeGenerate<cr>
nmap <leader>cb :CMakeBuild<cr>

Other info

  • OS: Ubuntu 20.04
  • Vim/Neovim version: 0.4.3
  • Vim-CMake version (5th line in :help cmake): 0.7.0

Support Vim under Windows

Support for Neovim under Windows has been added in #40. However, the plugin does not work in Vim under Windows yet.

Job still running after CMakeClose

Bug description

When I run CMakeBuild and CMakeClose and then try to write and quit all buffers using :wqa, I get a "One job is still running"

Expected behavior

The job should stop when CMakeBuild ended or when CMakeClose is called

Behavior with minimal .vimrc

Same behavior

Other info

  • OS: Manjaro
  • Vim version: 9.0
  • Vim-CMake version (:echo cmake#GetInfo().version): 0.12.1
  • CMake version (cmake --version): 3.26.1

feat: detect, show and use top-level directory of cmake

Reasoning
It is quite annoying to be forced to always jump to the top level directory, but we also dont want to mess up the build. For example, git submodules or external projects on wrong invocation of cmake may lead to this.
(the CMakeList.txt does not hint that the code is used as submodule)

Status Line
I It would be good to show the top-level directory in the statusline, but probably sufficient to show the top-level directory folder name in the status line. Adding instructions for doing this to the README would be great.

HOW
We can check git rev-parse --show-toplevel and git rev-parse --show-superproject-working-tree. Does cmake offer a similar solution? I did not find any yet.

don't create compile_commands.json soft link if cmake gives error

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when an invalid compile_commands.json link has been created

Describe the solution you'd like
A clear and concise description of what you want to happen.

create the link after successfully running cmake command
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

CMake Preset support

Request description

Can we support CMake presets? I would like to see an option which shows the available presets and let's the user tab complete it. And possibly change state variables like g:cmake_build_dir_location based on selected preset.

Desired behavior

  1. After calling the CMakePreset command with the preferred preset, cmake --preset should be called.
  2. The g:cmake_build_dir_location, g:cmake_default_config et al. should be updated to match selected preset from CMakePresets.json file.
  3. The preset name should be displayed on the vim status line if enabled through any variable, g:cmake_show_preset_in_status_line maybe?
  4. Plugin should be able to configure with g:cmake_preset and do steps 1-3

Alternatives solutions

I am able to do this via terminal. This is my flow

# list the presets, maybe this can be used for autocomplete?
cmake --list-presets
# generate cmake files based on the preset
cmake --preset x86_64-unknown-linux-gnu
# configure local .vimrc manually 
# for pointing vim-cmake to the generated files

Specify CMAKE_PREFIX_PATH

I would like to use this plugin for a simple Qt project:

cmake_minimum_required(VERSION 3.14)

project(myproject LANGUAGES CXX)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core)

add_executable(myproject
  main.cpp
)
target_link_libraries(myproject Qt${QT_VERSION_MAJOR}::Core)

install(TARGETS myproject
    LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})

Unfortunately, when I try to run :CMakeGenerate, I have the following issue:

Running command: cmake -D CMAKE_BUILD_TYPE=Debug -S . -B Debug
-- The CXX compiler identification is AppleClang 14.0.0.14000029
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:12 (find_package):
  Could not find a package configuration file provided by "QT" with any of
  the following names:

    Qt6Config.cmake
    qt6-config.cmake
    Qt5Config.cmake
    qt5-config.cmake

  Add the installation prefix of "QT" to CMAKE_PREFIX_PATH or set "QT_DIR" to
  a directory containing one of the above files.  If "QT" provides a separate
  development package or SDK, be sure it has been installed.


-- Configuring incomplete, errors occurred!
See also "/Users/martindelille/dev/tests/undo-test2/Debug/CMakeFiles/CMakeOutput.log".
See also "/Users/martindelille/dev/tests/undo-test2/Debug/CMakeFiles/CMakeError.log".

Running command: cmake -S . -B Debug
CMake Error at CMakeLists.txt:12 (find_package):
  Could not find a package configuration file provided by "QT" with any of
  the following names:

    Qt6Config.cmake
    qt6-config.cmake
    Qt5Config.cmake
    qt5-config.cmake

  Add the installation prefix of "QT" to CMAKE_PREFIX_PATH or set "QT_DIR" to
  a directory containing one of the above files.  If "QT" provides a separate
  development package or SDK, be sure it has been installed.


-- Configuring incomplete, errors occurred!
See also "/Users/martindelille/dev/tests/myproject/Debug/CMakeFiles/CMakeOutput.log".
See also "/Users/martindelille/dev/tests/myproject/Debug/CMakeFiles/CMakeError.log".

Running command: cmake -S . -B Debug
CMake Error at CMakeLists.txt:12 (find_package):
  Could not find a package configuration file provided by "QT" with any of
  the following names:

    Qt6Config.cmake
    qt6-config.cmake
    Qt5Config.cmake
    qt5-config.cmake

  Add the installation prefix of "QT" to CMAKE_PREFIX_PATH or set "QT_DIR" to
  a directory containing one of the above files.  If "QT" provides a separate
  development package or SDK, be sure it has been installed.


-- Configuring incomplete, errors occurred!
See also "/Users/martindelille/dev/tests/myproject/Debug/CMakeFiles/CMakeOutput.log".
See also "/Users/martindelille/dev/tests/myproject/Debug/CMakeFiles/CMakeError.log".

How can I specify the CMAKE_PREFIX_PATH ?

How to switch BuildType Debug/Release quickly?

Currently, I can switch CMake build type by setting g:cmake_default_config='Debug'/'Release'. Is there any better way to do this?
another question is how to use :CMakeSwitch <config>, I don't understand what does <config> mean.
Thanks!

can not create compile_commands.json

Describe the bug
vim-cmake does generate the Makefile and cmake objects in folder Debug, but it does not generate a compile_commands.json necessary for clangd or any other c++ language server.

To Reproduce
Steps to reproduce the behavior:

  1. Make sure you have folder called Debug.
  2. Run :CMakeGenerate

Expected behavior
The compile_commands.json should be created. However it is not, which makes clangd unusable.

Screenshots
(would show that clangd does not find files)

Other info

  • OS: Endeavour (rolling release Arch derivate)
  • Vim/Neovim version: NVIM v0.5.0-dev+1133-g0869cbd55 (appimage)
  • Vim-CMake version (5th line in :help cmake): 0.5.0

Additional context
Here is a hint that the compile_commands.json needs a second invocation of cmake. Did you skip this at some point? Otherwise I would suggest creating another command to generate the compile_commands.json.

Probably they changed the behavior such that cmake does not invoke itself a second time?!

set(CMAKE_EXPORT_COMPILE_COMMANDS ON) works as expected, so maybe the cmake CLI interface got changed?!

cannot find project path from subdirectory

Bug description

suppose the project's file hierarchy as below:
project_root
CMakeLists.txt
.marker(such .git)
src
main.cpp
include
hello.hpp

I can only use cmakegenerate in project_root to locate .marker correctly
if I try it in src or include , it will try to locate .marker from $HOME

I found FindProjectRoot() in autoload
if I change the following line:
let l:root = fnamemodify(l:marker_path, printf(
\ ':.:s?%s??:h', l:marker_path))
to:
let l:root = fnamemodify(l:marker_path,":h")
things will work fine

I think nvim change it's findfile() return value to full path, to strip the .marker, we only need to use ':h' in fnamemodify()

Add an option to set relative build path

It should be configurable to set path for build folder. For example '..' (parent directory of the project root)

/Users/user/project/
β”œβ”€β”€ Debug
    └── compile_commands.json
└── project
    β”œβ”€β”€ .git
    β”œβ”€β”€ CMakeLists.txt
    β”œβ”€β”€ compile_commands.json -> ../Debug/compile_commands.json
    └── src
        └── main.cpp

Wrong root directory for CMakeGenerate output

Describe the bug
CMakeGenerate ignores root folder found by g:cmake_root_markers

To Reproduce
Steps to reproduce the behavior:

  1. Setup project structure like this:
/Users/user/project/
β”œβ”€β”€ .git
β”œβ”€β”€ CMakeLists.txt
└── src
    └── main.cpp
  1. Add to config:
let g:cmake_generate_options = ['-GNinja', '-DCMAKE_EXPORT_COMPILE_COMMANDS=ON']
let g:cmake_root_markers = ['.git']
let g:cmake_link_compile_commands = 1
  1. Open file project/src/main.cpp in vim
  2. Execute :CMakeGenerate
  3. As result project structure will be:
/Users/user/project/
β”œβ”€β”€ .git
β”œβ”€β”€ CMakeLists.txt
β”œβ”€β”€ compile_commands.json -> Debug/compile_commands.json
└── src
    β”œβ”€β”€ Debug
    └── main.cpp

Expected behavior
Directory Debug must be created at the project root.
We also have a broken link here. compile_commands.json points to a not existing directory.
It also must be configurable to set path for the Debug folder. For example '..' (parent directory of the project root)

Also g:cmake_link_compile_commands option should imply -DCMAKE_EXPORT_COMPILE_COMMANDS=ON command line argument to cmake.

:CMakeToggle

Since we already have :CMakeOpen and :CMakeClose it feels like it would be appropriate with a :CMakeToggle command that toggles the cmake window.

This could be manually scripted in users' init script file(s), but it would be much cleaner and easier to keybind if it was a built-in feature of the plugin.

CMakeClose fail to close the console window

Describe the bug
CMakeClose fail to close the console window

To Reproduce
Steps to reproduce the behavior:

  1. CMakeBuild or CMakeGenerate, which write some chars into the console window buffer. Or just call CMakeOpen and input some random chars.
  2. call CMakeClose . Error37: No write since last change (add ! to override)

Expected behavior

  • CMakeClose should close the window even if there is change in the buffer.
  • Another option is to have a command CMakeClose! , which has the similar behaviour like :q! and keep the current CMakeClose for those who want to save the CMake log from the console window.

Screenshots
If applicable, add screenshots to help explain your problem.
图片

Other info

  • OS: Manjaro x64
  • Vim/Neovim version: vim 8.2
  • Vim-CMake version (5th line in :help cmake): 0.4.0

Additional context
Add any other context about the problem here.

Add an option to save (and restore) project context

Request description

Add an option to save (and restore) project context, mostly buildsys.current_config.

Desired behavior

Context should be saved such that when exiting and starting Vim/Neovim again it can be restored. The buildsys.current_config variable is the most important one, as it points to the current build configuration. There should also be an option to control whether or not context should be saved/restored.

Additional context

  • Would be good to store context data in some Vim/Neovim data folder. At the moment, for instance, Vim-CMake data is saved in a .data file at the root of the repository.
  • Vim-CMake could also check, upon start-up and in the background, if all projects with a saved context still exist, and delete the context of projects that do not exist any longer.

issue with neovim 0.3.0 bundled with CentOS 7

Describe the bug
The plugin is not working on CentOS7 / neovim v0.3.0 / cmake v3.17.2

Error:
Error detected while processing function cmake#Generate[16]..cmake#generate#Run:
line 8:
E121: Undefined variable: s:cmake_version
E15: Invalid expression: s:cmake_version < 313

To Reproduce
Steps to reproduce the behavior:

  1. Install CMake plugin using vim-plug Plug 'cdelledonne/vim-cmake'
  2. Try to generate project using :CMakeGenerate (I'm in the top-level project directory and no build folder present)

Expected behavior
No errors - folder build created, generated files appear in it.

Screenshots
nvim_cmake_issue

Other info

  • OS:

cat /etc/centos-release
CentOS Linux release 7.7.1908 (Core)

  • Vim/Neovim version:

nvim --version

NVIM v0.3.0
Build type: RelWithDebInfo
Lua 5.1
Compilation: /usr/bin/cc -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches  -m64 -mtune=generic -Wconversion -Wp,-U_FORTIFY_SOURCE -Wp,-D_FORTIFY_SOURCE=1 -DNVIM_UNIBI_HAS_VAR_FROM -O2 -g -DMIN_LOG_LEVEL=3 -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wvla -fstack-protector-strong -fdiagnostics-color=auto -Wno-array-bounds -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -I/builddir/build/BUILD/neovim-0.3.0/build/config -I/builddir/build/BUILD/neovim-0.3.0/src -I/usr/include -I/builddir/build/BUILD/neovim-0.3.0/build/src/nvim/auto -I/builddir/build/BUILD/neovim-0.3.0/build/include
Compiled by mockbuild

Features: +acl +iconv +jemalloc +tui 
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/share/nvim"

Run :checkhealth for more info
  • Vim-CMake version (5th line in :help cmake):
    Version: 0.1.1

Additional context
Add any other context about the problem here.

Support Pre-build/configure actions

Request description

It would be nice to run a command BEFORE any cmake command. E.g. execute a bash script before the cmake configure/build run.

Desired behavior

Specified command will run before any cmake command.

Additional context

I have the need to create junctions on windows before building. Currently I'm doing it within QT Creator where I can define build steps. Would be nice to have the same functionallity within this plugin.

Proposed Solution

Adding autocmd in the beginning of the Generate and Build functions. This way I could hook into them and call my scripts

Can't run CMakeGenerate after fresh install

Bug description

After installing the plugin through Vundle, I tried to run :CmakeGenerate and I get the following error:
image

To Reproduce

  1. Install
    2.Open vim
    3.Run :CMakeGenerate

Expected behavior

Expect to get the initial cmake files

Behavior with minimal .vimrc

Screenshots

image

Other info

  • OS: Ubuntu 22.04.1 LTS
  • Vim/Neovim version: VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Sep 13 2022 09:35:02)
    Included patches: 1-3995, 4563, 4646, 4774, 4895, 4899, 4901, 4919
  • Vim-CMake version (5th line in :help cmake): 0.11.0
  • CMake version (cmake --version): 3.22.1

Additional context

Add any other context about the problem here.

Possibly wrong output in narrow terminals in Vim

Bug description

In Vim, we can't seem to be able to set the PTY's width (as we reported upstream: vim/vim#11476). Some commands (i.e. Ninja, as far as we know) rely on the PTY's width to output properly formatted lines, and even use ANSI sequences to manipulate/clear lines, which gets messed up when the width perceived by the command does not correspond to what we try to set for the PTY.

The effect is a messed-up output in the Vim-CMake console. However, all other functionalities, including Quickfix, work as expected.

To Reproduce

Run :CMakeBuild for a Ninja-based build system in a narrow terminal in Vim.

Expected behavior

We would expect the PTY to have the width we specify when we call s:system.JobRun(). The environment variable COLUMNS seems to be set correctly, but the actual width of the PTY is wrong (see vim/vim#11476).

Other info

  • OS: Linux
  • Vim/Neovim version: Vim 9.0.720
  • Vim-CMake version (:echo cmake#GetInfo().version): 0.11.1

vim-cmake doesn't populate all the errors in the quickfix

Describe the bug
Quickfix doesn't populate all the errors

To Reproduce
:CMakeBuild
[Open quickfix]
Expected behavior
All the errors and warnings must be present in the quickfix.

Screenshots
Screenshot_20200913_212624
If I fix the second bug...
Screenshot_20200913_213100

Other info

  • OS: Linux (ArchLinux)
  • Vim/Neovim version: 8.2.1634
  • Vim-CMake version (5th line in :help cmake): 0.3.0

Additional context
:chistory tell me I am in a CMakeBuild quickfix.
The errors are detected by other plugins.
I will update the issue if I figure out anything else.

[ERROR] Job still runing in buffer

Describe the bug To Reproduce
Using commands like :CMakeCenerate or :CMakeCuild let the procces running in the background so when I try to exist vim an E947 doesn't let me leave.

Expected behavior
The script should finish or kill the process when I leave vim

Screenshots
Screenshot_20200818_232106

Other info

  • OS: Linux/Ubuntu
  • Vim/Neovim version: VIm 8.2
  • Vim-CMake version (5th line in :help cmake): 0.2.2

Edit: Its enough to open the window (:CMakeOpen)

How can i use toolchain

I need to add -DCMAKE_TOOLCHAIN_FIL=/path/to/toolchain/ E to command but I couldn't add. Can someone help.

Plugin refuse to work when it's installed in a directory with spaces

Describe the bug
A clear and concise description of what the bug is.
The plugin refuses to generate because my home path contains a space

To Reproduce
Steps to reproduce the behavior:

  1. Have a home path with space inside (typically Windows with accounts of full names)
  2. Run :CMakeGenerate

Expected behavior
The project should successfully configure

Screenshots
f783df6cb6ff2cbf2e28fdee15071c3e

Other info

  • OS: Windows 10
  • Vim/Neovim version: 0.4.4
  • Vim-CMake version (5th line in :help cmake): 0.3.0

Additional context

AirlineRefresh is called even if Airline plugin is not installed.

Describe the bug
Error detected while processing function 181_NeovimStdoutCallback[3]..185_CMakeConsoleCb:
line 13:
E492: Not an editor command: AirlineRefresh

To Reproduce
No special steps it, is hit by default.

Expected behavior
AirlineRefresh needs to be called only if it exist:

if exists(":AirlineRefresh")
    execute "AirlineRefresh"
endif

Screenshots
If applicable, add screenshots to help explain your problem.

Other info

  • OS:
  • Vim/Neovim version:
  • Vim-CMake version (5th line in :help cmake):

Additional context
Add any other context about the problem here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.