diff --git a/src/NeovimDialog.java b/src/NeovimDialog.java new file mode 100644 index 0000000..4b32119 --- /dev/null +++ b/src/NeovimDialog.java @@ -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(); + } +} diff --git a/src/NeovimIntellijComplete.java b/src/NeovimIntellijComplete.java index b44385e..e7bfaae 100644 --- a/src/NeovimIntellijComplete.java +++ b/src/NeovimIntellijComplete.java @@ -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.'"); + } + + } } \ No newline at end of file