Skip to content

Commit 0f56580

Browse files
authored
feat(clients): add support for the syntax_tree Ruby gem (#3653)
This adds the client for the `syntax_tree` Ruby gem. The naming on this one was a bit odd as the github org name is "ruby-syntax-tree", the gem name is "syntax_tree", and the executable is "stree". I attempted to standardize on "ruby-syntax-tree". Co-authored-by: Geoffrey Lessel <[email protected]>
1 parent b02bde6 commit 0f56580

File tree

4 files changed

+70
-1
lines changed

4 files changed

+70
-1
lines changed

CHANGELOG.org

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
* Add ~lsp-use-workspace-root-for-server-default-directory~.
4040
* Add [[https://github.com/artempyanykh/marksman][marksman]] support.
4141
* ~lsp-find-references~ to include declaration by default
42+
* Add [[https://github.com/ruby-syntax-tree/syntax_tree][syntax_tree]] support for Ruby code.
4243
** Release 8.0.0
4344
* Add ~lsp-clients-angular-node-get-prefix-command~ to get the Angular server from another location which is still has ~/lib/node_modules~ in it.
4445
* Set ~lsp-clients-angular-language-server-command~ after the first connection to speed up subsequent connections.

clients/lsp-ruby-syntax-tree.el

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
;;; lsp-ruby-syntax-tree.el --- lsp-mode for the Ruby syntax_tree gem -*- lexical-binding: t; -*-
2+
3+
;; Copyright (C) 2022 Geoffrey Lessel
4+
5+
;; Author: Geoffrey Lessel
6+
;; Keywords: languages
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 client for the Ruby syntax_tree gem.
24+
25+
;;; Code:
26+
27+
(require 'lsp-mode)
28+
29+
(defgroup lsp-ruby-syntax-tree nil
30+
"LSP support for the Ruby syntax_tree gem."
31+
:group 'lsp-mode
32+
:link '(url-link "https://github.com/ruby-syntax-tree/syntax_tree"))
33+
34+
(defcustom lsp-ruby-syntax-tree-use-bundler nil
35+
"Run stree (the syntax_tree executable) using bundler."
36+
:type 'boolean
37+
:safe #'booleanp
38+
:group 'lsp-ruby-syntax-tree)
39+
40+
(defcustom lsp-ruby-syntax-tree-format-options nil
41+
"Options to pass to the stree lsp server."
42+
:type '(repeat string)
43+
:group 'lsp-ruby-syntax-tree)
44+
45+
(defun lsp-ruby-syntax-tree--build-command ()
46+
(append
47+
(if lsp-ruby-syntax-tree-use-bundler '("bundle" "exec"))
48+
'("stree" "lsp")
49+
lsp-ruby-syntax-tree-format-options))
50+
51+
(lsp-register-client
52+
(make-lsp-client
53+
:new-connection (lsp-stdio-connection #'lsp-ruby-syntax-tree--build-command)
54+
:major-modes '(ruby-mode enh-ruby-mode)
55+
:priority -4
56+
:server-id 'ruby-syntax-tree-ls))
57+
58+
(provide 'lsp-ruby-syntax-tree)
59+
;;; lsp-ruby-syntax-tree.el ends here

docs/lsp-clients.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -733,6 +733,15 @@
733733
"installation-url": "https://github.com/imc-trading/svlangserver#installation",
734734
"debugger": "Not available"
735735
},
736+
{
737+
"name": "syntax_tree",
738+
"common-group-name": "Ruby (syntax_tree)",
739+
"full-name": "ruby-syntax-tree",
740+
"server-name": "stree",
741+
"server-url": "https://github.com/ruby-syntax-tree/syntax_tree",
742+
"installation-url": "https://github.com/ruby-syntax-tree/syntax_tree#installation",
743+
"debugger": "Not available"
744+
},
736745
{
737746
"name": "terraform",
738747
"full-name": "Terraform",

lsp-mode.el

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ As defined by the Language Server Protocol 3.16."
182182
lsp-pyright lsp-python-ms lsp-purescript lsp-r lsp-racket lsp-remark lsp-rf lsp-rust lsp-solargraph
183183
lsp-sorbet lsp-sourcekit lsp-sonarlint lsp-tailwindcss lsp-tex lsp-terraform lsp-toml
184184
lsp-ttcn3 lsp-typeprof lsp-v lsp-vala lsp-verilog lsp-vetur lsp-volar lsp-vhdl lsp-vimscript
185-
lsp-xml lsp-yaml lsp-sqls lsp-svelte lsp-steep lsp-zig)
185+
lsp-xml lsp-yaml lsp-ruby-syntax-tree lsp-sqls lsp-svelte lsp-steep lsp-zig)
186186
"List of the clients to be automatically required."
187187
:group 'lsp-mode
188188
:type '(repeat symbol))

0 commit comments

Comments
 (0)