config

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

lsp-ruby-lsp.el (1723B)


      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   :priority -2
     51   :server-id 'ruby-lsp-ls))
     52 
     53 (lsp-consistency-check lsp-ruby-lsp)
     54 
     55 (provide 'lsp-ruby-lsp)
     56 ;;; lsp-ruby-lsp.el ends here