Skip to content

Commit

Permalink
Merge branch 'emacs-lsp:master' into feat/rust-analyzer-cfg-set-test
Browse files Browse the repository at this point in the history
  • Loading branch information
st1971 authored Nov 14, 2024
2 parents 76e3039 + c41769e commit ad3433f
Show file tree
Hide file tree
Showing 11 changed files with 385 additions and 83 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.org
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
* Fix zls wrong bin path
* Add support for buf CLI ([[https://github.com/bufbuild/buf/releases/tag/v1.43.0][beta]])
* Add fennel support
* Add support for [[https://github.com/nextflow-io/language-server][Nextflow]]
* Add TypeSpec support

** 9.0.0
* Add language server config for QML (Qt Modeling Language) using qmlls.
Expand Down
139 changes: 139 additions & 0 deletions clients/lsp-nextflow.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
;;; lsp-nextflow.el --- lsp-mode nextflow integration -*- lexical-binding: t; -*-

;; Copyright (C) 2024 Edmund Miller

;; Author: Edmund Miller
;; Keywords: lsp, nextflow, groovy

;; 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:

;; LSP Clients for the Nextflow Programming Language.

;;; Code:

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

(defgroup lsp-nextflow nil
"LSP support for nextflow, using nextflow-language-server."
:group 'lsp-mode
:link '(url-link "https://github.com/nextflow-io/language-server"))

(defcustom lsp-nextflow-java-path "java"
"Path of the java executable."
:group 'lsp-nextflow
:type 'string)

(defcustom lsp-nextflow-version "1.0.0"
"Version of Nextflow language server."
:type 'string
:group 'lsp-nextflow
:package-version '(lsp-mode . "9.0.0"))

(defcustom lsp-nextflow-server-download-url
(format "https://github.com/nextflow-io/language-server/releases/download/v%s/language-server-all.jar"
lsp-nextflow-version)
"Automatic download url for lsp-nextflow."
:type 'string
:group 'lsp-nextflow
:package-version '(lsp-mode . "9.0.0"))

(defcustom lsp-nextflow-server-file
(f-join lsp-server-install-dir "nextflow-language-server.jar")
"The path to the file in which `lsp-nextflow' will be stored."
:group 'lsp-nextflow
:risky t
:type 'file
:package-version '(lsp-mode . "9.0.0"))

(defun lsp-nextflow-server-command ()
"Startup command for Nextflow language server."
`("java" "-jar" ,(expand-file-name lsp-nextflow-server-file)))

(lsp-dependency 'nextflow-lsp
'(:system lsp-nextflow-server-file)
`(:download :url lsp-nextflow-server-download-url
:store-path lsp-nextflow-server-file))

;;
;;; Settings

;; (lsp-generate-settings "~/src/nf-core/vscode-language-nextflow/package.json" 'lsp-nextflow)

(lsp-defcustom lsp-nextflow-debug nil
"Enable debug logging and debug information in hover hints."
:type 'boolean
:group 'lsp-nextflow
:package-version '(lsp-mode . "9.0.0")
:lsp-path "nextflow.debug")

(lsp-defcustom lsp-nextflow-files-exclude [".git" ".nf-test" "work"]
"Configure glob patterns for excluding folders from being searched for
Nextflow scripts and configuration files."
:type 'lsp-string-vector
:group 'lsp-nextflow
:package-version '(lsp-mode . "9.0.0")
:lsp-path "nextflow.files.exclude")

(lsp-defcustom lsp-nextflow-formatting-harshil-alignment nil
"Use the [Harshil Alignment™️](https://nf-co.re/docs/contributing/code_editors_and_styling/harshil_alignment) when formatting Nextflow scripts and config files.
*Note: not all rules are supported yet*"
:type 'boolean
:group 'lsp-nextflow
:package-version '(lsp-mode . "9.0.0")
:lsp-path "nextflow.formatting.harshilAlignment")

(lsp-defcustom lsp-nextflow-java-home nil
"Specifies the folder path to the JDK. Use this setting if the extension cannot
find Java automatically."
:type '(choice (const :tag "Auto" nil)
(directory :tag "Custom JDK path"))
:group 'lsp-nextflow
:package-version '(lsp-mode . "9.0.0")
:lsp-path "nextflow.java.home")

(lsp-defcustom lsp-nextflow-suppress-future-warnings t
"Hide warnings for future changes, deprecations, and removals."
:type 'boolean
:group 'lsp-nextflow
:package-version '(lsp-mode . "9.0.0")
:lsp-path "nextflow.suppressFutureWarnings")

;;
;;; Client

(lsp-register-client
(make-lsp-client
;; FIXME
;; :download-server-fn (lambda (_client callback error-callback _update?)
;; (lsp-package-ensure 'nextflow-lsp callback error-callback))
:new-connection (lsp-stdio-connection #'lsp-nextflow-server-command)
:major-modes '(nextflow-mode)
:multi-root t
:activation-fn (lsp-activate-on "nextflow")
:priority -1
:initialized-fn (lambda (workspace)
(with-lsp-workspace workspace
(lsp--set-configuration
(lsp-configuration-section "nextflow"))))
;; TODO Handle preview dag
:server-id 'nextflow-lsp))

(lsp-consistency-check lsp-nextflow)

(provide 'lsp-nextflow)
;;; lsp-nextflow.el ends here
87 changes: 87 additions & 0 deletions clients/lsp-typespec.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
;;; lsp-typespec.el --- Typespec Client settings -*- lexical-binding: t; -*-

;; Copyright (C) 2024 [email protected]

;; Author: Jeremy Meng <[email protected]>
;; Keywords: languages,tools

;; 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:

;; lsp-typespec client

;;; Code:

(require 'lsp-mode)
(require 'lsp-semantic-tokens)

(defgroup lsp-typespec nil
"LSP support for Typespec."
:link '(url-link "https://github.com/microsoft/typespec/blob/9c95ccda8c84c7c6afa24b2f4b21cf1ecbe680dd/packages/compiler/cmd/tsp-server.js")
:group 'lsp-mode
:tag "Lsp Typespec")

(defcustom lsp-typespec-custom-server-command nil
"The typespec-lisp server command."
:group 'lsp-typespec
:risky t
:type '(repeat string))

(lsp-dependency
'typespec-lsp
'(:npm :package "@typespec/compiler"
:path "tsp-server")
'(:system "tsp-server"))

(defun lsp-typespec--server-executable-path ()
"Return the typespec-lsp server command."
(or
(when-let ((workspace-folder (lsp-find-session-folder (lsp-session) default-directory)))
(let ((tsp-server-local-path (f-join workspace-folder "node_modules" ".bin"
(if (eq system-type 'windows-nt) "tsp-server.cmd" "tsp-server"))))
(when (f-exists? tsp-server-local-path)
tsp-server-local-path)))
(executable-find "tsp-server")
(lsp-package-path 'tsp-server)
"tsp-server"))

(lsp-register-client
(make-lsp-client
:semantic-tokens-faces-overrides '(:types (("docCommentTag" . font-lock-keyword-face)
("event" . default)))
:new-connection (lsp-stdio-connection `(,(lsp-typespec--server-executable-path) "--stdio"))
:activation-fn (lsp-activate-on "typespec")
:major-modes '(typespec-mode)
:server-id 'typespec-lsp))

(lsp-consistency-check lsp-typespec)

(defun lsp-typespec-semantic-tokens-refresh (&rest _)
"Force refresh semantic tokens."
(when-let ((workspace (and lsp-semantic-tokens-enable
(lsp-find-workspace 'typespec-lsp (buffer-file-name)))))
(--each (lsp--workspace-buffers workspace)
(when (lsp-buffer-live-p it)
(lsp-with-current-buffer it
(lsp-semantic-tokens--enable))))))

(with-eval-after-load 'typespec
(when lsp-semantic-tokens-enable
;; refresh tokens
(add-hook 'typespec-mode-hook #'lsp-typespec-semantic-tokens-refresh)))

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

17 changes: 17 additions & 0 deletions docs/lsp-clients.json
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,15 @@
"lsp-install-server": "jsts-ls",
"debugger": "Yes (Firefox/Chrome)"
},
{
"name": "typespec",
"full-name": "TypeSpec",
"server-name": "tsp server",
"server-url": "https://github.com/microsoft/typespec/tree/main/packages/compiler",
"installation": "npm i -g @typespec/compiler",
"lsp-install-server": "@typespec/compiler",
"debugger": "Yes (Firefox/Chrome)"
},
{
"name": "deno",
"common-group-name": "javascript",
Expand Down Expand Up @@ -677,6 +686,14 @@
"installation": "npm install -g @mdx-js/language-server",
"debugger": "Not available"
},
{
"name": "nextflow",
"full-name": "Nextflow",
"server-name": "nextflow-language-server",
"server-url": "https://github.com/nextflow-io/language-server",
"installation-url": "https://github.com/nextflow-io/language-server#build",
"debugger": "Not available"
},
{
"name": "nginx",
"full-name": "Nginx",
Expand Down
Loading

0 comments on commit ad3433f

Please sign in to comment.