-
Notifications
You must be signed in to change notification settings - Fork 3
Compiling Cplusplus on Windows with Linux toolchain using Vim as a lightweight IDE and the Language Server Protocol
This is just a short guide with references to online resources on how to set up a C++ Linux toolchain compilation and development environment on Windows (targeting Windows) using Vim as a lightweight IDE.
Install MSYS2
Installing MSYS2 creates a unix-like dev environment on windows with clang and gcc compilers plus related tools. Note, several clang tools are not included in the pre-installed libraries, you may need to install LLVM for windows, separately from MSYS2 just to get those clang tools and include them in your system's path.
Resources:
Build and Install CCLS Language Server Protocol Server for C++
C/C++/ObjC language server supporting cross references, hierarchies, completion and semantic highlighting.
Code completion (with both signature help and snippets), definition/references, and other cross references, cross reference extensions: $ccls/call $ccls/inheritance $ccls/member $ccls/vars, formatting, hierarchies: call (caller/callee) hierarchy, inheritance (base/derived) hierarchy, member hierarchy, symbol rename, document symbols and approximate search of workspace symbol, hover information, diagnostics and code actions (clang FixIts), semantic highlighting and preprocessor skipped regions, semantic navigation: $ccls/navigate.
Resources:
- Build ccls for Windows Make sure that the final executable location is included in system path.
Install Vim for Windows: Installers
Install Spacevim
Asynchronous linting/fixing for Vim and Language Server Protocol (LSP) integration ALE
I use ALE for linting with clang-tidy, and code formatting with clang-format
Install Vim Language Server Protocol client coc.nvim
I use coc.vim to provide vim with all other LSP IDE features (leaving only formatting and linting to ALE).
Convenient vim key bindings for these tasks are configured in my cpptaks.vim file
Note that it's essential to have a compile_commands.json
file in the root of your project for LSP features to work.
This file is produced as a byproduct of the cmake compilation with the help of a flag. See tasks
folder in sfml-project.
Library dependencies of your cpp projects can be installed in your MSYS environment with the help of the pacman package manager.
This is just a brief (but complete) outline of the setup, it's up to you to work out the details with the help of the linked resources.