lsp-bufls.el (3217B)
1 ;;; lsp-bufls.el --- bufls-langserver Client settings -*- lexical-binding: t; -*- 2 3 ;; Copyright (C) 2023 Jim Myhrberg 4 5 ;; Author: Jim Myhrberg 6 ;; Keywords: lsp, protobuf, buf, bufls 7 8 ;; This file is not part of GNU Emacs 9 10 ;;; License: 11 ;; 12 ;; This program is free software: you can redistribute it and/or modify 13 ;; it under the terms of the GNU General Public License as published by 14 ;; the Free Software Foundation, either version 3 of the License, or 15 ;; (at your option) any later version. 16 ;; 17 ;; This program is distributed in the hope that it will be useful, 18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of 19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 20 ;; GNU General Public License for more details. 21 ;; 22 ;; You should have received a copy of the GNU General Public License 23 ;; along with this program. If not, see <https://www.gnu.org/licenses/>. 24 25 ;;; Commentary: 26 ;; 27 ;; lsp-bufls client 28 29 ;;; Code: 30 31 (require 'lsp-mode) 32 (require 'lsp-go) 33 34 ;; Buf Language Server 35 (defgroup lsp-bufls nil 36 "Configuration options for Buf Language Server." 37 :group 'lsp-mode 38 :link '(url-lint "https://github.com/bufbuild/buf-language-server") 39 :package-version '(lsp-mode . "9.0.0")) 40 41 (defcustom lsp-bufls-args nil 42 "Arguments to pass to bufls serve." 43 :type '(repeat string) 44 :package-version '(lsp-mode . "9.0.0")) 45 46 (defcustom lsp-bufls-path "bufls" 47 "Command to run bufls." 48 :type 'string 49 :package-version '(lsp-mode . "9.0.0")) 50 51 (defun lsp-bufls-server--stdio-command () 52 "Return the command and args to start bufls-langserver." 53 (let ((args (list lsp-bufls-path "serve"))) 54 (when (and (listp lsp-bufls-args) 55 (> (length lsp-bufls-args) 0)) 56 (setq args (append args lsp-bufls-args))) 57 args)) 58 59 (lsp-register-client 60 (make-lsp-client :new-connection (lsp-stdio-connection 61 #'lsp-bufls-server--stdio-command) 62 :activation-fn (lsp-activate-on "protobuf") 63 :language-id "protobuf" 64 :priority -1 65 :server-id 'bufls)) 66 67 ;; Buf CLI 68 (defgroup lsp-buf nil 69 "Configuration options for buf CLI." 70 :group 'lsp-mode 71 :link '(url-lint "https://github.com/bufbuild/buf") 72 :package-version '(lsp-mode . "9.0.0")) 73 74 (defcustom lsp-buf-args `("beta" "lsp") 75 "Arguments to pass to buf CLI." 76 :type '(repeat string) 77 :group 'lsp-buf 78 :package-version '(lsp-mode . "9.0.0")) 79 80 (defcustom lsp-buf-path "buf" 81 "Command to run buf CLI." 82 :type 'string 83 :group 'lsp-buf 84 :package-version '(lsp-mode . "9.0.0")) 85 86 (defun lsp-buf--stdio-command () 87 "Return the command and args to start buf CLI LSP server." 88 (let ((args (list lsp-buf-path))) 89 (when (and (listp lsp-buf-args) 90 (> (length lsp-buf-args) 0)) 91 (setq args (append args lsp-buf-args))) 92 args)) 93 94 (lsp-register-client 95 (make-lsp-client :new-connection (lsp-stdio-connection 96 #'lsp-buf--stdio-command) 97 :activation-fn (lsp-activate-on "protobuf") 98 :language-id "protobuf" 99 :priority 0 100 :server-id 'buf)) 101 102 (lsp-consistency-check lsp-bufls) 103 104 (provide 'lsp-bufls) 105 ;;; lsp-bufls.el ends here