cquery icon indicating copy to clipboard operation
cquery copied to clipboard

[feature-request] A global ~/.config/cquery/settings file

Open skywind3000 opened this issue 7 years ago • 8 comments

I have to copy same .cquery every where, it contains only few lines:

%clang
%c -std=gnu11
%cpp -std=gnu++14
-pthread

# Includes
-ID:/dev/mingw/include

Can I have a global .cquery file like C:\Users\MyName\.config\cquery\settings to setup include paths ?? YouCompleteMe can allow me have a global config.

skywind3000 avatar Apr 24 '18 10:04 skywind3000

Sure, this sounds reasonable.

jacobdufault avatar Apr 24 '18 21:04 jacobdufault

I'm interested in implementing this feature. I've been looking over the code base and am struggling to find where the .cquery file is loaded. Could someone point me in the right direction?

nick96 avatar Jun 05 '18 04:06 nick96

This function handles loading from .cquery: https://github.com/cquery-project/cquery/blob/1fa36852b5dbe0d8e8207b1362a150c722a077c7/src/project.cc#L456-L514

jacobdufault avatar Jun 07 '18 06:06 jacobdufault

Great! Thank you :smile:

A couple things:

  1. On *nix it is probably best to get the .cquery file from $HOME/.config/cquery as opposed to just putting it at $HOME
  2. On Windows what is the convention for config files? Looking here it seems that C:\Users\<user>\AppData\Roaming\cquery would be the best spot.

What I plan to do:

  • Only read the global config file in absence of a project specific one
  • Read the global config file from one location only
    • $XDG_CONFIG_HOME/cquery on *nix
    • For windows, the value of config_path + "/cquery" in:
SHGetKnownFolderPath ( FOLDERID_RoamingAppData, KF_FLAG_CREATE, NULL, &config_path )))

nick96 avatar Jun 08 '18 09:06 nick96

For linux, what about reading $XDG_CONFIG_HOME and defaulting to $HOME/.cquery if not present?

A single global config SGTM.

Adding a function GetGlobalConfigDir to platform.h is one potential approach.

jacobdufault avatar Jun 08 '18 16:06 jacobdufault

FYI, per XDG basedir convention, config dir should be at $HOME/.config/cquery/ when XDG_CONFIG_HOME is not defined and $XDG_CONFIG_HOME/cquery/ when it is. So if it is desired to be consistent with this generally spottily-followed specification, this isn't really doing it right. However, this is an improvement over only $HOME/.cquery, IMO.

I've done a few XDG basedir retrofits, and I've usually checked for the original config file in $HOME, and if it doesn't exist there follow the basedir spec. This way no one's existing config breaks and the basedir spec is followed for new installs.

ambihelical avatar Jul 02 '18 04:07 ambihelical

Is it possible to have environment variables in the .cqeury file?

I use conda and installed my gcc compilers inside conda environment. The include path should look like -I$CONDA_PREFIX/include/c++/6.1.0

liushapku avatar Dec 17 '18 06:12 liushapku

I don't know. I think most of the config file stuff is just passed on to clang and a quick google doesn't suggest anything. I did a quick test on my machine and it didn't seem to effect code completion. Does it work for you?

nick96 avatar Jan 12 '19 14:01 nick96