lsp-nextflow.el (4713B)
1 ;;; lsp-nextflow.el --- lsp-mode nextflow integration -*- lexical-binding: t; -*- 2 3 ;; Copyright (C) 2024 Edmund Miller 4 5 ;; Author: Edmund Miller 6 ;; Keywords: lsp, nextflow, groovy 7 8 ;; This program is free software; you can redistribute it and/or modify 9 ;; it under the terms of the GNU General Public License as published by 10 ;; the Free Software Foundation, either version 3 of the License, or 11 ;; (at your option) any later version. 12 13 ;; This program is distributed in the hope that it will be useful, 14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 ;; GNU General Public License for more details. 17 18 ;; You should have received a copy of the GNU General Public License 19 ;; along with this program. If not, see <https://www.gnu.org/licenses/>. 20 21 ;;; Commentary: 22 23 ;; LSP Clients for the Nextflow Programming Language. 24 25 ;;; Code: 26 27 (require 'lsp-mode) 28 (require 'f) 29 30 (defgroup lsp-nextflow nil 31 "LSP support for nextflow, using nextflow-language-server." 32 :group 'lsp-mode 33 :link '(url-link "https://github.com/nextflow-io/language-server")) 34 35 (defcustom lsp-nextflow-java-path "java" 36 "Path of the java executable." 37 :group 'lsp-nextflow 38 :type 'string) 39 40 (defcustom lsp-nextflow-version "1.0.0" 41 "Version of Nextflow language server." 42 :type 'string 43 :group 'lsp-nextflow 44 :package-version '(lsp-mode . "9.0.0")) 45 46 (defcustom lsp-nextflow-server-download-url 47 (format "https://github.com/nextflow-io/language-server/releases/download/v%s/language-server-all.jar" 48 lsp-nextflow-version) 49 "Automatic download url for lsp-nextflow." 50 :type 'string 51 :group 'lsp-nextflow 52 :package-version '(lsp-mode . "9.0.0")) 53 54 (defcustom lsp-nextflow-server-file 55 (f-join lsp-server-install-dir "nextflow-language-server.jar") 56 "The path to the file in which `lsp-nextflow' will be stored." 57 :group 'lsp-nextflow 58 :risky t 59 :type 'file 60 :package-version '(lsp-mode . "9.0.0")) 61 62 (defun lsp-nextflow-server-command () 63 "Startup command for Nextflow language server." 64 `("java" "-jar" ,(expand-file-name lsp-nextflow-server-file))) 65 66 (lsp-dependency 'nextflow-lsp 67 '(:system lsp-nextflow-server-file) 68 `(:download :url lsp-nextflow-server-download-url 69 :store-path lsp-nextflow-server-file)) 70 71 ;; 72 ;;; Settings 73 74 ;; (lsp-generate-settings "~/src/nf-core/vscode-language-nextflow/package.json" 'lsp-nextflow) 75 76 (lsp-defcustom lsp-nextflow-debug nil 77 "Enable debug logging and debug information in hover hints." 78 :type 'boolean 79 :group 'lsp-nextflow 80 :package-version '(lsp-mode . "9.0.0") 81 :lsp-path "nextflow.debug") 82 83 (lsp-defcustom lsp-nextflow-files-exclude [".git" ".nf-test" "work"] 84 "Configure glob patterns for excluding folders from being searched for 85 Nextflow scripts and configuration files." 86 :type 'lsp-string-vector 87 :group 'lsp-nextflow 88 :package-version '(lsp-mode . "9.0.0") 89 :lsp-path "nextflow.files.exclude") 90 91 (lsp-defcustom lsp-nextflow-formatting-harshil-alignment nil 92 "Use the [Harshil Alignment™️](https://nf-co.re/docs/contributing/code_editors_and_styling/harshil_alignment) when formatting Nextflow scripts and config files. 93 94 *Note: not all rules are supported yet*" 95 :type 'boolean 96 :group 'lsp-nextflow 97 :package-version '(lsp-mode . "9.0.0") 98 :lsp-path "nextflow.formatting.harshilAlignment") 99 100 (lsp-defcustom lsp-nextflow-java-home nil 101 "Specifies the folder path to the JDK. Use this setting if the extension cannot 102 find Java automatically." 103 :type '(choice (const :tag "Auto" nil) 104 (directory :tag "Custom JDK path")) 105 :group 'lsp-nextflow 106 :package-version '(lsp-mode . "9.0.0") 107 :lsp-path "nextflow.java.home") 108 109 (lsp-defcustom lsp-nextflow-suppress-future-warnings t 110 "Hide warnings for future changes, deprecations, and removals." 111 :type 'boolean 112 :group 'lsp-nextflow 113 :package-version '(lsp-mode . "9.0.0") 114 :lsp-path "nextflow.suppressFutureWarnings") 115 116 ;; 117 ;;; Client 118 119 (lsp-register-client 120 (make-lsp-client 121 ;; FIXME 122 ;; :download-server-fn (lambda (_client callback error-callback _update?) 123 ;; (lsp-package-ensure 'nextflow-lsp callback error-callback)) 124 :new-connection (lsp-stdio-connection #'lsp-nextflow-server-command) 125 :major-modes '(nextflow-mode) 126 :multi-root t 127 :activation-fn (lsp-activate-on "nextflow") 128 :priority -1 129 :initialized-fn (lambda (workspace) 130 (with-lsp-workspace workspace 131 (lsp--set-configuration 132 (lsp-configuration-section "nextflow")))) 133 ;; TODO Handle preview dag 134 :server-id 'nextflow-lsp)) 135 136 (lsp-consistency-check lsp-nextflow) 137 138 (provide 'lsp-nextflow) 139 ;;; lsp-nextflow.el ends here