anchor.diff:               (format t "Received notification ~A(~{~A~^, ~})~%" msg-method (first msg-params))
                (force-output))))))
   
  -(defun send-msg (msg)
  +(defun send (bytes)
  +  "Send bytes via *socket*."
     (if *socket*
       (if cl-async-base:*event-base*
  -      (as:write-socket-data *socket* msg :force t)    
  +      (as:write-socket-data *socket* bytes :force t)    
         ;; Because we can't just send message from a thread doesn't have event-loop
         ;; running and since there doesn't seem to be a better way of doing this
         ;; in cl-async, we have to make this thread know about an event loop
         ;; running in the other thread first.
         (let* ((cl-async-base:*event-base* *global-event-base*)
  -             (cl-async-base:*data-registry* (cl-async-base:event-base-data-registry cl-async-base:*event-base*))
  -             (cl-async-base:*function-registry* (cl-async-base:event-base-function-registry cl-async-base:*event-base*))
  -             ; (*buffer-writes* *buffer-writes*)
  -             ; (*buffer-size* *buffer-size*)
  -             ; (*output-buffer* (static-vectors:make-static-vector *buffer-size* :element-type 'octet))
  -             ; (*input-buffer* (static-vectors:make-static-vector *buffer-size* :element-type 'octet))
  -             ; (*data-registry* (event-base-data-registry *event-base*))
  -             ; (*function-registry* (event-base-function-registry *event-base*))
  -             ; (callbacks nil)
  -             )
  -        (as:write-socket-data *socket* msg :force t)))))
  +             (cl-async-base:*function-registry* (cl-async-base:event-base-function-registry cl-async-base:*event-base*)))
  +        (as:write-socket-data *socket* bytes :force t)))))
   
  -(defun run (&key (host "127.0.0.1") (port 7777) fn)
  -  (bt:make-thread (lambda () (cond (fn              (run-listener #'as:pipe-connect fn))
  +(defun run-listener (listener &rest listener-args)
  +  "Run event loop with specified listener and listener arguments."
  +  (as:with-event-loop ()
  +    (setf *global-event-base* cl-async-base:*event-base*
  +          *socket* (apply listener (append listener-args
  +                                           (list #'handle-new-msg))))
  +    (as:signal-handler 2 #'(lambda (sig)
  +                             (declare (ignore sig))
  +                             (as:exit-event-loop)))))
  +
  +(defun run (&key (host "127.0.0.1") (port 7777) filename)
  +  "Run listener in an event loop inside a background thread."
  +  (bt:make-thread (lambda () (cond (filename        (run-listener #'as:pipe-connect filename))
                                      ((and host port) (run-listener #'as:tcp-connect host port))))
  -                  :name "Event loop")
  -  (format *standard-output* "Event loop is running..."))
  +                  :name "Event loop"))
  +
  
positive.code: 
  (defmacro msg-rpc-type (type-name type-id &rest components)
    (let ((make-name (symbol-append 'make- type-name))
          (predicate-name (symbol-append type-name 'p))
          (parse-name (symbol-append 'parse- type-name)) 
          (components (mapcar #'mklst components)))
      `(progn
         (defun ,make-name ,(first-els (remove-lsts-with :make components))
           (concatenate '(vector (unsigned-byte 8)) (encode (list ,type-id ,@(mapcar #'(lambda (c) (or (getf (rest c) :make) (first c))) components)))))
         (defun ,predicate-name (msg)
           (= (first msg) ,type-id))
         (defun ,parse-name (msg)
  
negative.code: (in-package #:cl-neovim)
  
  (defparameter *msg-id* 0 "Unique id for messages.")
  (defparameter *socket* NIL "Socket used for reading/writing.")
  
  (eval-when (:compile-toplevel)
    (defun symbol-append (&rest symbols) 
  