Description: Load ycmd default settings from its default_settings.json
 Upstream prefers to keep the configuration in one place, but as Debian has
 ycmd and vim-youcompleteme in two different packages and can update them
 independently it makes more sense to not override the defaults ycmd has
 as that would require updating both packages then.
 .
 This is still the case as the configuration options are only documented here
 as they can only be changed sensible from here by the user, but it allows at
 least the package maintainer to change options in one place and only have the
 documentation lagging behind (or ahead) slightly.
Author: David Kalnischkies <donkult@debian.org>
Forwarded: yes, but refused: https://github.com/ycm-core/YouCompleteMe/issues/3639
Last-Update: 2020-10-28

--- a/README.md
+++ b/README.md
@@ -2205,7 +2205,7 @@
 Setting this option to a high number like `99` effectively turns off the
 identifier completion engine and just leaves the semantic engine.
 
-Default: `2`
+Default: `2` (set by Debian's `ycmd` package)
 
 ```viml
 let g:ycm_min_num_of_chars_for_completion = 2
@@ -2222,7 +2222,7 @@
 **NOTE:** This option only applies to the identifier completer; it has no effect
 on the various semantic completers.
 
-Default: `0`
+Default: `0` (set by Debian's `ycmd` package)
 
 ```viml
 let g:ycm_min_num_identifier_candidate_chars = 0
@@ -2242,7 +2242,7 @@
 recommended as it will slow down completion when there are a very large number
 of suggestions.
 
-Default: `50`
+Default: `50` (set by Debian's `ycmd` package)
 
 ```viml
 let g:ycm_max_num_candidates = 50
@@ -2299,7 +2299,7 @@
 recommended as it will slow down completion when there are a very large number
 of suggestions.
 
-Default: `10`
+Default: `10` (set by Debian's `ycmd` package)
 
 ```viml
 let g:ycm_max_num_identifier_candidates = 10
@@ -2316,7 +2316,7 @@
 triggers, you should set `g:ycm_min_num_of_chars_for_completion` to a high
 number like `99`.
 
-Default: `1`
+Default: `1` (set by Debian's `ycmd` package)
 
 ```viml
 let g:ycm_auto_trigger = 1
@@ -2415,7 +2415,7 @@
 
 You can get the filetype of the current file in Vim with `:set ft?`.
 
-Default: `[see next line]`
+Default: `[see next line]` (set by Debian's `ycmd` package)
 
 ```viml
 let g:ycm_filetype_specific_completion_to_disable = {
@@ -2705,7 +2705,7 @@
 identifiers from strings and comments. Otherwise, the text in comments and
 strings will be ignored.
 
-Default: `0`
+Default: `0` (set by Debian's `ycmd` package)
 
 ```viml
 let g:ycm_collect_identifiers_from_comments_and_strings = 0
@@ -2811,7 +2811,7 @@
 
 To see where the logfiles are, call `:YcmDebugInfo`.
 
-Default: `0`
+Default: `0` (set by Debian's `ycmd` package)
 
 ```viml
 let g:ycm_keep_logfiles = 0
@@ -2840,7 +2840,7 @@
 When set to `1`, the OmniSharp-Roslyn server will be automatically started
 (once per Vim session) when you open a C# file.
 
-Default: `1`
+Default: `1` (set by Debian's `ycmd` package)
 
 ```viml
 let g:ycm_auto_start_csharp_server = 1
@@ -2851,7 +2851,7 @@
 When set to `1`, the OmniSharp-Roslyn server will be automatically stopped upon
 closing Vim.
 
-Default: `1`
+Default: `1` (set by Debian's `ycmd` package)
 
 ```viml
 let g:ycm_auto_stop_csharp_server = 1
@@ -2863,7 +2863,7 @@
 the OmniSharp-Roslyn server to listen on. When set to `0` uses an unused port provided
 by the OS.
 
-Default: `0`
+Default: `0` (set by Debian's `ycmd` package)
 
 ```viml
 let g:ycm_csharp_server_port = 0
@@ -3045,10 +3045,10 @@
 
 You can place such a global file anywhere in your filesystem.
 
-Default: `''`
+Default: `'/usr/lib/ycmd/ycm_extra_conf.py'` (set by Debian's `ycmd` package)
 
 ```viml
-let g:ycm_global_ycm_extra_conf = ''
+let g:ycm_global_ycm_extra_conf = '/usr/lib/ycmd/ycm_extra_conf.py'
 ```
 
 ### The `g:ycm_confirm_extra_conf` option
@@ -3060,7 +3060,7 @@
 To selectively get YCM to ask/not ask about loading certain `.ycm_extra_conf.py`
 files, see the `g:ycm_extra_conf_globlist` option.
 
-Default: `1`
+Default: `1` (set by Debian's `ycmd` package)
 
 ```viml
 let g:ycm_confirm_extra_conf = 1
@@ -3100,7 +3100,7 @@
 `os.path.expanduser()` and then resolved with `os.path.abspath()` before being
 matched against the filename.
 
-Default: `[]`
+Default: `[]` (set by Debian's `ycmd` package)
 
 ```viml
 let g:ycm_extra_conf_globlist = []
@@ -3113,7 +3113,7 @@
 Setting this option will force YCM to always interpret relative paths as being
 relative to Vim's current working directory.
 
-Default: `0`
+Default: `0` (set by Debian's `ycmd` package)
 
 ```viml
 let g:ycm_filepath_completion_use_working_dir = 0
@@ -3142,7 +3142,7 @@
 
 **NOTE:** The regex syntax is **NOT** Vim's, it's [Python's][python-re].
 
-Default: `[see next line]`
+Default: `{}` (set by Debian's `ycmd` package)
 
 ```viml
 let g:ycm_semantic_triggers =  {
@@ -3182,7 +3182,7 @@
 Default: `1`
 
 ```viml
-let g:ycm_use_ultisnips_completer = 1
+let g:ycm_use_ultisnips_completer = 1 (set by Debian's `ycmd` package)
 ```
 
 ### The `g:ycm_goto_buffer_command` option
@@ -3232,6 +3232,22 @@
 let g:ycm_disable_for_files_larger_than_kb = 1000
 ```
 
+### The `g:ycm_use_clang` option (Debian specific)
+
+This option controls whether **clang** should be used as completion engine for
+C-family languages. Can take one of the following values: `1`, `0`, with
+meanings:
+
+- `1`: YCM will use the built in clang-library-based completer
+if the **clangd** competer is not available or disabled.
+- `0`: YCM will never use clang completer.
+
+Default: `1` (set by Debian's `ycmd` package)
+
+```viml
+let g:ycm_use_clang = 1
+```
+
 ### The `g:ycm_use_clangd` option
 
 This option controls whether **clangd** should be used as completion engine for
@@ -3242,7 +3258,7 @@
 provided with `ycm_clangd_binary_path` option.
 - `0`: YCM will never use clangd completer.
 
-Default: `1`
+Default: `1` (set by Debian's `ycmd` package)
 
 ```viml
 let g:ycm_use_clangd = 1
@@ -3253,10 +3269,10 @@
 When `ycm_use_clangd` option is set to `1`, this option sets the path to
 **clangd** binary.
 
-Default: `''`
+Default: `'/usr/bin/clangd'` (set by Debian's `ycmd` package)
 
 ```viml
-let g:ycm_clangd_binary_path = ''
+let g:ycm_clangd_binary_path = '/usr/bin/clangd'
 ```
 
 ### The `g:ycm_clangd_args` option
@@ -3264,7 +3280,7 @@
 This option controls the command line arguments passed to the clangd binary. It
 appends new options and overrides the existing ones.
 
-Default: `[]`
+Default: `[]` (set by Debian's `ycmd` package)
 
 ```viml
 let g:ycm_clangd_args = []
@@ -3278,7 +3294,7 @@
 - `1`: Uses ycmd's caching and filtering logic.
 - `0`: Uses clangd's caching and filtering logic.
 
-Default: `1`
+Default: `1` (set by Debian's `ycmd` package)
 
 ```viml
 let g:ycm_clangd_uses_ycmd_caching = 1
@@ -3294,10 +3310,20 @@
 A simple working example of this option can be found in the section called
 ["Semantic Completion for Other Languages"](#semantic-completion-for-other-languages).
 
-Default: `[]`
+Default: `[see next line]` (set by Debian's `ycmd` package)
 
 ```viml
-let g:ycm_language_server = []
+let g:ycm_language_server =
+  \ [{
+  \   'name': 'ccls',
+  \   'cmdline': [ 'ccls' ],
+  \   'filetypes': [ 'c', 'cpp', 'cuda', 'objc', 'objcpp' ],
+  \   'project_root_files': [ '.ccls-root', 'compile_commands.json' ]
+  \ }, {
+  \   'name': 'fortran',
+  \   'filetypes': [ 'fortran' ],
+  \   'cmdline': [ 'fortls' ]
+  \ }]
 ```
 
 ### The `g:ycm_disable_signature_help` option
@@ -3307,7 +3333,7 @@
 that while signature help support remains experimental, its values and meaning
 may change and it may be removed in a future version.
 
-Default: `0`
+Default: `0` (set by Debian's `ycmd` package)
 
 ```viml
 " Disable signature help
@@ -3328,7 +3354,7 @@
 Similar to [the `g:ycm_clangd_args`](#the-gycm-clangd-args), this option allows
 passing additional flags to the `gopls` command line.
 
-Default: `[]`
+Default: `[]` (set by Debian's `ycmd` package)
 
 ```viml
 let g:ycm_gopls_args = []
--- a/doc/youcompleteme.txt
+++ b/doc/youcompleteme.txt
@@ -2429,7 +2429,7 @@
 Setting this option to a high number like '99' effectively turns off the
 identifier completion engine and just leaves the semantic engine.
 
-Default: '2'
+Default: '2' (set by Debian's *ycmd* package)
 >
   let g:ycm_min_num_of_chars_for_completion = 2
 <
@@ -2445,7 +2445,7 @@
 **NOTE:** This option only applies to the identifier completer; it has no
 effect on the various semantic completers.
 
-Default: '0'
+Default: '0' (set by Debian's *ycmd* package)
 >
   let g:ycm_min_num_identifier_candidate_chars = 0
 <
@@ -2463,7 +2463,7 @@
 recommended as it will slow down completion when there are a very large number
 of suggestions.
 
-Default: '50'
+Default: '50' (set by Debian's *ycmd* package)
 >
   let g:ycm_max_num_candidates = 50
 <
@@ -2518,7 +2518,7 @@
 recommended as it will slow down completion when there are a very large number
 of suggestions.
 
-Default: '10'
+Default: '10' (set by Debian's *ycmd* package)
 >
   let g:ycm_max_num_identifier_candidates = 10
 <
@@ -2534,7 +2534,7 @@
 triggers, you should set |g:ycm_min_num_of_chars_for_completion| to a high
 number like '99'.
 
-Default: '1'
+Default: '1' (set by Debian's *ycmd* package)
 >
   let g:ycm_auto_trigger = 1
 <
@@ -2612,7 +2612,7 @@
 
 You can get the filetype of the current file in Vim with ':set ft?'.
 
-Default: '[see next line]'
+Default: '[see next line]' (set by Debian's *ycmd* package)
 >
   let g:ycm_filetype_specific_completion_to_disable = {
         \ 'gitcommit': 1
@@ -2634,7 +2634,7 @@
 <
 You can get the filetype of the current file in Vim with ':set ft?'.
 
-Default: '[see next line]'
+Default: '[see next line]' (set by Debian's *ycmd* package)
 >
   let g:ycm_filepath_blacklist = {
         \ 'html': 1,
@@ -2886,7 +2886,7 @@
 identifiers from strings and comments. Otherwise, the text in comments and
 strings will be ignored.
 
-Default: '0'
+Default: '0' (set by Debian's *ycmd* package)
 >
   let g:ycm_collect_identifiers_from_comments_and_strings = 0
 <
@@ -2983,7 +2983,7 @@
 
 To see where the logfiles are, call |:YcmDebugInfo|.
 
-Default: '0'
+Default: '0' (set by Debian's *ycmd* package)
 >
   let g:ycm_keep_logfiles = 0
 <
@@ -3006,7 +3006,7 @@
 When set to '1', the OmniSharp-Roslyn server will be automatically started
 (once per Vim session) when you open a C# file.
 
-Default: '1'
+Default: '1' (set by Debian's *ycmd* package)
 >
   let g:ycm_auto_start_csharp_server = 1
 <
@@ -3016,7 +3016,7 @@
 When set to '1', the OmniSharp-Roslyn server will be automatically stopped upon
 closing Vim.
 
-Default: '1'
+Default: '1' (set by Debian's *ycmd* package)
 >
   let g:ycm_auto_stop_csharp_server = 1
 <
@@ -3027,7 +3027,7 @@
 OmniSharp-Roslyn server to listen on. When set to '0' uses an unused port
 provided by the OS.
 
-Default: '0'
+Default: '0' (set by Debian's *ycmd* package)
 >
   let g:ycm_csharp_server_port = 0
 <
@@ -3199,9 +3199,9 @@
 
 You can place such a global file anywhere in your filesystem.
 
-Default: "''"
+Default: "'/usr/lib/ycmd/ycm_extra_conf.py'" (set by Debian's *ycmd* package)
 >
-  let g:ycm_global_ycm_extra_conf = ''
+  let g:ycm_global_ycm_extra_conf = '/usr/lib/ycmd/ycm_extra_conf.py'
 <
 -------------------------------------------------------------------------------
 The *g:ycm_confirm_extra_conf* option
@@ -3213,7 +3213,7 @@
 To selectively get YCM to ask/not ask about loading certain
 '.ycm_extra_conf.py' files, see the |g:ycm_extra_conf_globlist| option.
 
-Default: '1'
+Default: '1' (set by Debian's *ycmd* package)
 >
   let g:ycm_confirm_extra_conf = 1
 <
@@ -3252,7 +3252,7 @@
 'os.path.expanduser()' and then resolved with 'os.path.abspath()' before being
 matched against the filename.
 
-Default: '[]'
+Default: '[]' (set by Debian's *ycmd* package)
 >
   let g:ycm_extra_conf_globlist = []
 <
@@ -3264,7 +3264,7 @@
 Setting this option will force YCM to always interpret relative paths as being
 relative to Vim's current working directory.
 
-Default: '0'
+Default: '0' (set by Debian's *ycmd* package)
 >
   let g:ycm_filepath_completion_use_working_dir = 0
 <
@@ -3292,7 +3292,7 @@
 
 **NOTE:** The regex syntax is **NOT** Vim's, it's Python's [75].
 
-Default: '[see next line]'
+Default: '{}' (set by Debian's *ycmd* package)
 >
   let g:ycm_semantic_triggers =  {
     \   'c': ['->', '.'],
@@ -3327,7 +3327,7 @@
 By default, YCM will query the UltiSnips plugin for possible completions of
 snippet triggers. This option can turn that behavior off.
 
-Default: '1'
+Default: '1' (set by Debian's *ycmd* package)
 >
   let g:ycm_use_ultisnips_completer = 1
 <
@@ -3376,6 +3376,21 @@
   let g:ycm_disable_for_files_larger_than_kb = 1000
 <
 -------------------------------------------------------------------------------
+The *g:ycm_use_clang* option (Debian specific)
+
+This option controls whether **clang** should be used as completion engine for
+C-family languages. Can take one of the following values: `1`, `0`, with
+meanings:
+
+- `1`: YCM will use the built in clang-library-based completer
+if the **clangd** competer is not available or disabled.
+- `0`: YCM will never use clang completer.
+
+Default: `1` (set by Debian's *ycmd* package)
+>
+  let g:ycm_use_clang = 1
+<
+-------------------------------------------------------------------------------
 The *g:ycm_use_clangd* option
 
 This option controls whether **clangd** should be used as completion engine for
@@ -3386,7 +3401,7 @@
   provided with 'ycm_clangd_binary_path' option.
 - '0': YCM will never use clangd completer.
 
-Default: '1'
+Default: '1' (set by Debian's *ycmd* package)
 >
   let g:ycm_use_clangd = 1
 <
@@ -3396,9 +3411,9 @@
 When 'ycm_use_clangd' option is set to '1', this option sets the path to
 **clangd** binary.
 
-Default: "''"
+Default: "'/usr/bin/clangd'" (set by Debian's *ycmd* package)
 >
-  let g:ycm_clangd_binary_path = ''
+  let g:ycm_clangd_binary_path = '/usr/bin/clangd'
 <
 -------------------------------------------------------------------------------
 The *g:ycm_clangd_args* option
@@ -3406,7 +3421,7 @@
 This option controls the command line arguments passed to the clangd binary. It
 appends new options and overrides the existing ones.
 
-Default: '[]'
+Default: '[]' (set by Debian's *ycmd* package)
 >
   let g:ycm_clangd_args = []
 <
@@ -3434,9 +3449,19 @@
 A simple working example of this option can be found in the section called
 "Semantic Completion for Other Languages".
 
-Default: '[]'
+Default: '[see next line]' (set by Debian's *ycmd* package)
 >
-  let g:ycm_language_server = []
+  let g:ycm_language_server =
+    \ [{
+    \   'name': 'ccls',
+    \   'cmdline': [ 'ccls' ],
+    \   'filetypes': [ 'c', 'cpp', 'cuda', 'objc', 'objcpp' ],
+    \   'project_root_files': [ '.ccls-root', 'compile_commands.json' ]
+    \ }, {
+    \   'name': 'fortran',
+    \   'filetypes': [ 'fortran' ],
+    \   'cmdline': [ 'fortls' ]
+    \ }]
 <
 -------------------------------------------------------------------------------
 The *g:ycm_disable_signature_help* option
@@ -3446,7 +3471,7 @@
 _reserved_, meaning that while signature help support remains experimental, its
 values and meaning may change and it may be removed in a future version.
 
-Default: '0'
+Default: '0' (set by Debian's *ycmd* package)
 >
   " Disable signature help
   let g:ycm_disable_signature_help = 1
@@ -3466,7 +3491,7 @@
 Similar to the |g:ycm_clangd_args|, this option allows passing additional flags
 to the 'gopls' command line.
 
-Default: '[]'
+Default: '[]' (set by Debian's *ycmd* package)
 >
   let g:ycm_gopls_args = []
 <
--- a/plugin/youcompleteme.vim
+++ b/plugin/youcompleteme.vim
@@ -197,91 +197,21 @@
 
 "
 " List of ycmd options.
+" Beware: We (Debian) load the defaults directly from ycmd
+" instead of embedding the values here as upstream does.
 "
-let g:ycm_filepath_completion_use_working_dir =
-      \ get( g:, 'ycm_filepath_completion_use_working_dir', 0 )
-
-let g:ycm_auto_trigger =
-      \ get( g:, 'ycm_auto_trigger', 1 )
-
-let g:ycm_min_num_of_chars_for_completion =
-      \ get( g:, 'ycm_min_num_of_chars_for_completion', 2 )
-
-let g:ycm_min_identifier_candidate_chars =
-      \ get( g:, 'ycm_min_num_identifier_candidate_chars', 0 )
-
-let g:ycm_semantic_triggers =
-      \ get( g:, 'ycm_semantic_triggers', {} )
-
-let g:ycm_filetype_specific_completion_to_disable =
-      \ get( g:, 'ycm_filetype_specific_completion_to_disable',
-      \      { 'gitcommit': 1 } )
-
-let g:ycm_collect_identifiers_from_comments_and_strings =
-      \ get( g:, 'ycm_collect_identifiers_from_comments_and_strings', 0 )
-
-let g:ycm_max_num_identifier_candidates =
-      \ get( g:, 'ycm_max_num_identifier_candidates', 10 )
-
-let g:ycm_max_num_candidates =
-      \ get( g:, 'ycm_max_num_candidates', 50 )
-
-let g:ycm_extra_conf_globlist =
-      \ get( g:, 'ycm_extra_conf_globlist', [] )
-
-let g:ycm_global_ycm_extra_conf =
-      \ get( g:, 'ycm_global_ycm_extra_conf', '' )
-
-let g:ycm_confirm_extra_conf =
-      \ get( g:, 'ycm_confirm_extra_conf', 1 )
-
-let g:ycm_max_diagnostics_to_display =
-      \ get( g:, 'ycm_max_diagnostics_to_display', 30 )
-
-let g:ycm_filepath_blacklist =
-      \ get( g:, 'ycm_filepath_blacklist', {
-      \   'html': 1,
-      \   'jsx': 1,
-      \   'xml': 1
-      \ } )
-
-let g:ycm_auto_start_csharp_server =
-      \ get( g:, 'ycm_auto_start_csharp_server', 1 )
-
-let g:ycm_auto_stop_csharp_server =
-      \ get( g:, 'ycm_auto_stop_csharp_server', 1 )
-
-let g:ycm_use_ultisnips_completer =
-      \ get( g:, 'ycm_use_ultisnips_completer', 1 )
-
-let g:ycm_csharp_server_port =
-      \ get( g:, 'ycm_csharp_server_port', 0 )
-
-let g:ycm_use_clangd =
-      \ get( g:, 'ycm_use_clangd', 1 )
-
-let g:ycm_clangd_binary_path =
-      \ get( g:, 'ycm_clangd_binary_path', '' )
-
-let g:ycm_clangd_args =
-      \ get( g:, 'ycm_clangd_args', [] )
-
-let g:ycm_clangd_uses_ycmd_caching =
-      \ get( g:, 'ycm_clangd_uses_ycmd_caching', 1 )
-
-" These options are not documented.
-let g:ycm_java_jdtls_extension_path =
-      \ get( g:, 'ycm_java_jdtls_extension_path', [] )
-
-let g:ycm_java_jdtls_use_clean_workspace =
-      \ get( g:, 'ycm_java_jdtls_use_clean_workspace', 1 )
-
-let g:ycm_java_jdtls_workspace_root_path =
-      \ get( g:, 'ycm_java_jdtls_workspace_root_path', '' )
-
-" This option is deprecated.
-let g:ycm_python_binary_path =
-      \ get( g:, 'ycm_python_binary_path', '' )
+if exists( '*json_decode' )
+  let s:option_file = '/usr/lib/ycmd/ycmd/default_settings.json'
+  if filereadable( s:option_file )
+    let s:default_options = json_decode( join( readfile( s:option_file ) ) )
+    for key in keys( s:default_options )
+      if ! has_key( g:, 'ycm_' . key )
+        let g:[ 'ycm_' . key ] = s:default_options[ key ]
+      endif
+    endfor
+    unlet key
+  endif
+endif
 
 if has( 'vim_starting' ) " Loading at startup.
   " We defer loading until after VimEnter to allow the gui to fork (see
