Coder Social home page Coder Social logo

autocomplete-plus's Introduction

Atom and all repositories under Atom will be archived on December 15, 2022. Learn more in our official announcement

Autocomplete+ package

macOS Build Status Windows Build status Dependency Status

Displays possible autocomplete suggestions on keystroke (or manually by typing ctrl-space) and inserts a suggestion in the editor if confirmed.

autocomplete+

Changelog

Installation

autocomplete+ is bundled with Atom. You don't have to do anything to install it.

Providers

autocomplete+ has a powerful autocomplete provider API, allowing provider authors to add language-specific behavior to this package.

You should definitely install additional providers (the default provider bundled with this package is somewhat crude): https://github.com/atom/autocomplete-plus/wiki/Autocomplete-Providers

Usage

Just type some stuff, and autocomplete+ will automatically show you some suggestions. Press UP and DOWN to select another suggestion, press TAB or ENTER to confirm your selection. You can change the default keymap in Preferences:

  • Keymap For Confirming A Suggestion

Additionally, the confirm keymap can be customized in your keymap.cson:

'atom-text-editor.autocomplete-active':
  'tab': 'unset!'
  'ctrl-shift-a': 'autocomplete-plus:confirm'

If setting custom keybindings, use the none setting for the confirmation keymap. All this option does is not set any other keybindings. This allows the TAB and ENTER keys to be used like normal, without side effects.

Remapping Movement Commands

By default, autocomplete-plus commandeers the editor's core movement commands when the suggestion list is open. You may want to change these movement commands to use your own keybindings.

First you need to set the autocomplete-plus.useCoreMovementCommands setting to false, which you can do from the autocomplete-plus settings in the settings view.

core-movement

Or by adding this to your config file:

"*":
  "autocomplete-plus":
    "useCoreMovementCommands": false

Then add these to your keymap file:

'body atom-text-editor.autocomplete-active':
  'ctrl-p': 'autocomplete-plus:move-up'
  'ctrl-n': 'autocomplete-plus:move-down'
  'pageup': 'autocomplete-plus:page-up'
  'pagedown': 'autocomplete-plus:page-down'
  'home': 'autocomplete-plus:move-to-top'
  'end': 'autocomplete-plus:move-to-bottom'

Features

  • Shows suggestions while typing
  • Includes a default provider (SymbolProvider):
    • Wordlist generation happens when you open a file, while editing the file, and on save
    • Suggestions are calculated using fuzzaldrin
  • Exposes a provider API which can be used to extend the functionality of the package and provide targeted / contextually correct suggestions
  • Disable autocomplete for file(s) via blacklisting, e.g. *.md to blacklist Markdown files
  • Disable autocomplete for editor scope(s) via blacklisting
  • Expands a snippet if an autocomplete+ provider includes one in a suggestion
  • Allows external editors to register for autocompletions

Provider API

Great autocomplete depends on having great autocomplete providers. If there is not already a great provider for the language / grammar that you are working in, please consider creating a provider.

Read the Provider API documentation to learn how to create a new autocomplete provider.

SymbolProvider Configuration

If the default SymbolProvider is missing useful information for the language / grammar you're working with, please take a look at the SymbolProvider Config API.

The watchEditor API

The watchEditor method on the AutocompleteManager object is exposed as a provided service, named autocomplete.watchEditor. The method allows external editors to register for autocompletions from providers with a given set of labels. Disposing the returned object will undo this request. External packages can access this service with the following code.

In package.json:

{
  "consumedServices": {
    "autocomplete.watchEditor": {
      "versions": {
        "1.0.0": "consumeAutocompleteWatchEditor"
      }
    }
  }
}

In the main module file:

consumeAutocompleteWatchEditor(watchEditor) {
  this.autocompleteDisposable = watchEditor(
    this.editor, ['symbol-provider']
  )
}

autocomplete-plus's People

Contributors

50wliu avatar abe33 avatar aerijo avatar as-cii avatar benogle avatar boykoalex avatar braver avatar damieng avatar jasonrudolph avatar jeancroy avatar joefitzgerald avatar kevinnathan avatar kevinsawicki avatar lee-dohm avatar leroix avatar maxbrunsfeld avatar mcolyer avatar mnquintana avatar nixel2007 avatar park9140 avatar pfitzseb avatar phyllisstein avatar rafeca avatar sadikovi avatar saschagehlich avatar simurai avatar smashwilson avatar tinloaf avatar vito avatar yongkangchen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

autocomplete-plus's Issues

Case sensitivity bugs

It seems that once you've finished a "word", it gets removed from the list of candidates. But then what happens is if you hit "tab", what you've typed will get completely replaced with a very different word.

