Skip to content

Commit

Permalink
Merge pull request #6 from iquiw/lsp
Browse files Browse the repository at this point in the history
Adapt to new lsp interface
  • Loading branch information
iquiw committed Dec 9, 2018
2 parents be4a4c7 + 8b8cc63 commit 74ce9bd
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 23 deletions.
2 changes: 2 additions & 0 deletions Cask
Expand Up @@ -4,4 +4,6 @@
(package-file "lsp-yaml.el")

(development
(depends-on "f")
(depends-on "ht")
(depends-on "undercover"))
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -25,9 +25,9 @@ To enable lsp-yaml in yaml-mode buffer, with [use-package](https://github.com/jw

``` emacs-lisp
(use-package lsp-yaml
:commands lsp-yaml-enable
:init
(add-hook 'yaml-mode-hook #'lsp-yaml-enable))
:after lsp
:config
(add-hook 'yaml-mode-hook #'lsp))
```

### Customization
Expand Down
33 changes: 13 additions & 20 deletions lsp-yaml.el
Expand Up @@ -29,14 +29,14 @@
;;
;; And then, install "lsp-mode" package.
;;
;; To use lsp-yaml in yaml-mode buffer, add `lsp-yaml-enable' to `yaml-mode-hook'.
;; To use lsp-yaml in yaml-mode buffer, add `lsp' to `yaml-mode-hook'.
;;
;; (add-hook 'yaml-mode-hook #'lsp-yaml-enable)
;; (add-hook 'yaml-mode-hook #'lsp)
;;

;;; Code:

(require 'lsp-mode)
(require 'lsp)

(defgroup lsp-yaml nil
"Yaml support for lsp-mode."
Expand Down Expand Up @@ -112,12 +112,6 @@ This can be also a hash table."
"Notify lsp-yaml settings to server."
(lsp--set-configuration (lsp-yaml--settings)))

(defun lsp-yaml--set-extra-capabilities ()
"Register client capabilities for setting \
textDocument.formatting.dynamicRegistration to true."
(lsp-register-client-capabilities
'lsp-yaml '(:textDocument (:formatting (:dynamicRegistration t)))))

(defun lsp-yaml--settings ()
"Return lsp-yaml settings to be notified to server."
`(:yaml
Expand Down Expand Up @@ -147,17 +141,16 @@ The value is composed from `lsp-yaml-format-enable' and `lsp-yaml-format-options
options))
(_ (user-error "Invalid `lsp-yaml-format-options'. Plist, alist or hash table is expected.")))))

;;;###autoload(autoload 'lsp-yaml-enable "lsp-yaml")
(lsp-define-stdio-client lsp-yaml "yaml"
(lambda () default-directory)
(list
"node"
(expand-file-name "out/server/src/server.js"
lsp-yaml-language-server-dir)
"--stdio"))

(add-hook 'lsp-before-initialize-hook #'lsp-yaml--set-extra-capabilities)
(add-hook 'lsp-after-initialize-hook #'lsp-yaml--set-configuration)
(lsp-register-client
(make-lsp-client :new-connection (lsp-stdio-connection
(list "node"
(expand-file-name "out/server/src/server.js"
lsp-yaml-language-server-dir)
"--stdio"))
:major-modes '(yaml-mode)
:server-id 'yaml))

(add-hook 'lsp-before-initialize-hook #'lsp-yaml--set-configuration)

(provide 'lsp-yaml)
;;; lsp-yaml.el ends here

0 comments on commit 74ce9bd

Please sign in to comment.