From 15849409df36188fa7c6cb320fa71e58db5bd8c4 Mon Sep 17 00:00:00 2001 From: Nils Deppe Date: Thu, 5 Dec 2019 21:21:27 -0500 Subject: [PATCH] Add support for clangd customization --- README.md | 13 +++++++++++++ ycmd.el | 28 ++++++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fd45d8e..2dcdc62 100644 --- a/README.md +++ b/README.md @@ -118,6 +118,19 @@ that: After this you can use your standard `company-mode` keybindings to do completion. +## clangd completion + +To use clangd completion you must have built ycmd with the clangd completer +enabled. You must then set `ycmd-use-clangd` to `1`: + +```elisp +(set-variable 'ycmd-use-clangd 1) +``` + +You can also pass extra arguments to clangd by specifying `ycmd-clangd-args` as +a list of string arguments. If you need to explicitly set the path to where +clangd is located you can specify the variable `ycmd-clangd-binary-path`. + ## IMPORTANT: Unbuffered output There have been some reports that `ycmd.el` doesn't work when Python's output is buffered. See, for example, [issue #104](https://github.com/abingham/emacs-ycmd/issues/104). This is because we rely on the ycmd server printing out its host and port information in a timely (i.e. unbuffered) manner. We will almost certainly update the defaults for `ycmd.el` to force unbuffered output. diff --git a/ycmd.el b/ycmd.el index 8065c47..6ab31af 100644 --- a/ycmd.el +++ b/ycmd.el @@ -368,6 +368,22 @@ engine." "Python binary path." :type 'string) +(defcustom ycmd-use-clangd nil + "Use clangd for completion." + :type 'integer) + +(defcustom ycmd-clangd-binary-path nil + "Path to clangd binary." + :type 'string) + +(defcustom ycmd-clangd-args nil + "Extra arguments to pass to clangd when launching." + :type '(repeat string)) + +(defcustom ycmd-clangd-uses-ycmd-caching nil + "Have clangd use ycmd caching." + :type 'integer) + (defcustom ycmd-global-modes t "Modes for which `ycmd-mode' is turned on by `global-ycmd-mode'. @@ -2098,7 +2114,11 @@ file." (swift-src-path (or ycmd-swift-src-path "")) (racerd-binary-path (or ycmd-racerd-binary-path "")) (python-binary-path (or ycmd-python-binary-path "")) - (auto-trigger (if ycmd-auto-trigger-semantic-completion 1 0))) + (auto-trigger (if ycmd-auto-trigger-semantic-completion 1 0)) + (use-clangd (or ycmd-use-clangd 0)) + (clangd-binary-path (or ycmd-clangd-binary-path "")) + (clangd-args (or ycmd-clangd-args [])) + (clangd-uses-ycmd-caching (or ycmd-clangd-uses-ycmd-caching 1))) `((filepath_completion_use_working_dir . 0) (auto_trigger . ,auto-trigger) (min_num_of_chars_for_completion . ,ycmd-min-num-chars-for-completion) @@ -2122,7 +2142,11 @@ file." (rust_src_path . ,rust-src-path) (swift_src_path . ,swift-src-path) (racerd_binary_path . ,racerd-binary-path) - (python_binary_path . ,python-binary-path)))) + (python_binary_path . ,python-binary-path) + (use_clangd . ,use-clangd) + (clangd_binary_path . ,clangd-binary-path) + (clangd_args . ,clangd-args) + (clangd_uses_ycmd_caching . ,clangd-uses-ycmd-caching)))) (defun ycmd--create-options-file (hmac-secret) "Create a new options file for a ycmd server with HMAC-SECRET.