ProductPromotion
Logo

C++ Programming

made by https://0x3d.site

GitHub - Sarcasm/irony-mode: A C/C++ minor mode for Emacs powered by libclang
A C/C++ minor mode for Emacs powered by libclang. Contribute to Sarcasm/irony-mode development by creating an account on GitHub.
Visit Site

GitHub - Sarcasm/irony-mode: A C/C++ minor mode for Emacs powered by libclang

GitHub - Sarcasm/irony-mode: A C/C++ minor mode for Emacs powered by libclang

Irony-Mode

A C/C++ minor mode powered by libclang

irony-mode is an Emacs minor-mode that aims at improving the editing experience for the C, C++ and Objective-C languages. It works by using a combination of an Emacs package and a C++ program (irony-server) exposing libclang.

Features:

Dependencies

Elisp dependencies

These dependencies will be installed automatically when using the standard installation procedure described below.

Package Comment
cl-lib Built-in since Emacs 24.3
json Built-in since Emacs 23.1
YASnippet Optional. May be used to provide post-completion expansion of function arguments

Irony-Server prerequisites

irony-server provides the libclang interface to irony-mode. It uses a simple protocol based on S-expression. This server, written in C++ and requires the following packages to be installed on your system:

Installation

The recommended way to install irony-mode and its dependencies is to use a package manager.

  • Using MELPA

      M-x package-install RET irony RET
    
  • Using apt on Debian ≥10 and derivatives

      sudo apt install elpa-irony
    

Exactly one package manager should manage irony-mode. If using apt, but the MELPA package is desired, uninstall the version managed by apt; Likewise, installing from both MELPA and straight.el may result in a state that requires a manual workaround.

To install the latest Debian-supported irony-mode and Clang

The backports mechanism is the recommended and officially supported method of accessing newer versions than Debian stable provides. For example on Debian 10 (buster):

    sudo apt install -t buster-backports elpa-irony

If one requires a newer version of Clang/LLVM than the one provided in backports, the following repository is available: LLVM Debian/Ubuntu nightly packages. This unofficial repository is maintained by Sylvestre Ledru, who is responsible for the official Debian package. His repository also supports Ubuntu and derivatives. When using this unofficial repository, it is recommended to use the MELPA package of irony-mode and to uninstall elpa-irony. Finally, when switching from apt to MELPA, the following action is required: M-x irony-install-server RET.

Configuration

(add-hook 'c++-mode-hook 'irony-mode)
(add-hook 'c-mode-hook 'irony-mode)
(add-hook 'objc-mode-hook 'irony-mode)

(add-hook 'irony-mode-hook 'irony-cdb-autosetup-compile-options)

Windows considerations

