Skip to content

Commit a756cd5

Browse files
committed
use project options file
1 parent e16ab99 commit a756cd5

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

CTags.sublime-settings

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,5 +163,11 @@
163163
//
164164
// Different tags generators may generate this non-standard field in
165165
// different formats
166-
"scope_re": "(\\d.*?):(\\d.*?)-(\\d.*?):(\\d.*?)"
166+
"scope_re": "(\\d.*?):(\\d.*?)-(\\d.*?):(\\d.*?)",
167+
168+
// Enable use project options file
169+
"enable_project_option": false,
170+
171+
// Default options file name
172+
"options_file": "ctags.cnf"
167173
}

ctagsplugin.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -821,6 +821,7 @@ def run(self, edit, **args):
821821
recursive = setting('recursive')
822822
opts = setting('opts')
823823
tag_file = setting('tag_file')
824+
opts = self.append_project_options(opts)
824825

825826
if 'dirs' in args and args['dirs']:
826827
paths.extend(args['dirs'])
@@ -894,6 +895,30 @@ def tags_built(tag_file):
894895

895896
GetAllCTagsList.ctags_list = [] # clear the cached ctags list
896897

898+
def append_project_options(self, opts):
899+
"""
900+
append ctags.cnf path to opts.
901+
"""
902+
window = sublime.active_window()
903+
904+
if setting('enable_project_option') is True:
905+
project_file_path = window.project_file_name()
906+
if project_file_path is None:
907+
return opts
908+
project_file_path = os.path.dirname(project_file_path)
909+
project_path = window.project_data()['folders'][0]['path']
910+
options_file = setting('options_file')
911+
options_file_path = os.path.join(
912+
project_file_path,
913+
project_path,
914+
options_file)
915+
if os.path.isfile(options_file_path) is True:
916+
import platform
917+
if platform.platform().find('Windows') >= 0:
918+
options_file_path = options_file_path.replace('\\', '\\\\')
919+
opts.append('--options=%s' % options_file_path)
920+
return opts
921+
897922
# Autocomplete commands
898923

899924

0 commit comments

Comments
 (0)