diff --git a/CTags.sublime-settings b/CTags.sublime-settings index 3b60e94..21235d7 100644 --- a/CTags.sublime-settings +++ b/CTags.sublime-settings @@ -163,5 +163,11 @@ // // Different tags generators may generate this non-standard field in // different formats - "scope_re": "(\\d.*?):(\\d.*?)-(\\d.*?):(\\d.*?)" + "scope_re": "(\\d.*?):(\\d.*?)-(\\d.*?):(\\d.*?)", + + // Enable use project options file + "enable_project_option": false, + + // Default options file name + "options_file": "ctags.cnf" } diff --git a/ctagsplugin.py b/ctagsplugin.py index d3e918d..5c6fc8b 100644 --- a/ctagsplugin.py +++ b/ctagsplugin.py @@ -821,6 +821,7 @@ def run(self, edit, **args): recursive = setting('recursive') opts = setting('opts') tag_file = setting('tag_file') + opts = self.append_project_options(opts) if 'dirs' in args and args['dirs']: paths.extend(args['dirs']) @@ -894,6 +895,30 @@ def tags_built(tag_file): GetAllCTagsList.ctags_list = [] # clear the cached ctags list + def append_project_options(self, opts): + """ + append ctags.cnf path to opts. + """ + window = sublime.active_window() + + if setting('enable_project_option') is True: + project_file_path = window.project_file_name() + if project_file_path is None: + return opts + project_file_path = os.path.dirname(project_file_path) + project_path = window.project_data()['folders'][0]['path'] + options_file = setting('options_file') + options_file_path = os.path.join( + project_file_path, + project_path, + options_file) + if os.path.isfile(options_file_path) is True: + import platform + if platform.platform().find('Windows') >= 0: + options_file_path = options_file_path.replace('\\', '\\\\') + opts.append('--options=%s' % options_file_path) + return opts + # Autocomplete commands