Using Atom as a C/C++ Ide (linux)
I dont like heavyweight IDEs such as eclipse or even VSCode/Codium.
I much prefer light ones, such as netbeans.
I want them to be just a thin wrapper on top of my CMake projects, and that they start in a second or so.
For quick edit, (N)Vim + coc.vim is incredibly powerful, but for big projects i prefer something more comfortable.
So i gave Atom a try, and it's pretty good. Really good actually.
The thing is you have to install a bunch of plugins to configure it to be a C/C++ IDE.
And as a bonus, the code completion setup is similar to the setup for coc.vim, so i can setup it once, and it works for both.
Coc.vim is superior imho for c++, but the Atom is more confortable for large projects.
Atom configuration
So here we go (ubunto 20, it 's a bit more complicated for windows but similar ( use chocolatey for example) :
1- Install Atom . Nothing special here.
2- Install the following plugins. Edit->Preferences->Install
linterlinter-gccatom-ide-baseatom-ide-uiatom-ide-definitionside-c-cppide-cclsbuildbuild-cmake
Per project configuration
mkdir -p buildAtomcd buildAtomcmake -DCMAKE_EXPORT_COMPILE_COMMANDS=True ..cd ..
compdb -p buildAtom/ list > compile_commands.json
We are creating a fake cmake build where we ask cmake for dependencies and feed that to ccls. That will enable code completion etc..
3- Create a default CMakeSettings.json (if you dont it will NOT Work properly, even if it's basically defaults)
{
"configurations": [
{
"name": "Debug",
"generator": "Unix Makefiles",
"configurationType" : "Debug",
"buildRoot": "${projectDir}/build",
"cmakeCommandArgs": "",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"variables": [{
"name": "TEST_VAR",
"value": "ON"
}]
}
]
}
4- File -> addFolder : your favorite project
The basic C/C++ setup is done. You can tweak things (compilation flags...) etc.. but that setup works "as-is" as a start.
You can toggle between generate cmake project and build cmake project with the pulldown menu on the bottom left (default is Debug:generate you probably want Debug:build all)
That includes :
- Syntax highlighting
- On the fly code suggestion
- On the fly linter (with some false warnings if you didnt set it up completely, but good enough imho)
Now you use the following default keybindings :
- Ctrl+Click on a symbol : Go to definition
- Ctrl+Alt+B : Generate cmake or build (change it through the small menu on the bottom left)
- Ctrl+Alt+H : Go to next build error
Comments
Post a Comment