Skip to content
This repository has been archived by the owner on Nov 29, 2020. It is now read-only.

Add tags completion support #72

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
20 changes: 14 additions & 6 deletions lib/config.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -14,34 +14,42 @@ 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.
'
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.
'
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.
Expand All @@ -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.
Expand All @@ -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**.
Expand Down
5 changes: 3 additions & 2 deletions lib/get-completions.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 5 additions & 2 deletions lib/handler.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/provider.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ command = require './command'

module.exports =
selector: '*'
inclusionPriority: 2
suggestionPriority: 2
inclusionPriority: 0
suggestionPriority: 1
excludeLowerPriority: false

grammarScopes: ['*']
Expand Down
2 changes: 2 additions & 0 deletions lib/utility.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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) ->
Expand Down