Skip to content

arteen1000/clang-format-lite

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 

Repository files navigation

clang-format-lite

This is a new take on the clang-format package. It is distinguished because it provides only a lightweight ELisp wrapper around the clang-format binary. It is also distinct from clang-format+, which wraps the former to offer an on-save hook. We incorporate this functionality directly within our package.

Why clang-format-lite?

  • It’s lightweight with no dependencies on other packages.
  • Supports formatting of remote files, which the other packages do not.
  • Integrates clang-format on-save functionality directly.

Getting Started

The package may be installed through MELPA. I recommend use-package.

(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(unless (package-installed-p 'use-package)
  (package-refresh-contents)
  (package-install 'use-package))
(require 'use-package)

(use-package clang-format-lite
  :ensure t)

Configuration

There are two primary public interfaces.

clang-format-lite-save-hook
This buffer-local hook can be added to a mode hook to enable clang-format on save. Furthermore, the variable clang-format-lite-only-if-config determines whether or not clang-format is actually run.
clang-format-lite-only-if-config
This variable can be set to either nil or t. If nil, then clang-format is always run. If t, then clang-format is run only when a .clang-format file is found.

Here is a simple example:

;; run clang-format only if the .clang-format file is found
(setq clang-format-lite-only-if-config t)
;; and we are in c++ mode
(add-hook 'c++-mode-hook #'clang-format-lite-save-hook)
;; or we are in c mode
(add-hook 'c-mode-hook #'clang-format-lite-save-hook)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published