Skip to content
This repository has been archived by the owner on Feb 9, 2019. It is now read-only.

Commit

Permalink
Dialog to define the addr for neovim
Browse files Browse the repository at this point in the history
  • Loading branch information
vhakulinen committed Apr 14, 2016
1 parent 45f1a89 commit 73469e7
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 15 deletions.
33 changes: 33 additions & 0 deletions src/NeovimDialog.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import com.intellij.openapi.ui.DialogWrapper;
import com.siyeh.ig.ui.TextField;
import org.jetbrains.annotations.Nullable;

import javax.swing.*;

/**
* Created by ville on 4/14/16.
*/
public class NeovimDialog extends DialogWrapper {

private JTextField mComponent;

public NeovimDialog(boolean canBeParent) {
super(canBeParent);

this.setTitle("Connect to Neovim");
mComponent = new JTextField();
mComponent.setToolTipText("Neovim TCP address");

this.init();
}

@Nullable
@Override
protected JComponent createCenterPanel() {
return mComponent;
}

public String getAddr() {
return mComponent.getText();
}
}
37 changes: 22 additions & 15 deletions src/NeovimIntellijComplete.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,23 +86,30 @@ public NeovimIntellijComplete() {

@Override
public void actionPerformed(AnActionEvent e) {
MessagePackRPC.Connection conn;
HostAndPort hp = HostAndPort.fromParts("127.0.0.1", 7650);
try {
conn = new SocketNeovim(hp);
} catch (IOException ex) {
LOG.error("Failed to connect to neovim", ex);
return;

}
mNeovim = Neovim.connectTo(conn);
LOG.info("Connected to neovim");
NeovimDialog dialog = new NeovimDialog(true);
dialog.show();

long cid = mNeovim.getChannelId().join();
mNeovim.commandOutput("let g:intellijID=" + cid);
mNeovim.register(new Updater(mNeovim));
if (dialog.isOK()) {
LOG.warn(dialog.getAddr());

mNeovim.sendVimCommand("echo 'Intellij connected.'");
}
MessagePackRPC.Connection conn;
//HostAndPort hp = HostAndPort.fromParts("127.0.0.1", 7650);
try {
conn = new SocketNeovim(dialog.getAddr());
} catch (IOException ex) {
LOG.error("Failed to connect to neovim", ex);
return;
}
mNeovim = Neovim.connectTo(conn);
LOG.info("Connected to neovim");

long cid = mNeovim.getChannelId().join();
mNeovim.commandOutput("let g:intellijID=" + cid);
mNeovim.register(new Updater(mNeovim));

mNeovim.sendVimCommand("echo 'Intellij connected.'");
}

}
}

0 comments on commit 73469e7

Please sign in to comment.