Here's an example in Java, with the words thread and Thread. When you start typing say the first few characters of thread, the primary suggested match is thread as expected, but when I type the last letter (d), it suddenly changes to Thread. Exact opposite thing happens when typing Thread.

image

image

Also in general, I think matching case should take higher priority for selecting the first match, or at least there should be an option. In this example, I think downloadThread should be the main suggestion instead of DownloadTask.
image

Save should dismiss suggestions

If there are suggestions present when I save the file, the suggestions should be dismissed. Save implies I'm already done. Thoughts?

Nice work btw. I was used to this feature in Sublime Text.

Keyword auto completion

In ruby i am getting autocompletion on keywords like 'do'. The keyword is not in the suggestions list so you end up with something like 'double' instead

Snippet completion / suggestions

It would be really helpful if snippets could be part of the completion list. Currently you have to esc from the suggested completions and then tab complete the snippet.

Repeating special characters when "Live Completion" is enabled

When I type ` or ^ (for example) using the "Live Completion" mode enabled the following happens:

error

The character is repeated multiple times and the buffer is now in a buggy state. Using the package with live completion turned off works great though :).

Tested on version 0.7.0 and 0.8.0.

Ability to go fully case Sensitive?

Perhaps it's just me being use to the editor I came from before Atom but I would love to make autocomplete be 100% case sensitive. To me foo is completely different from Foo and when I type Fo I don't want to be presented with foo as an autocomplete option.

Closing tab with Autosave causes JavaScript error and Inspector to open

Steps to reproduce:

  1. Enable the default atom/autosave package
  2. Open an existing JavaScript file or CoffeeScript file
  3. Click the close tab X icon or press cmd+w
  4. Inspector opens with the following error message Uncaught TypeError: Cannot call method 'getBufferPosition' of undefined /Applications/Atom.app/Contents/Resources/app/src/editor.js:1246

It seems that it's trying to get the caret position for autocomplete on the file that was just saved and closed.

Move The Package Into Core / Upstream The Package

Would be really great if the provider API worked with both.

The worst thing that could happen is if the atom package implemented a different API. Then authors would have to either choose one, or support both. Neither of those is a great option.

I don't know how this is architected internally, and maybe its difficult to upstream as its currently written. But if that isn't the case, would be great.

getBufferRange Error

Window load time: 720ms /Applications/Atom.app/Contents/Resources/app/src/window-bootstrap.js:18
2
Uncaught TypeError: Cannot call method 'getBufferRange' of undefined /Applications/Atom.app/Contents/Resources/app/node_modules/text-buffer/lib/history.js:99
23
Uncaught TypeError: Cannot call method 'getBufferRange' of undefined fuzzy-provider.coffee:95
Uncaught TypeError: Cannot call method 'getBufferRange' of undefined /Applications/Atom.app/Contents/Resources/app/node_modules/text-buffer/lib/history.js:99
Uncaught TypeError: Cannot call method 'getBufferRange' of undefined /Applications/Atom.app/Contents/Resources/app/node_modules/atom-keymap/lib/keymap-manager.js:390

What about showing on delay?

Having it live seems to bothersome when I'm writing comments. What about turning it off when I'm writing comments, or only turn it on after a slight delay?

API

Other packages should be able to use the Autocomplete+ UI

Modify Provider / Suggestion API To Be Asynchronous

Curently, runAutocompletion is an synchronous API, calling each Provider in order for suggestions. It might be more appropriate to make this an asynchronous, event-driven API. This presents obvious challenges for aggregation of suggestions, but should discourage any misbehaving providers from blocking unnecessarily.

Appears to Conflict with Autosave

Running this with Autosave on causes the file to get repeated "This file has changed on disk" warnings, requiring a reload of the file.

Not working for me, not sure why

I just installed this fresh after uninstalling. Quit Atom and re-opened, just to make sure. Menu with autocomplete suggestions never comes up. Something I need to do that I'm not seeing in the Readme?

Using Korean input messes up atom

Hello,

when having autocomplete plus installed and switching to the Korean 2 set input, the editor goes crazy. A single character will result in a line of Korean characters, keyboard navigation is no longer working and mouse interaction neither.

The only way to recover from this state is to cmd+w the tab, discard changes and open again, this time with US layout.

Tested on 2 Macbooks running OS X 10.9.2.
Atom version 0.85.9

Korean layout used is the normal 2 set one that ships with OS X.

Uncaught TypeError: Cannot read property 'length' of undefined

When using my package 'git-plus' to save a commit message file, this gets thrown the first time core:save is triggered but saving will work the second time.

Stack trace:

Uncaught TypeError: Cannot read property 'length' of undefined    
  /Applications/Atom.app/Contents/Resources/app/node_modules/text-buffer/lib/text-buffer.js:154
module.exports.TextBuffer.lineLengthForRow     
  /Applications/Atom.app/Contents/Resources/app/node_modules/text-buffer/lib/text-buffer.js:154
module.exports.Editor.lineLengthForBufferRow  
  /Applications/Atom.app/Contents/Resources/app/src/editor.js:429
module.exports.FuzzyProvider.lastTypedWord 
  fuzzy-provider.coffee:104
module.exports.FuzzyProvider.addLastWordToList 
  fuzzy-provider.coffee:81
module.exports.FuzzyProvider.onChanged 
  fuzzy-provider.coffee:73
(anonymous function) 
  fuzzy-provider.coffee:1

The error only occurs when a new line isn't entered in the commit message.
It seems to me as if the newLine variable is true when it should be false because there is no \n or ' '

Optional Confirm Key

I have so many issues using this, as I am used to autocomplete-confirm with the ENTER key, instead of tab. Would love a way to configure this in the settings pane. Could this be added?

Enter makes problem

Each time I use autocomplete, if I pressed Enter instead of Space.
The cursor is missing, and any typing will not work. Until I use Cmd+S save the file.

1

Add priority stuff to suggestions

As propsed by @pjv, we should add some priority stuff to the suggestions:

  • matches from the current language syntax file
  • matches from snippets for the current language
  • matches from word list from the current file buffer

Laggy moving cursor in large files when autosave is enabled

This could be related to #13.

Steps to reproduce:

  1. Open System Preferences, click Keyboard and set Key Repeat to the highest setting (Fast)
  2. Enable the default atom/autosave package
  3. Open an existing large JavaScript file e.g. over 100 lines (say backbone.js)
  4. Press & hold the down arrow and notice how laggy the cursor moves between lines (same with up arrow). CPU usage also spikes with the Atom Helper process jumping to around 99% usage, while the down arrow is being pressed.

Note when autosave is disabled cursor moves with less lag.

Typing cmd+s or trying to save a file, opens the dev tools with an exception

How to reproduce:

open a folder with atom, with some files inside
open a file in the editor
hit cmd+k and an arrow to make a split panel
hit cmd+w to close the new panel
now whenever you hit cmd+s to save, you get the dev tools with the below error

Uncaught TypeError: Cannot call method 'getBufferPosition' of undefined 

screen shot 2014-03-19 at 13 46 32

If I disable the plugin, save behaves normally and I don't get the dev tools.

Return Functionality Compromised

When editing a Markdown or Ruby, if I hit Return while the autocomplete box is open, it will enter a carriage return but not allow me to type anything else. I have to move to a new tab or Cmd-Tab out of the app and back in order to regain my control.

Autocompleting multiple selections at once

When using d or manually selecting multiple instances of a symbol and autocompleting will append the entire autocompletion to the stubs of every selection but the last. For example:

<div cla>
...
<div cla>
...
<div cla>

selecting all of the 'cla' and typing 'clas', then tab completing to 'class' will result in

<div clasclass>
...
<div clasclass>
...
<div class>

Configurable "Accept" Key

Other editors like Sublime Text allow you to disable "Accepting" a suggestion on enter. For example, I get to the end of a line, and hit enter to return to the next line, but there was a suggestion that gets accepted instead.

In ST when you disable accept on enter, if there is a suggestion when you hit enter, it just returns to the next line. This would be my preferred behavior.

Remove enter as default confirmation key

The tooltip with the suggestions shouldn't have an option selected by default.
Im using this with the "live completion" enabled, but because of the default selection I can't using in conjunction with emmet or even with my custom snippets. This happens because when I try to expand a snippet, most of the times there's a autocomplete suggestion that will expand instead.

Suggestions contain words for wrong scope

Since we only generate the wordlist from time to time, it might contain suggestions for the wrong scope. Solution: Don't put scope words into the wordlist per default, just merge them with the wordlist every time we display suggestions.

Laggy when indenting large selection

Steps to reproduce:

  1. With autocomlete-plus 0.14.0 as the only 3rd package installed.
  2. Using the markup in this gist https://gist.github.com/mcanas/10888195, paste the code into Atom
  3. Select All
  4. Click the Tab button

Indentation lags by 15-20 seconds.

Attaching a few views of the console timeline.

Without autocomplete-plus:
screen shot 2014-04-16 at 3 04 50 pm

With autocomplete-plus:
screen shot 2014-04-16 at 3 02 37 pm

[React editor] Stopping text input after displaying autocompletion box

Hi, I'm trying your plugin but it's clearly not working as expected, on my install. When I type something, after one or two chars, the autocomplete box pops up, and if I keep typing it doesn't go away. The only way to close it is either hit Esc or select an autocomplete option with Up and Down and then hitting Enter.

Here are my current settings.

screen shot 2014-04-24 at 14 08 58

Thanks for your work!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.