Enabling the ccls LSP backend
If you're using spacemacs, enable the c-c++ layer in dotspacemacs-configuration-layers
:
dotspacemacs-configuration-layers '( (c-c++ :variables c-c++-backend 'lsp-ccls c-c++-lsp-enable-semantic-highlight 'rainbow) ... )
And then in dotspacemacs/user-config
:
(dir-locals-set-class-variables 'webkit-instance '((nil . ((c-basic-offset . 4) (indent-tabs-mode . nil) (fill-column . 100) (ccls-executable . "webkit-ccls") (projectile-project-name . "WebKit") (lsp-enable-file-watchers . nil) (lsp-ui-peek-find-references nil (list :folders (vector (projectile-project-root)))) (git-commit-style-convention-checks (remove 'non-empty-second-line git-commit-style-convention-checks)) )) (prog-mode (ccls-initialization-options . (:compilationDatabaseDirectory "/app/webkit/WebKitBuild/Release" :cache (:directory ".ccls-cache") )) ))) (dir-locals-set-directory-class "/home/phil/WebKit/" 'webkit-instance)
DO NOT CHANGE /app/webkit/WebKitBuild
in compilationDatabaseDirectory
because it refers to the standard Flatpak SDK sandbox path.
Then add a new executable script in your PATH, called webkit-ccls
with the following contents (YMMV):
#!/bin/sh set -eu cd $HOME/WebKit/ exec Tools/Scripts/webkit-flatpak -c ccls "$@"
If you are running a Fedora Silverblue host OS, make sure the Emacs flatpak app is called with the --talk-name=org.freedesktop.Flatpak
argument. Then, the webkit-ccls
contents should rather be:
set -eu cd $HOME/WebKit/ exec flatpak-spawn --host Tools/Scripts/webkit-flatpak -c ccls "$@"
Most WebKit header files don't include config.h, which tricks LSP to grey out all file contents in the editor. To fix this, add a .ccls
file in your WebKit checkout:
%compile_commands.json %h -x %h c++-header %h --include=config.h %cpp --include=config.h
Enabling the clangd LSP backend
If you're using spacemacs, enable the c-c++ layer in dotspacemacs-configuration-layers
:
dotspacemacs-configuration-layers '( (c-c++ :variables c-c++-backend 'lsp-clangd c-c++-lsp-enable-semantic-highlight 'rainbow) ... )
And then in dotspacemacs/user-config
:
(dir-locals-set-class-variables 'webkit-instance '((nil . ((c-basic-offset . 4) (indent-tabs-mode . nil) (fill-column . 100) (lsp-clients-clangd-executable . "/home/phil/WebKit/Tools/flatpak/webkit-clangd") (lsp-clients-clangd-args . ("--enable-config" "--gtk" )) (projectile-project-name . "WebKit") (lsp-enable-file-watchers . nil) (lsp-ui-peek-find-references nil (list :folders (vector (projectile-project-root)))) (git-commit-style-convention-checks (remove 'non-empty-second-line git-commit-style-convention-checks)) )) ) ) (dir-locals-set-directory-class "/home/phil/WebKit/" 'webkit-instance)