config

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

lsp-sml.el (3467B)


      1 ;;; lsp-sml.el --- Standard ML client settings -*- lexical-binding: t; -*-
      2 
      3 ;; Copyright (c) 2023 Ariel Davis
      4 
      5 ;; Author: Ariel Davis <ariel.z.davis@icloud.com>
      6 ;; Keywords: languages, lsp, sml, standard-ml, millet
      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-sml client via Millet
     24 
     25 ;;; Code:
     26 
     27 (require 'lsp-mode)
     28 (require 'lsp-completion)
     29 
     30 (defgroup lsp-sml nil
     31   "LSP support for Standard ML, using the Millet language server."
     32   :link '(url-link "https://github.com/azdavis/millet")
     33   :group 'lsp-mode)
     34 
     35 (defcustom lsp-sml-millet-format-engine "none"
     36   "**WARNING: THE FORMATTER IS HIGHLY EXPERIMENTAL.
     37 IT MAY IRREVOCABLY DESTROY SOME OR ALL OF YOUR CODE.**
     38 
     39 How to format open SML files on save."
     40   :type '(choice (const :tag "No formatting." "none")
     41                  (const :tag "Naive formatting." "naive")
     42                  (const :tag "Formatting provided by https://github.com/shwestrick/smlfmt." "smlfmt"))
     43   :group 'lsp-sml)
     44 
     45 (defcustom lsp-sml-millet-server-diagnostics-filter "syntax"
     46   "What diagnostics to send per file."
     47   :type '(choice (const :tag "No filter, i.e. all available diagnostics are sent." "none")
     48                  (const :tag "If there are syntax errors (lex, parse, etc),
     49 send only those, and do not send e.g. statistics diagnostics." "syntax"))
     50   :group 'lsp-sml)
     51 
     52 (defcustom lsp-sml-millet-server-diagnostics-moreInfoHint-enable t
     53   "Show a hint on diagnostic messages about clicking the error code number for
     54 more information."
     55   :type 'boolean
     56   :group 'lsp-sml)
     57 
     58 (defcustom lsp-sml-millet-server-diagnostics-onChange-enable nil
     59   "Send diagnostics when file contents change before saving."
     60   :type 'boolean
     61   :group 'lsp-sml)
     62 
     63 (defcustom lsp-sml-millet-server-hover-token-enable t
     64   "Show information about tokens on hover."
     65   :type 'boolean
     66   :group 'lsp-sml)
     67 
     68 (defcustom lsp-sml-millet-server-path "millet-ls"
     69   "Path to the `millet-ls` executable."
     70   :type 'string
     71   :group 'lsp-sml)
     72 
     73 (lsp-register-custom-settings
     74  '(("millet.format.engine" lsp-sml-millet-format-engine)
     75    ("millet.server.diagnostics.filter" lsp-sml-millet-server-diagnostics-filter)
     76    ("millet.server.diagnostics.moreInfoHint.enable" lsp-sml-millet-server-diagnostics-moreInfoHint-enable)
     77    ("millet.server.diagnostics.onChange.enable" lsp-sml-millet-server-diagnostics-onChange-enable)
     78    ("millet.server.hover.token.enable" lsp-sml-millet-server-hover-token-enable)
     79    ("millet.server.path" lsp-sml-millet-server-path)))
     80 
     81 (lsp-register-client
     82  (make-lsp-client :new-connection (lsp-stdio-connection
     83                                    (lambda () lsp-sml-millet-server-path))
     84                   :activation-fn (lsp-activate-on "sml" "millet.toml")
     85                   :language-id "sml"
     86                   :priority -1
     87                   :server-id 'millet))
     88 
     89 (lsp-consistency-check lsp-sml)
     90 
     91 (provide 'lsp-sml)
     92 ;;; lsp-sml.el ends here