mirror of
https://github.com/jimeh/.emacs.d.git
synced 2026-02-19 13:46:41 +00:00
feat(lang): add protobuf-mode and configure flycheck to support buf
This commit is contained in:
@@ -189,6 +189,7 @@
|
||||
(require 'siren-nginx)
|
||||
(require 'siren-php)
|
||||
(require 'siren-plantuml)
|
||||
(require 'siren-protobuf)
|
||||
(require 'siren-ruby)
|
||||
(require 'siren-rust)
|
||||
(require 'siren-sass)
|
||||
|
||||
51
modules/languages/siren-protobuf.el
Normal file
51
modules/languages/siren-protobuf.el
Normal file
@@ -0,0 +1,51 @@
|
||||
;;; siren-protobuf.el --- jimeh's Emacs Siren: protobuf-mode configuration.
|
||||
|
||||
;;; Commentary:
|
||||
|
||||
;; Basic configuration for protobuf-mode.
|
||||
|
||||
;;; Code:
|
||||
|
||||
(require 'siren-company)
|
||||
(require 'siren-flycheck)
|
||||
(require 'siren-folding)
|
||||
(require 'siren-prog-mode)
|
||||
|
||||
(use-package protobuf-mode
|
||||
:mode "\\.proto\\'"
|
||||
:hook
|
||||
(protobuf-mode . siren-protobuf-mode-setup)
|
||||
|
||||
:init
|
||||
(defun siren-protobuf-mode-setup ()
|
||||
(run-hooks 'prog-mode-hook)
|
||||
(c-add-style "siren" '((c-basic-offset . 2)
|
||||
(indent-tabs-mode . nil)) t)
|
||||
|
||||
(company-mode +1)
|
||||
(subword-mode +1)
|
||||
(siren-folding))
|
||||
|
||||
(defun flycheck-protobuf-buf-project-root (&optional _checker)
|
||||
"Return the nearest directory holding the buf.yaml configuration."
|
||||
(and buffer-file-name
|
||||
(locate-dominating-file buffer-file-name "buf.yaml")))
|
||||
|
||||
:config
|
||||
(unbind-key "C-c C-u" 'c-mode-base-map)
|
||||
|
||||
(flycheck-define-checker protobuf-buf
|
||||
"A protobuf syntax checker using buf.
|
||||
See URL `https://github.com/bufbuild/buf'."
|
||||
:command ("buf" "lint" "--path" source-original)
|
||||
:error-patterns
|
||||
((warning line-start (file-name) ":" line ":" column ":" (message) line-end))
|
||||
:modes protobuf-mode
|
||||
:enabled flycheck-protobuf-buf-project-root
|
||||
:working-directory flycheck-protobuf-buf-project-root
|
||||
:predicate flycheck-buffer-saved-p)
|
||||
|
||||
(add-to-list 'flycheck-checkers 'protobuf-buf))
|
||||
|
||||
(provide 'siren-protobuf)
|
||||
;;; siren-protobuf.el ends here
|
||||
Reference in New Issue
Block a user