irony-mode should work fine on Windows but there are some things to take care of first.

  • libclang.dll is expected to be available in the PATH or in Emacs' exec-path.

  • Emacs >= 24.4 is required. A bug in previous versions makes irony unuseable (Emacs bug #18420).

  • w32-pipe-read-delay default value of 50 should be changed. This should not cause any issue on today's version of Windows. The default value of 50 may be lowered in mainline Emacs in future versions, until then, I suggest to set it to 0.

  • w32-pipe-buffer-size, introduced by Emacs 25, can be set to a larger value than the default to improve irony-server communication performances (c.f. https://github.com/Sarcasm/irony-mode/issues/321). The variable to customize is irony-server-w32-pipe-buffer-size.

Windows configuration tweaks to add to your Emacs configuration:

;; Windows performance tweaks
;;
(when (boundp 'w32-pipe-read-delay)
  (setq w32-pipe-read-delay 0))
;; Set the buffer size to 64K on Windows (from the original 4K)
(when (boundp 'w32-pipe-buffer-size)
  (setq irony-server-w32-pipe-buffer-size (* 64 1024)))

Usage

On the first run, irony-mode will ask you to build and install irony-server. To do so, type M-x irony-install-server RET.

To tune irony-mode, use customize:

M-x customize-group RET irony RET

In order to provide context sensitive and accurate information, irony-mode needs to know about the compiler flags used to parse the current buffer. The best way to achieve this is to use a Compilation Database.

Compilation Database

In order to work correctly, irony-mode needs to know the compile flags. irony-cdb aims to provide as automatic as possible compile flags discovery, with minimal user input.

Please refer to irony-cdb-autosetup-compile-options and irony-cdb-compilation-databases.

Right now irony-cdb supports the following compilation databases:

  • JSON Compilation Database - A JSON formatted file generated by various build tools. The file is named compile_commands.json, it lists the compile options associated to each file in the project.

    • CMake >= 2.8.5 will generate a compilation database in the build directory when issuing the following command cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON <...>.

    • ninja >= 1.2 will generate a JSON Compilation Database when using the compdb tool.

    • Bear generates a JSON Compilation Database file by "monitoring" the build of a project. The typical usage for a make-based project will be bear -- make -B.

  • .clang_complete - A file at the root of your project containing the compilation flags, one per line. This is compatible with the with plugin Rip-Rip/clang_complete. If you want to generate the .clang_complete automatically, take a look at the cc_args.py documentation.

More detailed information on compilation database is available here:

FAQ

It's slow, why?

A bug in old version of Clang (at least '3.1-8') caused the completion to fail on the standard library types. To eliminate this bug an optimisation has been disabled in the parsing of a translation unit. This result in a slower parsing.

This only affect old versions of Clang (< 3.2), it is suggested to update your libclang installation if you want to take advantage of the optimizations.

libclang.so: cannot open shared object file...

Compiling irony-server succeed but you have the following message when you try to run the irony-server executable:

'irony-server: error while loading shared libraries: libclang.so: cannot open shared object file: No such file or directory

When libclang is installed in a non-standard location (one that is missing from the path list of the dynamic loader, see ld.so.conf) you can tell CMake to use the rpath when installing the target irony-server. To enable rpath in CMake use the following command:

cmake -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=ON <args...>

If you're running OS X, you can also use install_name_tool to explicitly tell irony-server where an appropriate version of libclang.dylib lives. For example, Homebrew (with brew install llvm --with-clang) will install a libclang.dylib library at /usr/local/opt/llvm/lib/libclang.dylib; you can instruct irony-server to use this with something like:

install_name_tool -change @rpath/libclang.dylib /usr/local/opt/llvm/lib/libclang.dylib irony-server

More Resources
to explore the angular.

mail [email protected] to add your project or resources here 🔥.

Related Articles
to learn about angular.

FAQ's
to learn more about Angular JS.

mail [email protected] to add more queries here 🔍.

More Sites
to check out once you're finished browsing here.

0x3d
https://www.0x3d.site/
0x3d is designed for aggregating information.
NodeJS
https://nodejs.0x3d.site/
NodeJS Online Directory
Cross Platform
https://cross-platform.0x3d.site/
Cross Platform Online Directory
Open Source
https://open-source.0x3d.site/
Open Source Online Directory
Analytics
https://analytics.0x3d.site/
Analytics Online Directory
JavaScript
https://javascript.0x3d.site/
JavaScript Online Directory
GoLang
https://golang.0x3d.site/
GoLang Online Directory
Python
https://python.0x3d.site/
Python Online Directory
Swift
https://swift.0x3d.site/
Swift Online Directory
Rust
https://rust.0x3d.site/
Rust Online Directory
Scala
https://scala.0x3d.site/
Scala Online Directory
Ruby
https://ruby.0x3d.site/
Ruby Online Directory
Clojure
https://clojure.0x3d.site/
Clojure Online Directory
Elixir
https://elixir.0x3d.site/
Elixir Online Directory
Elm
https://elm.0x3d.site/
Elm Online Directory
Lua
https://lua.0x3d.site/
Lua Online Directory
C Programming
https://c-programming.0x3d.site/
C Programming Online Directory
C++ Programming
https://cpp-programming.0x3d.site/
C++ Programming Online Directory
R Programming
https://r-programming.0x3d.site/
R Programming Online Directory
Perl
https://perl.0x3d.site/
Perl Online Directory
Java
https://java.0x3d.site/
Java Online Directory
Kotlin
https://kotlin.0x3d.site/
Kotlin Online Directory
PHP
https://php.0x3d.site/
PHP Online Directory
React JS
https://react.0x3d.site/
React JS Online Directory
Angular
https://angular.0x3d.site/
Angular JS Online Directory