Created
June 9, 2020 09:56
-
-
Save siassaj/8cbcb4533a27c50d2613a03400f098bb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun lsp-docker--with-plist-keys (list &rest required-keys happy-fn sad-fn) | |
"handle when keys exist & don't exist" | |
(let* ((existing-keys (mapcar 'car list)) | |
(difference (-difference required-keys existing-keys))) | |
(if (> 0 (length difference)) | |
(funcall happy-fn (--map (plist-get list it) required-keys)) | |
(error "list is missing %s" difference)))) | |
(defun lsp-docker--docker-command (config) | |
"Return the exact docker command to run to turn on the LSP server" | |
(lsp-docker--with-plist-keys config '(:docker-image-name | |
:container-name | |
:container-command | |
:host-work-dir | |
:container-work-dir) | |
(lambda (docker-image-name | |
container-name | |
container-command | |
host-work-dir | |
container-work-dir) | |
(split-string | |
(format "docker run --name %s --rm -v %s:%s -i %s %s" | |
container-name | |
host-work-dir | |
container-work-dir | |
docker-image-name | |
container-command))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment