Skip to content

Commit 291f730

Browse files
authored
feat: Add a solidity language server (#4208)
* feat: Add a solidity language server * feat(lsp-solidity): Provide a way to download automatically the server Following the example of bash-lsp. Also, don't confuse the user by telling about alternative implementations, while this package was mostly tested with the implementation of nomicfoundation.
1 parent 0f5723f commit 291f730

File tree

4 files changed

+73
-1
lines changed

4 files changed

+73
-1
lines changed

CHANGELOG.org

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
* Changelog
22
** Unreleased 8.0.1
3+
* Add lsp-solidity, using the implementation from NomicFoundation
34
* Change rust-analyzer base URL to be github.com/rust-lang/rust-analyzer, rather than rust-analyzer/rust-analyzer.
45
* Add [[https://github.com/wader/jq-lsp][jq-lsp]]
56
* Add architecture triples for [[https://github.com/WhatsApp/erlang-language-platform][erlang-language-platform]] file downloads, to support macos on ARM and X86.

clients/lsp-solidity.el

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
;;; lsp-solidity.el --- solidity LSP -*- lexical-binding: t; -*-
2+
3+
;; Copyright (C) 2023 konubinix
4+
5+
;; Author: konubinix <[email protected]>
6+
;; Keywords: tools
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+
;;; Code:
24+
25+
(require 'lsp-mode)
26+
27+
(lsp-dependency 'solidity-language-server
28+
'(:system "solidity-language-server")
29+
'(:npm :package "@nomicfoundation/solidity-language-server"
30+
:path "nomicfoundation-solidity-language-server"))
31+
32+
33+
(defun lsp-client--solidity-ls-server-command ()
34+
"Startup command for Solidity language server."
35+
(list (lsp-package-path 'solidity-language-server) "--stdio"))
36+
37+
38+
(defgroup lsp-solidity nil
39+
"LSP support for Solidity."
40+
:group 'lsp-mode
41+
:link '(url-link "https://github.com/NomicFoundation/hardhat-vscode/blob/development/server/README.md"))
42+
43+
44+
(lsp-register-client
45+
(make-lsp-client :new-connection (lsp-stdio-connection #'lsp-client--solidity-ls-server-command)
46+
:activation-fn (lsp-activate-on "solidity" "sol")
47+
:server-id 'solidity
48+
:notification-handlers
49+
(ht ("custom/validation-job-status"
50+
#'lsp-client--solidity-validation-job-status))
51+
:download-server-fn (lambda (_client callback error-callback _update?)
52+
(lsp-package-ensure 'solidity-language-server callback error-callback))))
53+
54+
(defun lsp-client--solidity-validation-job-status (_workspace params)
55+
;; noop until I find out what to do with this
56+
)
57+
58+
(lsp-consistency-check lsp-solidity)
59+
60+
(provide 'lsp-solidity)
61+
;;; lsp-solidity.el ends here

docs/lsp-clients.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,15 @@
843843
"installation": "gem install solargraph",
844844
"debugger": "Yes"
845845
},
846+
{
847+
"name": "solidity",
848+
"full-name": "nomicfoundation/solidity-language-server",
849+
"server-name": "solidity-language-server",
850+
"installation": "npx @nomicfoundation/solidity-language-server",
851+
"server-url": "https://github.com/NomicFoundation/hardhat-vscode/blob/development/server/README.md",
852+
"installation-url": "https://github.com/NomicFoundation/hardhat-vscode/blob/development/server/README.md",
853+
"debugger": "Not available"
854+
},
846855
{
847856
"name": "sorbet",
848857
"full-name": "Ruby (Sorbet)",

lsp-mode.el

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ As defined by the Language Server Protocol 3.16."
187187
lsp-solargraph lsp-sorbet lsp-sourcekit lsp-sonarlint lsp-tailwindcss lsp-tex lsp-terraform
188188
lsp-toml lsp-ttcn3 lsp-typeprof lsp-v lsp-vala lsp-verilog lsp-vetur lsp-volar
189189
lsp-vhdl lsp-vimscript lsp-xml lsp-yaml lsp-ruby-lsp lsp-ruby-syntax-tree
190-
lsp-sqls lsp-svelte lsp-steep lsp-tilt lsp-zig lsp-jq)
190+
lsp-solidity lsp-sqls lsp-svelte lsp-steep lsp-tilt lsp-zig lsp-jq)
191191
"List of the clients to be automatically required."
192192
:group 'lsp-mode
193193
:type '(repeat symbol))
@@ -927,6 +927,7 @@ Changes take effect only when a new session is started."
927927
(gleam-mode . "gleam")
928928
(graphviz-dot-mode . "dot")
929929
(tiltfile-mode . "tiltfile")
930+
(solidity-mode . "solidity")
930931
(bibtex-mode . "bibtex")
931932
(rst-mode . "restructuredtext")
932933
(glsl-mode . "glsl")

0 commit comments

Comments
 (0)