mirror of
https://github.com/qvacua/vimr.git
synced 2024-12-24 22:33:52 +03:00
GH-232 Launch neovim synchronously.
- The agent waits till neovim has finished launching. This makes many things easier...
This commit is contained in:
parent
818f61323b
commit
a236b2c16a
@ -52,6 +52,7 @@ static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFD
|
||||
CFRunLoopRef _localServerRunLoop;
|
||||
|
||||
NSTask *_neoVimServerTask;
|
||||
bool _neoVimIsReady;
|
||||
}
|
||||
|
||||
- (instancetype)initWithUuid:(NSString *)uuid {
|
||||
@ -61,6 +62,7 @@ static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFD
|
||||
}
|
||||
|
||||
_uuid = uuid;
|
||||
_neoVimIsReady = NO;
|
||||
|
||||
return self;
|
||||
}
|
||||
@ -87,7 +89,6 @@ static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFD
|
||||
_localServerThread = [[NSThread alloc] initWithTarget:self selector:@selector(runLocalServer) object:nil];
|
||||
[_localServerThread start];
|
||||
|
||||
|
||||
_neoVimServerTask = [[NSTask alloc] init];
|
||||
|
||||
NSMutableDictionary *env = [NSMutableDictionary dictionaryWithDictionary:[NSProcessInfo processInfo].environment];
|
||||
@ -98,6 +99,10 @@ static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFD
|
||||
_neoVimServerTask.launchPath = [self neoVimServerExecutablePath];
|
||||
_neoVimServerTask.arguments = @[ [self localServerName], [self remoteServerName] ];
|
||||
[_neoVimServerTask launch];
|
||||
|
||||
// Wait until neovim is ready.
|
||||
while (!_neoVimIsReady
|
||||
&& [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]);
|
||||
}
|
||||
|
||||
- (void)vimCommand:(NSString *)string {
|
||||
@ -241,10 +246,12 @@ static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFD
|
||||
return;
|
||||
|
||||
case NeoVimServerMsgIdNeoVimReady: {
|
||||
_neoVimIsReady = YES;
|
||||
|
||||
if (data.length > 0) {
|
||||
log4Warn("There was an error during the initialization of NeoVim. Use :messages to view the error messages.");
|
||||
}
|
||||
[_bridge neoVimUiIsReady];
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -43,8 +43,6 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@protocol NeoVimUiBridgeProtocol <NSObject>
|
||||
|
||||
- (void)neoVimUiIsReady;
|
||||
|
||||
/**
|
||||
* NeoVim has set the size of its screen to rows X columns. The view must be resized accordingly.
|
||||
*/
|
||||
|
@ -112,6 +112,11 @@ public class NeoVimView: NSView, NSUserInterfaceValidations {
|
||||
// We cannot set bridge in init since self is not available before super.init()...
|
||||
self.agent.bridge = self
|
||||
self.agent.runLocalServerAndNeoVimWithPath(ShellUtils.pathForUserShell())
|
||||
|
||||
// Neovim is ready now: resize neovim to bounds.
|
||||
DispatchUtils.gui {
|
||||
self.resizeNeoVimUiTo(size: self.bounds.size)
|
||||
}
|
||||
}
|
||||
|
||||
required public init?(coder: NSCoder) {
|
||||
@ -978,13 +983,6 @@ extension NeoVimView {
|
||||
// MARK: - NeoVimUiBridgeProtocol
|
||||
extension NeoVimView: NeoVimUiBridgeProtocol {
|
||||
|
||||
public func neoVimUiIsReady() {
|
||||
DispatchUtils.gui {
|
||||
self.resizeNeoVimUiTo(size: self.bounds.size)
|
||||
self.delegate?.neoVimReady()
|
||||
}
|
||||
}
|
||||
|
||||
public func resizeToWidth(width: Int32, height: Int32) {
|
||||
DispatchUtils.gui {
|
||||
// NSLog("\(#function): \(width):\(height)")
|
||||
|
@ -10,6 +10,5 @@ public protocol NeoVimViewDelegate: class {
|
||||
|
||||
func setTitle(title: String)
|
||||
func setDirtyStatus(dirty: Bool)
|
||||
func neoVimReady()
|
||||
func neoVimStopped()
|
||||
}
|
||||
|
@ -335,7 +335,6 @@
|
||||
4BEE79161D16D3800012EDAA /* CellAttributes.swift */,
|
||||
1929BA6128BFDD54CA92F46E /* ColorUtils.swift */,
|
||||
4B6A709E1D660CDA00E12030 /* ShellUtils.swift */,
|
||||
4B2A2C061D0352CB0074CE9A /* NeoVimUiBridgeProtocol.h */,
|
||||
4B2A2BF91D0351810074CE9A /* SwiftNeoVim.h */,
|
||||
4BDF641A1D0887C100D47E1D /* TextDrawer.h */,
|
||||
4BDF641B1D0887C100D47E1D /* TextDrawer.m */,
|
||||
@ -473,6 +472,7 @@
|
||||
4B401B191D046E0600D99EDC /* NeoVimViewDelegate.swift */,
|
||||
4B570DC01D303CAF006EDC21 /* NeoVimAgent.h */,
|
||||
4B570DC11D303CAF006EDC21 /* NeoVimAgent.m */,
|
||||
4B2A2C061D0352CB0074CE9A /* NeoVimUiBridgeProtocol.h */,
|
||||
);
|
||||
name = NeoVimView;
|
||||
sourceTree = "<group>";
|
||||
|
@ -23,8 +23,6 @@ class MainWindowComponent: NSObject, NSWindowDelegate, NeoVimViewDelegate, Compo
|
||||
private let windowController = NSWindowController(windowNibName: "MainWindow")
|
||||
private let window: NSWindow
|
||||
|
||||
private let urlsToBeOpenedWhenReady: [NSURL]
|
||||
|
||||
private var defaultEditorFont: NSFont
|
||||
private var usesLigatures: Bool
|
||||
|
||||
@ -40,7 +38,6 @@ class MainWindowComponent: NSObject, NSWindowDelegate, NeoVimViewDelegate, Compo
|
||||
self.window = self.windowController.window!
|
||||
self.defaultEditorFont = initialData.appearance.editorFont
|
||||
self.usesLigatures = initialData.appearance.editorUsesLigatures
|
||||
self.urlsToBeOpenedWhenReady = urls
|
||||
|
||||
super.init()
|
||||
|
||||
@ -49,6 +46,10 @@ class MainWindowComponent: NSObject, NSWindowDelegate, NeoVimViewDelegate, Compo
|
||||
|
||||
self.addViews()
|
||||
self.addReactions()
|
||||
|
||||
self.neoVimView.font = self.defaultEditorFont
|
||||
self.neoVimView.usesLigatures = self.usesLigatures
|
||||
self.neoVimView.open(urls: urls)
|
||||
|
||||
self.window.makeFirstResponder(self.neoVimView)
|
||||
self.windowController.showWindow(self)
|
||||
@ -195,13 +196,6 @@ extension MainWindowComponent {
|
||||
self.window.title = title
|
||||
}
|
||||
|
||||
func neoVimReady() {
|
||||
self.neoVimView.font = self.defaultEditorFont
|
||||
self.neoVimView.usesLigatures = self.usesLigatures
|
||||
|
||||
self.neoVimView.open(urls: self.urlsToBeOpenedWhenReady)
|
||||
}
|
||||
|
||||
func setDirtyStatus(dirty: Bool) {
|
||||
self.windowController.setDocumentEdited(dirty)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user