Feature request: Environment variable for using source file's current folder in `common_flags`
See original GitHub issueWe have these options to define include dirs in the plugin settings:
// Every path variable in settings can contain wildcards (without the ""):
// - "$project_base_path" <-- replaced by the full path to the project to
// which the currently opened view belongs.
// - "$project_name" <-- replaced by the name of the current project.
// - "$clang_version" <-- replaced by the numeric version of used clang.
// - "~" <-- replaced by the path to user home directory.
//
// In addition to these, you can use your environment variables:
// - OSX and Linux: $variable_name or ${variable_name}
// - Windows: $variable_name or ${variable_name} or %variable_name%
// Specify common flags that will be passed to clang for EVERY build.
"common_flags" : [
// some example includes
"-I/usr/include",
"-I$project_base_path/src",
// this is needed to include the correct headers for clang
"-I/usr/lib/clang/$clang_version/include"
],
If you use Sublime that your Opened Project folder (D:\www
) is where all of your dev projects stored (i.e. lots of subfolders where your real projects reside, for example: D:\www\cpp\asio
, D:\www\node\koa
, D:\www\html\personal-portfolio
, etc.), so these environment variables:
"-I$project_base_path/src",
"-I$project_base_path/include",
"-I%cd%/include",
Simply not giving you the desired paths. Also, the windows environment variable like %cd%
simply didn’t included in the verbose output that I included below (probably this also can be MSYS2 issue, because clang insalled in that, not native MSVC version). $project_base_path
is just a confusing name, because you expect to get your current folder where your source .cpp
files resides for linting, but instead you got:
DEBUG:EasyClangComplete.plugin.settings.settings_storage: populated '-I$project_base_path/src' to '-ID:\www/src'
DEBUG:EasyClangComplete.plugin.settings.settings_storage: populated '-I$project_base_path/include' to '-ID:\www/include'
DEBUG:EasyClangComplete.plugin.settings.settings_storage: populated '-I/usr/lib/clang/$clang_version/include' to '-I/usr/lib/clang/3.9.1/include'
But what should I want to have, if you open a .cpp
file at D:\www\cpp\asio\src\main.cpp
location, these lines should be:
DEBUG:EasyClangComplete.plugin.settings.settings_storage: populated '-I$current_path/include' to '-ID:\www\cpp\asio\src\include'
Something like $current_path
would be nice to have, if the Windows environment variables doesn’t work thanks to MSYS2, Cygwin, compatibility issues. I think it’s not impossible because these lines already giving the desired paths:
DEBUG:EasyClangComplete.plugin.tools: searching 'CMakeLists.txt' from 'D:\www\cpp\asio\src' to 'D:\\www'
DEBUG:EasyClangComplete.plugin.tools: searching 'compile_commands.json' from 'D:\www\cpp\asio\src' to 'D:\\www'
DEBUG:EasyClangComplete.plugin.tools: searching '.clang_complete' from 'D:\www\cpp\asio\src' to 'D:\\www'
For many starters like me who learning C++, dealing with Cmake is just utterly confusing, that’s why would be much simpler to have an option like $current_path
in EasyClangComplete.
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (1 by maintainers)
Have you tried using .clang_complete file? I am not sure what your problem exactly is but you could do something like this: D:\www\P1\ .clang_complete D:\www\P2\ .clang_complete D:\www\P3\ .clang_complete
Then when working on file in P1 you would use includes from P1\ .clang_complete etc.
Wow, I did the opposite. 😁 I left VSCode in favor of Sublime Text since VSCode consumed way too much memory for me. I hope @simia still uses Sublime.