alexstaubo/sublime_text_alternative_autocompletion — Issue #8: Populate candidates with sensible defaults (feature request)
Author: colinta
Created: 2012-01-10 17:13:55+00:00
State: open

This is especially handy in PHP, where I often type `array_m` + ESC, and expect `array_merge` (or `array_map`) to appear, even though it's not in by buffer. In name-spaced languages like python this would be trickier, but could still useful I think. Anyway, implementation is easy enough.

My idea is that a list of words could "seed" the `candidates` variable in the `find_candidates` function. I'm imagining a system that uses built-ins and the user's language-specific settings file, so that this list could be configured per-language.

Built-in config files are easy enough:

```python
view = self.window.active_view()
settings_name, _ = os.path.splitext(os.path.basename(view.settings().get('syntax')))
default_settings = sublime.load_settings("alternative_autocompletion.sublime-settings")
candidates = default_settings[settings_name]
```

And to make things even better, combine that list with `User/__language__.sublime-settings`.

```python
user_settings = sublime.load_settings(settings_name + ".sublime-settings")
candidates = candidates.extend(user_settings['autocomplete']) # extend? override?
```

The built-in settings file is simple enough:

```json
{
"php": ["array_merge", "array_map", "..."],
"python": ["splitext", "..."]
}
```

And user settings:

```json
{
// ...
"autocomplete": ["entitize", "..."],
//...
}
```