Skip to content

Commit eb9c9c9

Browse files
authored
Add new client: ruby-lsp (#3984)
ruby-lsp is new opinionated language server for Ruby. Please consult a link bellow to learn more: https://github.com/Shopify/ruby-lsp
1 parent ee05f55 commit eb9c9c9

File tree

4 files changed

+80
-1
lines changed

4 files changed

+80
-1
lines changed

clients/lsp-ruby-lsp.el

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
;;; lsp-ruby-lsp.el --- lsp-mode for the Ruby ruby-lsp gem -*- lexical-binding: t; -*-
2+
3+
;; Copyright (C) 2023 Šimon Lukašík
4+
5+
;; Author: Šimon Lukašík
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 ruby-lsp - an optionated language server for Ruby.
24+
;; Not to be confused with lsp-ruby that has been deprecated for a while.
25+
26+
;;; Code:
27+
28+
(require 'lsp-mode)
29+
30+
(defgroup lsp-ruby-lsp nil
31+
"LSP support for the ruby-lsp language server."
32+
:group 'lsp-mode
33+
:link '(url-link "https://github.com/shopify/ruby-lsp"))
34+
35+
(defcustom lsp-ruby-lsp-use-bundler nil
36+
"Run ruby-lsp using bundler."
37+
:type 'boolean
38+
:safe #'booleanp
39+
:group 'lsp-ruby-lsp)
40+
41+
(defun lsp-ruby-lsp--build-command ()
42+
(append
43+
(if lsp-ruby-lsp-use-bundler '("bundle" "exec"))
44+
'("ruby-lsp")))
45+
46+
(lsp-register-client
47+
(make-lsp-client
48+
:new-connection (lsp-stdio-connection #'lsp-ruby-lsp--build-command)
49+
:activation-fn (lsp-activate-on "ruby")
50+
:initialization-options `(
51+
:enabledFeatures ["documentHighlights"
52+
"documentSymbols"
53+
"documentLink"
54+
"diagnostics"
55+
"foldingRanges"
56+
"selectionRanges"
57+
"semanticHighlighting"
58+
"formatting"
59+
"onTypeFormatting"
60+
"codeActions"
61+
"completion"
62+
"inlayHint"
63+
"hover"])
64+
:priority -2
65+
:server-id 'ruby-lsp-ls))
66+
67+
(lsp-consistency-check lsp-ruby-lsp)
68+
69+
(provide 'lsp-ruby-lsp)
70+
;;; lsp-ruby-lsp.el ends here

docs/lsp-clients.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -707,6 +707,14 @@
707707
"installation": "pip install robotframework --user",
708708
"debugger": "Yes"
709709
},
710+
{
711+
"name": "ruby-lsp",
712+
"full-name": "Ruby (ruby-lsp)",
713+
"server-name": "ruby-lsp",
714+
"server-url": "https://github.com/Shopify/ruby-lsp",
715+
"installation": "gem install ruby-lsp",
716+
"debugger": "Not available"
717+
},
710718
{
711719
"name": "ruff-lsp",
712720
"full-name": "Python",

lsp-mode.el

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

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ nav:
124124
- R: page/lsp-r.md
125125
- Racket (jeapostrophe): page/lsp-racket-langserver.md
126126
- Racket (Theia): page/lsp-racket-language-server.md
127+
- Ruby (ruby-lsp): page/lsp-ruby-lsp.md
127128
- Ruby (Solargraph): page/lsp-solargraph.md
128129
- Ruby (Sorbet): page/lsp-sorbet.md
129130
- Ruby (Steep): page/lsp-steep.md

0 commit comments

Comments
 (0)