config

Personal configuration.
git clone git://code.dwrz.net/config
Log | Files | Refs

lsp-purescript.el (3156B)


      1 ;;; lsp-purescript.el --- description -*- lexical-binding: t; -*-
      2 
      3 ;; Copyright (C) 2020 emacs-lsp maintainers
      4 
      5 ;; Author: emacs-lsp maintainers
      6 ;; Keywords: lsp, purescript
      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 PureScript Programming Language.
     24 
     25 ;;; Code:
     26 
     27 (require 'lsp-mode)
     28 
     29 (defgroup lsp-purescript nil
     30   "LSP support for PureScript, using purescript-language-server."
     31   :group 'lsp-mode
     32   :link '(url-link "https://github.com/nwolverson/purescript-language-server"))
     33 
     34 (defcustom lsp-purescript-server-executable nil
     35   "Path to server executable."
     36   :type 'string
     37   :risky t
     38   :group 'lsp-purescript)
     39 
     40 (defcustom lsp-purescript-server-args
     41   '("--stdio")
     42   "Arguments to pass to the server."
     43   :type '(repeat string)
     44   :risky t
     45   :group 'lsp-purescript)
     46 
     47 (defun lsp-purescript--server-command ()
     48   "Generate LSP startup command for purescript-language-server."
     49   (cons (or lsp-purescript-server-executable
     50             (lsp-package-path 'purescript-language-server))
     51         lsp-purescript-server-args))
     52 
     53 (lsp-defcustom lsp-purescript-add-spago-sources t
     54   "Whether to add spago sources to the globs.
     55 Passed to the IDE server for source locations."
     56   :type 'boolean
     57   :group 'lsp-purescript
     58   :package-version '(lsp-mode . "9.0.0")
     59   :lsp-path "purescript.addSpagoSources")
     60 
     61 (lsp-defcustom lsp-purescript-add-npm-path nil
     62   "Whether to add the local npm bin directory to the PATH."
     63   :type 'boolean
     64   :group 'lsp-purescript
     65   :package-version '(lsp-mode . "9.0.0")
     66   :lsp-path "purescript.addNpmPath")
     67 
     68 (lsp-defcustom lsp-purescript-formatter "purty"
     69   "Tool to use to for formatting.
     70 Must be installed and on PATH (or npm installed with addNpmPath set)"
     71   :type '(choice (:tag none purty purs-tidy pose))
     72   :group 'lsp-purescript
     73   :package-version '(lsp-mode . "9.0.0")
     74   :lsp-path "purescript.formatter")
     75 
     76 (lsp-dependency 'purescript-language-server
     77                 '(:system "purescript-language-server")
     78                 '(:npm :package "purescript-language-server"
     79                        :path "purescript-language-server"))
     80 
     81 (lsp-register-client
     82  (make-lsp-client
     83   :new-connection (lsp-stdio-connection
     84                    #'lsp-purescript--server-command)
     85   :major-modes '(purescript-mode)
     86   :priority -1
     87   :server-id 'pursls
     88   :download-server-fn (lambda (_client callback error-callback _update?)
     89                         (lsp-package-ensure 'purescript-language-server callback error-callback))))
     90 
     91 
     92 (lsp-consistency-check lsp-purescript)
     93 
     94 (provide 'lsp-purescript)
     95 ;;; lsp-purescript.el ends here