Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for clangd customization #500

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
28 changes: 26 additions & 2 deletions ycmd.el
Original file line number Diff line number Diff line change
Expand Up @@ -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'.

Expand Down Expand Up @@ -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)
Expand All @@ -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.
Expand Down