diff --git a/README.md b/README.md index 7b802c1e8d..93451d1bee 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ It is reasonably fast, taking ~10 seconds to generate a configuration file for t ## Usage Run ```./config-gen.py PROJECT_DIRECTORY```, where ```PROJECT_DIRECTORY``` is the root directory of your project's build system (i.e. the one containing the root Makefile, etc.) -YCM-Generator can also be used as a Vim plugin. Once installed with Vundle/NeoBundle/etc., use the ```:YcmGenerateConfig``` command to generate a config file for the current directory. +YCM-Generator can also be used as a Vim plugin. Once installed with Vundle/NeoBundle/etc., use the ```:YcmGenerateConfig``` command to generate a config file for the current directory. This command accepts the same arguments as ```./config-gen.py```, but does not require the project directory to be specified (it defaults to the current working directory). ## Requirements and Limitations * Requirements: diff --git a/plugin/ycm-generator.vim b/plugin/ycm-generator.vim index c84b62cce7..a396f21c42 100644 --- a/plugin/ycm-generator.vim +++ b/plugin/ycm-generator.vim @@ -1,10 +1,17 @@ let s:config_gen = expand(":p:h:h") . "/config_gen.py" -command -nargs=0 YcmGenerateConfig call s:YcmGenerateConfig() +command -nargs=? YcmGenerateConfig call s:YcmGenerateConfig("") + +function s:YcmGenerateConfig(flags) + let l:cmd = "! " . s:config_gen . " " . a:flags + + " Only append the working directory if the last option is not a flag + let l:split_flags = split(a:flags) + if len(l:split_flags) == 0 || l:split_flags[-1] =~ "^-" + let l:cmd = l:cmd . " " . getcwd() + endif -function s:YcmGenerateConfig() - let l:cmd = "! " . s:config_gen . " " . getcwd() execute l:cmd endfunction