Spacemacs as c++ ide

 

Introduction

In this article, you will see how to turn spacemacs into C++ ide.

Installation steps

Windows

Prerequisite

  • Install spacemacs - windows
  • Install cscope - windows
    • download the binary and put it into os environment path
  • Install gnu global - windows
    • download the binary and put it into os environment path
  • Install the script for windows or linux into os environment path

The script

:: prepareSpacemacsTags.bat
SET script_path=%~dp0
echo %script_path:~0,-1%
SET buildPath=%cd%
echo %buildPath%

:: remove old tags
del ${buildPath}/GPATH
del ${buildPath}/GRTAGS
del ${buildPath}/GTAGS

del ${buildPath}/cscope.files
del ${buildPath}/cscope.out
del ${buildPath}/cscope.in.out
del ${buildPath}/cscope.po.out

:: make tags
echo "######### make GTag"
gtags.exe
echo "######### make cscope"
dir /b/s | findstr /i /r "\.c$ \.cpp$ \.cc$ \.h$ \.hpp$" > cscope.files
cscope.exe -q -R -b -k -i cscope.files

How to use

# test it
$ cd path/to/your/cpp/project
$ prepareSpacemacsTags.bat

Linux

Prerequisite

# install tagging tools
$ sudo apt-get install global cscope

# test it
$ cd path/to/your/cpp/project
$ prepareSpacemacsTags.sh

The script

#!/bin/bash
buildPath="$PWD"


# remove old tags
rm ${buildPath}/GPATH
rm ${buildPath}/GRTAGS
rm ${buildPath}/GTAGS

rm ${buildPath}/cscope.files
rm ${buildPath}/cscope.out
rm ${buildPath}/cscope.in.out
rm ${buildPath}/cscope.po.out

# make tags
echo "######### make GTag"
gtags
echo "######### make cscope"
find . -name "*.cc" -o -name "*.c" -o -name "*.cpp" -o -name "*.h" -o -name "*.hpp" > cscope.files
cscope -q -R -b -k -i cscope.files

How to use

# test it
$ cd path/to/your/cpp/project
$ prepareSpacemacsTags.sh


Comments