Add language layer for Protocol Buffers.

This commit is contained in:
Amol Mandhane 2016-09-05 16:26:03 +05:30 committed by syl20bnr
parent 12eacab665
commit b08faa730e
2 changed files with 59 additions and 0 deletions

View file

@ -0,0 +1,23 @@
#+TITLE: Protocol Buffers layer
#+HTML_HEAD_EXTRA: <link rel="stylesheet" type="text/css" href="../../../css/readtheorg.css" />
* Table of Contents :TOC_4_org:noexport:
- [[Description][Description]]
- [[Features][Features]]
- [[Install][Install]]
* Description
Highlighting and syntax checking for [[https://developers.google.com/protocol-buffers/][Protocol Buffer]] files.
Uses Google's [[https://github.com/google/protobuf/blob/master/editors/protobuf-mode.el][protobuf-mode]] with [[https://github.com/edvorg/flycheck-protobuf][flycheck-protobuf]].
* Features
+ Syntax Highlighting
+ Syntax checking using Flycheck (=protoc= compiler must be available)
+ Correct Indentation and commenting
+ Quickly browse file contents using =M-x helm-imenu= and =M-x imenu=.
* Install
To use this configuration layer, add it to your =~/.spacemacs=. You will need to
add =protobuf= to the existing =dotspacemacs-configuration-layers= list in this
file.

View file

@ -0,0 +1,36 @@
;;; packages.el --- Protocol Buffers Layer packages File for Spacemacs
;;
;; Copyright (c) 2012-2016 Sylvain Benner & Contributors
;;
;; Author: Amol Mandhane <https://github.com/amol-mandhane>
;; URL: https://github.com/syl20bnr/spacemacs
;;
;; This file is not part of GNU Emacs.
;;
;;; License: GPLv3
(setq protobuf-packages
'(
protobuf-mode
flycheck-protobuf
))
(defun protobuf/init-protobuf-mode ()
(use-package protobuf-mode
:init (progn
(defun spacemacs//setup-protobuf-imenu ()
"Setup imenu regex for protocol buffers."
(setq imenu-generic-expression '((nil "^[[:space:]]*\\(message\\|service\\|enum\\)[[:space:]]+\\([[:alnum:]]+\\)"
2))))
(add-hook 'protobuf-mode-hook 'spacemacs//setup-protobuf-imenu))))
(defun protobuf/init-flycheck-protobuf ()
(use-package flycheck-protobuf))
(when (configuration-layer/package-usedp 'flycheck)
(defun protobuf/post-init-flycheck-protobuf ()
(with-eval-after-load 'flycheck-protobuf
(require 'flycheck)
(require 'flycheck-protobuf)
(add-to-list 'flycheck-checkers 'protobuf-protoc-reporter
t))))