diff options
author | Adam Patterson <adam@adamrt.com> | 2022-04-02 17:28:21 -0500 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-04-26 22:43:50 +0200 |
commit | 452334ab6e93d10af0e3c2518b173ccfa008a114 (patch) | |
tree | 269107a064762851f1c16135452ba527117e3f93 /Documentation | |
parent | e11fb83bb79a9802121c0a6888141c080ca476a4 (diff) | |
download | serenity-452334ab6e93d10af0e3c2518b173ccfa008a114.zip |
Documentation: Add EmacsConfiguration.md for emacs editor support
Emacs takes a little work to get working with Serenity.
Diffstat (limited to 'Documentation')
-rw-r--r-- | Documentation/EmacsConfiguration.md | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/Documentation/EmacsConfiguration.md b/Documentation/EmacsConfiguration.md new file mode 100644 index 0000000000..d0281ff216 --- /dev/null +++ b/Documentation/EmacsConfiguration.md @@ -0,0 +1,57 @@ +# Emacs Project Configuration + +Emacs can be configured with `lsp-mode` and `clangd` to work well. + +### clangd + +The official clangd extension can be used for C++ comprehension. You +can use the following `.clangd` file placed in the project root: + +```yaml +CompileFlags: + CompilationDatabase: Build/i686 + Add: + - "-D__serenity__" + - "-UNO_TLS" + - "-I/path/to/serenity/Toolchain/Local/i686/i686-pc-serenity/include/c++/11.2.0" + - "-I/path/to/serenity/Toolchain/Local/i686/i686-pc-serenity/include/c++/11.2.0/i686-pc-serenity" +``` + +You will need to change `/path/to/serenity` and change `11.2.0` to +whatever your GCC toolchain version at the time is. + +Run cmake (`Meta/serenity.sh run` or similar) at least once for this +to work, as it will generate the `Build/i686/compile_commands.json` +that is needed by `clangd`. + +### lsp-mode + +```lisp +(use-package lsp-mode + :hook ((c++-mode) . lsp-deferred) + :commands lsp + :config + (setq lsp-clients-clangd-args '("-j=4" "-background-index" "--log=error" "--clang-tidy" "--enable-config")) + ;; Optionally, set the location of clangd -- See notes below for options. + (setq lsp-clangd-binary-path "/usr/bin/clangd")) + +``` + +### clangd + +There are a few different ways to specify which clangd to use: + +- By default, without configuration `lsp-mode` will try to find and use your system `clangd`. This is the easiest solution, but your system clangd might be out of date. +- You can manually specify any `clangd` binary with `lsp-clangd-binary-path`, as shown in the use-package example above. +- You can have `lsp-mode` manage your `clangd` installation with emacs' `lsp-install-server`. This will install a `clangd` binary for you. +- You can build the LLVM toolchain, including `clangd`, from Serenity's repository. This is an advanced option that is not currently documented. + +### clang-format + +There are multiple packages to handle auto formatting with +`clang-format`, within emacs. Choose what works best for your setup: + +- [format-all-mode](https://github.com/lassik/emacs-format-all-the-code) +- [clang-format-plus](https://github.com/SavchenkoValeriy/emacs-clang-format-plus) + +``` |