From b08faa730e31e3c4fc8092cbe491a6b08123f230 Mon Sep 17 00:00:00 2001 From: Amol Mandhane Date: Mon, 5 Sep 2016 16:26:03 +0530 Subject: [PATCH] Add language layer for Protocol Buffers. --- layers/+lang/protobuf/README.org | 23 ++++++++++++++++++++ layers/+lang/protobuf/packages.el | 36 +++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 layers/+lang/protobuf/README.org create mode 100644 layers/+lang/protobuf/packages.el diff --git a/layers/+lang/protobuf/README.org b/layers/+lang/protobuf/README.org new file mode 100644 index 000000000..ca82b4b50 --- /dev/null +++ b/layers/+lang/protobuf/README.org @@ -0,0 +1,23 @@ +#+TITLE: Protocol Buffers layer +#+HTML_HEAD_EXTRA: + +* 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. diff --git a/layers/+lang/protobuf/packages.el b/layers/+lang/protobuf/packages.el new file mode 100644 index 000000000..c101e6094 --- /dev/null +++ b/layers/+lang/protobuf/packages.el @@ -0,0 +1,36 @@ +;;; packages.el --- Protocol Buffers Layer packages File for Spacemacs +;; +;; Copyright (c) 2012-2016 Sylvain Benner & Contributors +;; +;; Author: 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))))