|
| 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: langauges, 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. statics 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 more information." |
| 54 | + :type 'boolean |
| 55 | + :group 'lsp-sml) |
| 56 | + |
| 57 | +(defcustom lsp-sml-millet-server-diagnostics-onChange-enable nil |
| 58 | + "Send diagnostics when file contents change before saving." |
| 59 | + :type 'boolean |
| 60 | + :group 'lsp-sml) |
| 61 | + |
| 62 | +(defcustom lsp-sml-millet-server-hover-token-enable t |
| 63 | + "Show information about tokens on hover." |
| 64 | + :type 'boolean |
| 65 | + :group 'lsp-sml) |
| 66 | + |
| 67 | +(defcustom lsp-sml-millet-server-path "millet-ls" |
| 68 | + "Path to the `millet-ls` executable." |
| 69 | + :type 'string |
| 70 | + :group 'lsp-sml) |
| 71 | + |
| 72 | +(lsp-register-custom-settings |
| 73 | + '(("millet.format.engine" lsp-sml-millet-format-engine) |
| 74 | + ("millet.server.diagnostics.filter" lsp-sml-millet-server-diagnostics-filter) |
| 75 | + ("millet.server.diagnostics.moreInfoHint.enable" lsp-sml-millet-server-diagnostics-moreInfoHint-enable) |
| 76 | + ("millet.server.diagnostics.onChange.enable" lsp-sml-millet-server-diagnostics-onChange-enable) |
| 77 | + ("millet.server.hover.token.enable" lsp-sml-millet-server-hover-token-enable) |
| 78 | + ("millet.server.path" lsp-sml-millet-server-path))) |
| 79 | + |
| 80 | +(lsp-register-client |
| 81 | + (make-lsp-client :new-connection (lsp-stdio-connection |
| 82 | + (lambda () lsp-sml-millet-server-path)) |
| 83 | + :activation-fn (lsp-activate-on "sml" "millet.toml") |
| 84 | + :language-id "sml" |
| 85 | + :priority -1 |
| 86 | + :server-id 'millet)) |
| 87 | + |
| 88 | +(lsp-consistency-check lsp-sml) |
| 89 | + |
| 90 | +(provide 'lsp-sml) |
| 91 | +;;; lsp-sml.el ends here |
0 commit comments