diff --git a/README.md b/README.md index af60ecee8..e55a0ddaa 100644 --- a/README.md +++ b/README.md @@ -1544,6 +1544,10 @@ installing [the Rust source code][rust-src], so no configuration is necessary. `rust-analyzer` supports a myriad of options. These are configured using [LSP configuration](#lsp-configuration), and are [documented here](https://rust-analyzer.github.io/manual.html#configuration]). +For global (`$VIMRC`-level) configuration without a `.ycm_extra_conf.py`, you can +also use the [`g:ycm_completer_settings`](#the-gycm_completer_settings-option) +option. + ### Go Semantic Completion Completions and GoTo commands should work out of the box (provided that you @@ -1565,6 +1569,10 @@ def Settings( **kwargs ): } ``` +For global (`$VIMRC`-level) configuration without a `.ycm_extra_conf.py`, you can +also use the [`g:ycm_completer_settings`](#the-gycm_completer_settings-option) +option. + ### JavaScript and TypeScript Semantic Completion **NOTE:** YCM originally used the [Tern][] engine for JavaScript but due to @@ -1648,6 +1656,8 @@ Many LSP servers allow some level of user configuration. YCM enables this with the help of `.ycm_extra_conf.py` files. Here's an example of jdt.ls user examples of configuring the likes of PHP, Ruby, Kotlin, D, and many, many more. +See also [`g:ycm_completer_settings`](#the-gycm_completer_settings-option). + ```python def Settings( **kwargs ): if kwargs[ 'language' ] == 'java': @@ -3852,6 +3862,44 @@ tells YCM where is the TSServer executable located. Similar to [the `gopls` path](#the-gycm-gopls-binaty-path), this option tells YCM where is the Omnisharp-Roslyn executable located. +### The `g:ycm_completer_settings` option + +Sets global LSP configuration for ycmd's predefined completers (Java, Go, Rust, +C-family) without needing per-project `.ycm_extra_conf.py` files. + +The dictionary keys map to completer names: `java`, `go`, `rust`, and +`cpp`/`c`/`objc`/`objcpp`/`cuda` for C-family. The values are dictionaries of +server settings - equivalent to the `ls` key in the `Settings()` function of +`.ycm_extra_conf.py`. + +**Settings priority** (lowest to highest): +1. Hardcoded completer defaults +2. `g:ycm_completer_settings` +3. The `ls` key returned by `Settings()` in `.ycm_extra_conf.py` + +Example: + +```viml +let g:ycm_completer_settings = { +\ 'go': { +\ 'hoverKind': 'SynopsisDocumentation' +\ }, +\ 'rust': { +\ 'diagnostics': { +\ 'disabled': [ +\ 'inactive-code', +\ ] +\ }, +\ } +\} +``` + +Default: `{}` + +```viml +let g:ycm_completer_settings = {} +``` + ### The `g:ycm_update_diagnostics_in_insert_mode` option With async diagnostics, LSP servers might send new diagnostics mid-typing. diff --git a/doc/youcompleteme.txt b/doc/youcompleteme.txt index 320d0554e..7bd30b651 100644 --- a/doc/youcompleteme.txt +++ b/doc/youcompleteme.txt @@ -197,6 +197,7 @@ Contents ~ 64. The |g:ycm_tsserver_binary_path| option 65. The |g:ycm_roslyn_binary_path| option 66. The |g:ycm_update_diagnostics_in_insert_mode| option + 67. The |g:ycm_completer_settings| option 12. FAQ |youcompleteme-faq| 13. Contributor Code of Conduct |youcompleteme-contributor-code-of-conduct| 14. Contact |youcompleteme-contact| @@ -4069,6 +4070,42 @@ The *g:ycm_roslyn_binary_path* option Similar to the 'gopls' path, this option tells YCM where is the Omnisharp-Roslyn executable located. +------------------------------------------------------------------------------- +The *g:ycm_completer_settings* option + +Sets global LSP configuration for ycmd's predefined completers (Java, Go, Rust, +C-family) without needing per-project '.ycm_extra_conf.py' files. + +The dictionary keys map to completer names: 'java', 'go', 'rust', and +'cpp'/'c'/'objc'/'objcpp'/'cuda' for C-family. The values are dictionaries of +server settings - equivalent to the 'ls' key in the 'Settings()' function of +'.ycm_extra_conf.py'. + +Settings priority (lowest to highest): + 1. Hardcoded completer defaults + 2. 'g:ycm_completer_settings' + 3. The 'ls' key returned by 'Settings()' in '.ycm_extra_conf.py' + +Example: +> + let g:ycm_completer_settings = { + \ 'go': { + \ 'hoverKind': 'SynopsisDocumentation' + \ }, + \ 'rust': { + \ 'diagnostics': { + \ 'disabled': [ + \ 'inactive-code', + \ ] + \ }, + \ } + \} +< + +Default: '{}' +> + let g:ycm_completer_settings = {} +< ------------------------------------------------------------------------------- The *g:ycm_update_diagnostics_in_insert_mode* option