Skip to content

Commit

Permalink
Use yaml-language-server executable
Browse files Browse the repository at this point in the history
Requires yaml-language-server >= 0.4.0.
  • Loading branch information
iquiw committed Apr 7, 2019
1 parent dc1b6c3 commit c7458fa
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 53 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -9,7 +9,7 @@ YAML support for lsp-mode using [yaml-language-server](https://github.com/redhat

### Prerequisite

Install yaml-language-server by npm.
Install yaml-language-server (>= v0.4.0) by npm.

``` console
$ npm install -g yaml-language-server
Expand Down
16 changes: 0 additions & 16 deletions lsp-yaml-tests.el
Expand Up @@ -105,19 +105,3 @@
(should-error (lsp-yaml--format-options) :type 'user-error))
(let ((lsp-yaml-format-options t))
(should-error (lsp-yaml--format-options) :type 'user-error)))

(ert-deftest lsp-yaml-test-find-language-server-dir-on-windows ()
"Check if default directory of \"yaml-language-server\" is correct on Windows."
(let ((exec-path (cons "test/bin" exec-path))
(system-type 'windows-nt))
(should
(equal (lsp-yaml--find-language-server-dir)
"/opt/npm/node_modules/yaml-language-server"))))

(ert-deftest lsp-yaml-test-find-language-server-dir-on-non-windows ()
"Check if default directory of \"yaml-language-server\" is correct on non-Windows."
(let ((exec-path (cons "test/bin" exec-path))
(system-type 'gnu/linux))
(should
(equal (lsp-yaml--find-language-server-dir)
"/opt/npm/lib/node_modules/yaml-language-server"))))
28 changes: 4 additions & 24 deletions lsp-yaml.el
Expand Up @@ -42,22 +42,6 @@
"Yaml support for lsp-mode."
:group 'lsp-mode)

(defun lsp-yaml--find-language-server-dir ()
"Find default \"yaml-language-server\" directory using \"npm\" command."
(let ((npm-prefix (ignore-errors
(with-output-to-string
(with-current-buffer standard-output
(let ((process-environment
(cons "NO_UPDATE_NOTIFIER=1" process-environment)))
(process-file "npm" nil t nil "prefix" "-g"))
(goto-char (point-max))
(when (eq (char-before) ?\n)
(delete-char -1))))))
(yaml-ls-dir (if (eq system-type 'windows-nt)
"node_modules/yaml-language-server"
"lib/node_modules/yaml-language-server")))
(expand-file-name yaml-ls-dir npm-prefix)))

(defcustom lsp-yaml-completion t
"Specify whether to enable autocompletion."
:type 'boolean)
Expand Down Expand Up @@ -94,9 +78,9 @@ will be sent as
"Specify whether to enable hover."
:type 'boolean)

(defcustom lsp-yaml-language-server-dir (lsp-yaml--find-language-server-dir)
"Directory where \"yaml-language-server\" is installed."
:type 'string)
(defcustom lsp-yaml-server "yaml-language-server"
"The \"yaml-language-server\" executable to use."
:type 'file)

(defcustom lsp-yaml-schemas nil
"Schemas plist or alist that associates schema with glob patterns.
Expand Down Expand Up @@ -142,11 +126,7 @@ The value is composed from `lsp-yaml-format-enable' and `lsp-yaml-format-options
(_ (user-error "Invalid `lsp-yaml-format-options'. Plist, alist or hash table is expected.")))))

(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"))
(make-lsp-client :new-connection (lsp-stdio-connection (list lsp-yaml-server "--stdio"))
:major-modes '(yaml-mode)
:server-id 'yaml
:initialized-fn (lambda (workspace)
Expand Down
12 changes: 0 additions & 12 deletions test/bin/npm

This file was deleted.

0 comments on commit c7458fa

Please sign in to comment.