Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.org
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@
| JavaScript/TypeScript | [[https://github.com/theia-ide/typescript-language-server][typescript-language-server]] (recommended) | Yes | npm i -g typescript-language-server; npm i -g typescript | Yes (Firefox/Chrome) |
| JavaScript/TypeScript | [[https://github.com/sourcegraph/javascript-typescript-langserver][javascript-typescript-stdio]] | Yes | npm i -g javascript-typescript-langserver | Yes (Firefox/Chrome) |
| JavaScript Flow | [[https://flow.org][flow]] (add-on if working on a Flow file) | Yes | [[https://flow.org][flow]] | Yes (Firefox/Chrome) |
| Json | [[https://github.com/vscode-langservers/vscode-json-languageserver][vscode-json-languageserver]] | Yes | Automatic or manual by ~npm i -g vscode-json-languageserver~ | |
| Julia | [[https://github.com/non-Jedi/lsp-julia][lsp-julia]] | [[https://github.com/non-Jedi/lsp-julia][lsp-julia]] | [[https://github.com/JuliaEditorSupport/LanguageServer.jl][LanguageServer.jl]] | |
| Kotlin | [[https://github.com/fwcd/KotlinLanguageServer][kotlin-language-server]] | Yes | [[https://github.com/fwcd/KotlinLanguageServer][kotlin-language-server]] | |
| OCaml | [[https://github.com/ocaml-lsp/ocaml-language-server][ocaml-language-server]] | Yes | [[https://github.com/ocaml-lsp/ocaml-language-server][ocaml-language-server]] | |
Expand All @@ -167,7 +168,7 @@
| Powershell | [[https://github.com/PowerShell/PowerShellEditorServices][PowerShellEditorServices]] | Yes | Automatic | Yes |
| Python | [[https://github.com/palantir/python-language-server][pyls]] | Yes | pip install 'python-language-server[all]' | Yes |
| Python(Microsoft) | [[https://github.com/Microsoft/python-language-server][Microsoft Python Language Server]] | [[https://github.com/emacs-lsp/lsp-python-ms][lsp-python-ms]] | [[https://github.com/emacs-lsp/lsp-python-ms][lsp-python-ms]] | Yes |
| R | [[https://github.com/REditorSupport/languageserver][languageserver]] | Yes | install.packages("languageserver") | No |
| R | [[https://github.com/REditorSupport/languageserver][languageserver]] | Yes | install.packages("languageserver") | No |
| Ruby | [[https://github.com/castwide/solargraph][solargraph]] | Yes | gem install solargraph | Yes |
| Rust | [[https://github.com/rust-lang/rls][rls]] | Yes | [[https://github.com/rust-lang/rls][rls]] | Yes |
| Rust | [[https://github.com/rust-analyzer/rust-analyzer][rust-analyzer]] | Yes | [[https://github.com/rust-analyzer/rust-analyzer#language-server-quick-start][rust-analyzer]] | |
Expand Down
1 change: 1 addition & 0 deletions lsp-clients.el
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
(require 'lsp-terraform)
(require 'lsp-pwsh)
(require 'lsp-csharp)
(require 'lsp-json)

;;; Ada
(defgroup lsp-ada nil
Expand Down
136 changes: 136 additions & 0 deletions lsp-json.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
;;; lsp-pwsh.el --- vscode-json-languageserver integration -*- lexical-binding: t; -*-
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this filename in this comment is wrong

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, the downfall of copy/paste :(. Will update it next time I touch this file again.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries.


;; Copyright (C) 2019 Kien Nguyen

;; Author: kien.n.quang at gmail.com
;; Keywords: lsp

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <https://www.gnu.org/licenses/>.

;;; Commentary:

;;

;;; Code:

(require 'lsp-mode)
(require 'ht)
(require 'url-util)

(defgroup lsp-json nil
"LSP support for JSON, using vscode-json-languageserver."
:group 'lsp-mode
:link '(url-link "https://github.com/vscode-langservers/vscode-json-languageserver")
:package-version '(lsp-mode . "6.3"))

(defcustom lsp-json-schemas nil
"Associate schemas to JSON files in the current project"
:type '(repeat alist)
:group 'lsp-json
:package-version '(lsp-mode . "6.3"))

(defcustom lsp-json-format-enable t
"Enable/disable default JSON formatter"
:type 'boolean
:group 'lsp-json
:package-version '(lsp-mode . "6.3"))

(defcustom lsp-http-proxy nil
"The URL of the proxy server to use when fetching schema."
:type 'string
:group 'lsp-json
:package-version '(lsp-mode . "6.3"))

(defcustom lsp-http-proxyStrictSSL t
"The URL of the proxy server to use when fetching schema."
:type 'boolean
:group 'lsp-json
:package-version '(lsp-mode . "6.3"))

(lsp-register-custom-settings
'(("json.format.enable" lsp-json-format-enable t)
("json.schemas" lsp-json-schemas)
("http.proxy" lsp-http-proxy)
("http.proxyStrictSSL" lsp-http-proxyStrictSSL)))

(defcustom lsp-json-server "vscode-json-languageserver"
"Json language server executable."
:type 'string
:group 'lsp-json
:package-version '(lsp-mode . "6.3"))

(defun lsp-json--command ()
"Return the command to start server."
;; Install language server
(unless (and lsp-json-server (executable-find lsp-json-server))
(unless (executable-find "npm")
(user-error "`npm' is not available in your PATH, please install it"))
(shell-command "npm install -g vscode-json-languageserver"))
`(,lsp-json-server "--stdio"))

(defvar lsp-json--extra-init-params
`(:handledSchemaProtocols ("file" "http" "https")))

(defvar lsp-json--major-modes '(json-mode jsonc-mode))

(defvar lsp-json--schema-associations
`(("/*.css-data.json" . ["https://raw.githubusercontent.com/Microsoft/vscode-css-languageservice/master/docs/customData.schema.json"])
("/package.json" . ["https://schemastore.azurewebsites.net/schemas/json/package.json"])
("/*.html-data.json" . ["https://raw.githubusercontent.com/Microsoft/vscode-html-languageservice/master/docs/customData.schema.json"])
("/*.schema.json" . ["http://json-schema.org/draft-07/schema#"])
("/bower.json" . ["https://schemastore.azurewebsites.net/schemas/json/bower.json"])
("/composer.json" . ["https://getcomposer.org/schema.json"])
("/tsconfig.json" . ["https://schemastore.azurewebsites.net/schemas/json/tsconfig.json"])
("/tsconfig.*.json" . ["https://schemastore.azurewebsites.net/schemas/json/tsconfig.json"])
("/typings.json" . ["https://schemastore.azurewebsites.net/schemas/json/typings.json"])
("/.bowerrc" . ["https://schemastore.azurewebsites.net/schemas/json/bowerrc.json"])
("/.babelrc" . ["https://schemastore.azurewebsites.net/schemas/json/babelrc.json"])
("/.babelrc.json" . ["https://schemastore.azurewebsites.net/schemas/json/babelrc.json"])
("/babel.config.json" . ["https://schemastore.azurewebsites.net/schemas/json/babelrc.json"])
("/jsconfig.json" . ["https://schemastore.azurewebsites.net/schemas/json/jsconfig.json"])
("/jsconfig.*.json" . ["https://schemastore.azurewebsites.net/schemas/json/jsconfig.json"])
("/project.json" . ["http://json.schemastore.org/project"])
("/omnisharp.json" . ["http://json.schemastore.org/omnisharp"]))
"Default json schemas.")

(defun lsp-json--get-content (_workspace uri)
"Get content from URI."
(with-temp-buffer
(url-insert-file-contents (url-unhex-string uri))
(buffer-string)))

(lsp-register-client
(make-lsp-client
:new-connection (lsp-stdio-connection #'lsp-json--command)
:major-modes lsp-json--major-modes
:server-id 'json-ls
:priority -1
:completion-in-comments? t
:initialization-options lsp-json--extra-init-params
:request-handlers (ht ("vscode/content" #'lsp-json--get-content))
:initialized-fn (lambda (w)
(with-lsp-workspace w
(lsp--set-configuration (lsp-configuration-section "json"))
(lsp-notify "json/schemaAssociations" lsp-json--schema-associations)))))

;; Compatibility
(with-eval-after-load 'company-lsp
(advice-add 'company-tng--supress-post-completion
:after-while
(lambda (&rest _)
(not (memq major-mode lsp-json--major-modes)))
'((name . --force-post-completion-for-json))))

(provide 'lsp-json)
;;; lsp-json.el ends here
1 change: 1 addition & 0 deletions lsp-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,7 @@ Changes take effect only when a new session is started."
(php-mode . "php")
(powershell-mode . "powershell")
(json-mode . "json")
(jsonc-mode . "jsonc")
(rjsx-mode . "javascript")
(js2-mode . "javascript")
(js-mode . "javascript")
Expand Down
7 changes: 3 additions & 4 deletions lsp-pwsh.el
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

;; Copyright (C) 2019 Kien Nguyen

;; Author: kien.n.quang@gmail.com
;; URL: https://github.com/kiennq/lsp-powershell
;; Keywords: languages
;; Author: kien.n.quang at gmail.com
;; Keywords: lsp

;; This program is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -296,7 +295,7 @@ Must not nil.")
:new-connection (lsp-stdio-connection #'lsp-pwsh--command)
:major-modes lsp-pwsh--major-modes
:server-id 'pwsh-ls
:priority 1
:priority -1
:initialization-options #'lsp-pwsh--extra-init-params
:notification-handlers (lsp-ht ("powerShell/executionStatusChanged" #'ignore)
("output" #'ignore))
Expand Down