Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature request - live autocomplete #5

Open
rofrol opened this issue Mar 12, 2017 · 7 comments
Open

feature request - live autocomplete #5

rofrol opened this issue Mar 12, 2017 · 7 comments

Comments

@rofrol
Copy link

rofrol commented Mar 12, 2017

It would be nice to have it. I still hasn't learned elm native to make pull request though.

@therustmonk
Copy link
Owner

Do you want to have a capability to activate the following options: enableBasicAutocompletion, enableSnippets, enableLiveAutocompletion, right?

@therustmonk
Copy link
Owner

I've released 2.2.0 version with the options above and extensions (look to the example). Check it, please.

@rofrol
Copy link
Author

rofrol commented May 18, 2017

I'm running your example but don't get autocompletion.

I have an example that I have to port to Elm and it's initiated like below. It sends completion request to the RServe:

var langTools = ace.require("ace/ext/language_tools");
var pre_process = ace.edit('pre_process');
pre_process.setTheme('ace/theme/crimson_editor');
pre_process.getSession().setMode('ace/mode/r');
pre_process.setOptions({
  enableBasicAutocompletion: true
  , enableLiveAutocompletion: true
});
var Rcompleter = {getCompletions: getCompletions}
langTools.addCompleter(Rcompleter);

function getCompletions(editor, session, pos, prefix, callback) {
  console.log("POS: " + JSON.stringify(pos) + " prefix: " + prefix);
  if (prefix.length === 0) {
    let range = {
      start: {
        row: pos.row,
        column: 0
      },
      end: {
        row: pos.row,
        column: pos.column
      }
    }
    prefix = editor.session.getTextRange(range);
    if (prefix.length === 0) {
      callback(null, []); 
      return;
    }
  }
  var completionObj = {
    "rserveHost": $('#rserveHost').val() || "localhost",
    "rservePort": $('#rservePort').val() || 6311,
    "prefix": prefix,
    "pos": pos.column
  };
  console.log("completionObj: " + JSON.stringify(completionObj));
  $.post( '/rserveCommand/completion', completionObj)
  .done(function( data ) {
    console.log("in done");
    if (data.cmdList && data.cmdList !== null) {
      callback(null, data.cmdList.map(function(val) {
        return {caption: val, value: val}
      }));
    }
    if (data.err)
      console.log("ERROR: \n" + data.err);
  }).fail(function(xhr) {
    console.log("ERROR: \n" + JSON.stringify(xhr));
  });
}

@therustmonk
Copy link
Owner

You use custom code completion feature. I need to think how to implement it with Elm.

@rofrol
Copy link
Author

rofrol commented May 18, 2017

On every keystroke or ctrl+space I need access to editor, prefix and pos.

@therustmonk
Copy link
Owner

Resonable. I will take this into account in the implementation.

@shamis
Copy link

shamis commented Feb 15, 2018

Could you please let me know the status of this feature ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants