diff --git a/lib/config.coffee b/lib/config.coffee index 58001f5..1880dd9 100644 --- a/lib/config.coffee +++ b/lib/config.coffee @@ -14,11 +14,19 @@ module.exports = The directory containing the `ycmd/default_settings.json` file. [Ycmd](https://github.com/Valloric/ycmd) is required for this plugin to work. ' + ycmdSettingPath: + type: 'string' + default: 'ycmd/default_settings.json' + order: 3 + description: ' + The `default_settings.json` to start ycmd server. + Copy the `ycmd/default_settings.json` file and modify as needed. + ' enabledFiletypes: type: 'array' items: type: 'string' default: ['c', 'cpp', 'objc', 'objcpp'] - order: 3 + order: 4 description: ' An array of filetypes within we should provide completions and diagnostics. They are equivalent to file extensions most of the time. @@ -26,14 +34,14 @@ module.exports = linterEnabled: type: 'boolean' default: true - order: 4 + order: 5 description: ' Disable linter if you do not need those diagnostic messages. ' globalExtraConfig: type: 'string' default: '' - order: 5 + order: 6 description: ' The fallback extra config file when no `.ycm_extra_conf.py` is found. Follow [this link](https://github.com/Valloric/YouCompleteMe#the-gycm_global_ycm_extra_conf-option) for more information. @@ -41,7 +49,7 @@ module.exports = confirmExtraConfig: type: 'boolean' default: true - order: 6 + order: 7 description: ' Whether to ask once before loading an extra config file for safety reason. To selectively whitelist or blacklist them, use **Extra Config Globlist** option. @@ -51,7 +59,7 @@ module.exports = type: 'array' items: type: 'string' default: [] - order: 7 + order: 8 description: ' Extra config files whitelist and blacklist, e.g. `~/dev/*, !~/*` would make it load all `.ycm_extra_conf.py` under `~/dev/` and not to load all other `.ycm_extra_conf.py` under `~/`, without confirmation. @@ -60,7 +68,7 @@ module.exports = rustSrcPath: type: 'string' default: '' - order: 8 + order: 9 description: ' The directory containing the [Rust source code](https://github.com/rust-lang/rust). You have also to to add `rust` in **Enabled Filetypes**. diff --git a/lib/get-completions.coffee b/lib/get-completions.coffee index d20da67..b0a22de 100644 --- a/lib/get-completions.coffee +++ b/lib/get-completions.coffee @@ -27,11 +27,12 @@ convertCompletions = ({completions, prefix, filetypes}) -> text: completion.insertion_text replacementPrefix: prefix displayText: completion.menu_text - leftLabel: completion.extra_menu_info + leftLabel: completion.extra_menu_info.replace(/(^\[|\]$)/g, '') rightLabel: completion.kind description: completion.detailed_info - suggestion.type = switch completion.kind + suggestion.type = switch completion.extra_menu_info when '[File]', '[Dir]', '[File&Dir]' then 'import' + when '[ID]' then 'tag' else null return suggestion diff --git a/lib/handler.coffee b/lib/handler.coffee index c2950e3..c74b814 100644 --- a/lib/handler.coffee +++ b/lib/handler.coffee @@ -33,8 +33,11 @@ launch = (exit) -> reject error readDefaultOptions = new Promise (fulfill, reject) -> - defaultOptionsFile = path.resolve atom.config.get('you-complete-me.ycmdPath'), 'ycmd', 'default_settings.json' - fs.readFile defaultOptionsFile, encoding: 'utf8', (error, data) -> + customOptionsFile = path.resolve atom.config.get('you-complete-me.ycmdSettingPath') + fs.exists customOptionsFile, (exists) -> + unless exists? + customOptionsFile = path.resolve atom.config.get('you-complete-me.ycmdPath'), 'ycmd', 'default_settings.json' + fs.readFile customOptionsFile, encoding: 'utf8', (error, data) -> unless error? fulfill JSON.parse data else diff --git a/lib/provider.coffee b/lib/provider.coffee index 370acfe..bbf751f 100644 --- a/lib/provider.coffee +++ b/lib/provider.coffee @@ -5,8 +5,8 @@ command = require './command' module.exports = selector: '*' - inclusionPriority: 2 - suggestionPriority: 2 + inclusionPriority: 0 + suggestionPriority: 1 excludeLowerPriority: false grammarScopes: ['*'] diff --git a/lib/utility.coffee b/lib/utility.coffee index 610790a..9aa9a3e 100644 --- a/lib/utility.coffee +++ b/lib/utility.coffee @@ -35,6 +35,7 @@ buildRequestParameters = (filepath, contents, filetypes = [], bufferPosition = n convertFiletypes = (filetypes) -> filetypes.map((filetype) -> switch filetype when 'js', 'jsx' then 'javascript' + when 'ahk' then 'autohotkey' else filetype ).filter (filetype, index, filetypes) -> filetypes.indexOf(filetype) is index workingDir = getWorkingDirectory() @@ -44,6 +45,7 @@ buildRequestParameters = (filepath, contents, filetypes = [], bufferPosition = n line_num: bufferPosition.row + 1 column_num: bufferPosition.column + 1 file_data: {} + tag_files: ['.tags', 'tags'].map (t) -> path.join(workingDir, t) parameters.file_data[filepath] = {contents, filetypes: convertFiletypes filetypes} atom.workspace.getTextEditors() .filter (editor) ->