mirror of
https://github.com/qvacua/vimr.git
synced 2024-11-28 02:54:31 +03:00
GH-251, GH-258 Show a warning when there was an error during the initialization of init.vim
This commit is contained in:
parent
fb86c67c73
commit
762c1e7267
@ -597,11 +597,8 @@ void server_start_neovim() {
|
||||
|
||||
_backspace = [[NSString alloc] initWithString:@"<BS>"];
|
||||
|
||||
NSData *data = nil;
|
||||
if (msg_didany > 0) {
|
||||
bool value = true;
|
||||
data = [[NSData alloc] initWithBytes:&value length:sizeof(bool)];
|
||||
}
|
||||
bool value = msg_didany > 0;
|
||||
NSData *data = [[NSData alloc] initWithBytes:&value length:sizeof(bool)];
|
||||
[_neovim_server sendMessageWithId:NeoVimServerMsgIdNeoVimReady data:data];
|
||||
[data release];
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
- (instancetype)initWithUuid:(NSString *)uuid;
|
||||
- (void)quit;
|
||||
|
||||
- (void)runLocalServerAndNeoVimWithPath:(NSString *)path;
|
||||
- (bool)runLocalServerAndNeoVimWithPath:(NSString *)path;
|
||||
|
||||
- (void)vimCommand:(NSString *)string;
|
||||
|
||||
|
@ -52,7 +52,9 @@ static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFD
|
||||
CFRunLoopRef _localServerRunLoop;
|
||||
|
||||
NSTask *_neoVimServerTask;
|
||||
|
||||
bool _neoVimIsReady;
|
||||
bool _isInitErrorPresent;
|
||||
}
|
||||
|
||||
- (instancetype)initWithUuid:(NSString *)uuid {
|
||||
@ -63,6 +65,7 @@ static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFD
|
||||
|
||||
_uuid = uuid;
|
||||
_neoVimIsReady = NO;
|
||||
_isInitErrorPresent = NO;
|
||||
|
||||
return self;
|
||||
}
|
||||
@ -85,7 +88,7 @@ static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFD
|
||||
[_localServerThread cancel];
|
||||
}
|
||||
|
||||
- (void)runLocalServerAndNeoVimWithPath:(NSString *)path {
|
||||
- (bool)runLocalServerAndNeoVimWithPath:(NSString *)path {
|
||||
_localServerThread = [[NSThread alloc] initWithTarget:self selector:@selector(runLocalServer) object:nil];
|
||||
[_localServerThread start];
|
||||
|
||||
@ -103,6 +106,8 @@ static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFD
|
||||
// Wait until neovim is ready.
|
||||
while (!_neoVimIsReady
|
||||
&& [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate distantFuture]]);
|
||||
|
||||
return !_isInitErrorPresent;
|
||||
}
|
||||
|
||||
- (void)vimCommand:(NSString *)string {
|
||||
@ -250,11 +255,10 @@ static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFD
|
||||
return;
|
||||
|
||||
case NeoVimServerMsgIdNeoVimReady: {
|
||||
_neoVimIsReady = YES;
|
||||
bool *value = data_to_bool_array(data, 1);
|
||||
_isInitErrorPresent = value[0];
|
||||
|
||||
if (data.length > 0) {
|
||||
log4Warn("There was an error during the initialization of NeoVim. Use :messages to view the error messages.");
|
||||
}
|
||||
_neoVimIsReady = YES;
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -112,10 +112,19 @@ 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())
|
||||
|
||||
let noErrorDuringInitialization = self.agent.runLocalServerAndNeoVimWithPath(ShellUtils.pathForUserShell())
|
||||
|
||||
// Neovim is ready now: resize neovim to bounds.
|
||||
DispatchUtils.gui {
|
||||
if noErrorDuringInitialization == false {
|
||||
let alert = NSAlert()
|
||||
alert.alertStyle = .WarningAlertStyle
|
||||
alert.messageText = "Error during initialization"
|
||||
alert.informativeText = "There was an error during the initialization of NeoVim. "
|
||||
+ "Use :messages to view the error messages."
|
||||
alert.runModal()
|
||||
}
|
||||
|
||||
self.resizeNeoVimUiTo(size: self.bounds.size)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user