Vim now loads most defaults from the json file
This commit is contained in:
parent
534f6f57d4
commit
8bc888d711
@ -51,6 +51,7 @@ function! youcompleteme#Enable()
|
||||
py from ycm import utils
|
||||
py utils.AddThirdPartyFoldersToSysPath()
|
||||
py from ycm import base
|
||||
py base.LoadJsonDefaultsIntoVim()
|
||||
py from ycm import vimsupport
|
||||
py from ycm import user_options_store
|
||||
py user_options_store.SetAll( base.BuildServerConf() )
|
||||
@ -161,6 +162,11 @@ function! s:SetUpBackwardsCompatibility()
|
||||
let g:ycm_complete_in_strings = 1
|
||||
let g:ycm_complete_in_comments = 1
|
||||
endif
|
||||
|
||||
" ycm_filetypes_to_completely_ignore is the old name for fileype_blacklist
|
||||
if has_key( g:, 'ycm_filetypes_to_completely_ignore' )
|
||||
let g:filetype_blacklist = g:ycm_filetypes_to_completely_ignore
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
||||
|
@ -60,32 +60,11 @@ endif
|
||||
|
||||
let g:loaded_youcompleteme = 1
|
||||
|
||||
let g:ycm_min_num_of_chars_for_completion =
|
||||
\ get( g:, 'ycm_min_num_of_chars_for_completion', 2 )
|
||||
|
||||
let g:ycm_min_num_identifier_candidate_chars =
|
||||
\ get( g:, 'ycm_min_num_identifier_candidate_chars', 0 )
|
||||
|
||||
let g:ycm_filetype_whitelist =
|
||||
\ get( g:, 'ycm_filetype_whitelist', {
|
||||
\ '*' : 1,
|
||||
\ } )
|
||||
|
||||
" The fallback to g:ycm_filetypes_to_completely_ignore is here because of
|
||||
" backwards compatibility with previous versions of YCM.
|
||||
let g:ycm_filetype_blacklist =
|
||||
\ get( g:, 'ycm_filetype_blacklist',
|
||||
\ get( g:, 'ycm_filetypes_to_completely_ignore', {
|
||||
\ 'notes' : 1,
|
||||
\ 'qf': 1,
|
||||
\ 'markdown' : 1,
|
||||
\ 'text' : 1,
|
||||
\ 'unite' : 1,
|
||||
\ 'tagbar' : 1,
|
||||
\ } ) )
|
||||
|
||||
let g:ycm_filetype_specific_completion_to_disable =
|
||||
\ get( g:, 'ycm_filetype_specific_completion_to_disable', {} )
|
||||
" NOTE: Most defaults are in default_settings.json. They are loaded into Vim
|
||||
" global with the 'ycm_' prefix if such a key does not already exist; thus, the
|
||||
" user can override the defaults.
|
||||
" The only defaults that are here are the ones that are only relevant to the YCM
|
||||
" Vim client and not the server.
|
||||
|
||||
let g:ycm_register_as_syntastic_checker =
|
||||
\ get( g:, 'ycm_register_as_syntastic_checker', 1 )
|
||||
@ -96,30 +75,12 @@ let g:ycm_allow_changing_updatetime =
|
||||
let g:ycm_add_preview_to_completeopt =
|
||||
\ get( g:, 'ycm_add_preview_to_completeopt', 0 )
|
||||
|
||||
let g:ycm_complete_in_comments =
|
||||
\ get( g:, 'ycm_complete_in_comments', 0 )
|
||||
|
||||
let g:ycm_complete_in_strings =
|
||||
\ get( g:, 'ycm_complete_in_strings', 1 )
|
||||
|
||||
let g:ycm_collect_identifiers_from_comments_and_strings =
|
||||
\ get( g:, 'ycm_collect_identifiers_from_comments_and_strings', 0 )
|
||||
|
||||
let g:ycm_collect_identifiers_from_tags_files =
|
||||
\ get( g:, 'ycm_collect_identifiers_from_tags_files', 0 )
|
||||
|
||||
let g:ycm_seed_identifiers_with_syntax =
|
||||
\ get( g:, 'ycm_seed_identifiers_with_syntax', 0 )
|
||||
|
||||
let g:ycm_autoclose_preview_window_after_completion =
|
||||
\ get( g:, 'ycm_autoclose_preview_window_after_completion', 0 )
|
||||
|
||||
let g:ycm_autoclose_preview_window_after_insertion =
|
||||
\ get( g:, 'ycm_autoclose_preview_window_after_insertion', 0 )
|
||||
|
||||
let g:ycm_max_diagnostics_to_display =
|
||||
\ get( g:, 'ycm_max_diagnostics_to_display', 30 )
|
||||
|
||||
let g:ycm_key_list_select_completion =
|
||||
\ get( g:, 'ycm_key_list_select_completion', ['<TAB>', '<Down>'] )
|
||||
|
||||
@ -132,41 +93,9 @@ let g:ycm_key_invoke_completion =
|
||||
let g:ycm_key_detailed_diagnostics =
|
||||
\ get( g:, 'ycm_key_detailed_diagnostics', '<leader>d' )
|
||||
|
||||
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_extra_conf_globlist =
|
||||
\ get( g:, 'ycm_extra_conf_globlist', [] )
|
||||
|
||||
let g:ycm_filepath_completion_use_working_dir =
|
||||
\ get( g:, 'ycm_filepath_completion_use_working_dir', 0 )
|
||||
|
||||
" Default semantic triggers are in python/ycm/completers/completer_utils.py
|
||||
" these just append new triggers to the default dict.
|
||||
let g:ycm_semantic_triggers =
|
||||
\ get( g:, 'ycm_semantic_triggers', {} )
|
||||
|
||||
let g:ycm_cache_omnifunc =
|
||||
\ get( g:, 'ycm_cache_omnifunc', 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_csharp_server_port =
|
||||
\ get( g:, 'ycm_csharp_server_port', 2000 )
|
||||
|
||||
let g:ycm_server_use_vim_stdout =
|
||||
\ get( g:, 'ycm_server_use_vim_stdout', 0 )
|
||||
|
||||
let g:ycm_server_log_level =
|
||||
\ get( g:, 'ycm_server_log_level', 'info' )
|
||||
|
||||
" On-demand loading. Let's use the autoload folder and not slow down vim's
|
||||
" startup procedure.
|
||||
augroup youcompletemeStart
|
||||
|
@ -22,6 +22,7 @@ import re
|
||||
import vim
|
||||
from ycm import vimsupport
|
||||
from ycm import utils
|
||||
from ycm import user_options_store
|
||||
|
||||
YCM_VAR_PREFIX = 'ycm_'
|
||||
|
||||
@ -40,12 +41,7 @@ def BuildServerConf():
|
||||
"""Builds a dictionary mapping YCM Vim user options to values. Option names
|
||||
don't have the 'ycm_' prefix."""
|
||||
|
||||
try:
|
||||
# vim.vars is fairly new so it might not exist
|
||||
vim_globals = vim.vars
|
||||
except:
|
||||
vim_globals = vim.eval( 'g:' )
|
||||
|
||||
vim_globals = vimsupport.GetReadOnlyVimGlobals()
|
||||
server_conf = {}
|
||||
for key, value in vim_globals.items():
|
||||
if not key.startswith( YCM_VAR_PREFIX ):
|
||||
@ -60,6 +56,15 @@ def BuildServerConf():
|
||||
return server_conf
|
||||
|
||||
|
||||
def LoadJsonDefaultsIntoVim():
|
||||
defaults = user_options_store.DefaultOptions()
|
||||
vim_defaults = {}
|
||||
for key, value in defaults.iteritems():
|
||||
vim_defaults[ 'ycm_' + key ] = value
|
||||
|
||||
vimsupport.LoadDictIntoVimGlobals( vim_defaults, overwrite = False )
|
||||
|
||||
|
||||
def CompletionStartColumn():
|
||||
"""Returns the 0-based index where the completion string should start. So if
|
||||
the user enters:
|
||||
|
@ -1,26 +1,23 @@
|
||||
{
|
||||
"filepath_completion_use_working_dir": 0,
|
||||
"min_num_of_chars_for_completion": 2,
|
||||
"min_num_identifier_candidate_chars": 0,
|
||||
"semantic_triggers": {},
|
||||
"collect_identifiers_from_comments_and_strings": 0,
|
||||
"filetype_specific_completion_to_disable": {
|
||||
"gitcommit": 1
|
||||
},
|
||||
"seed_identifiers_with_syntax": 0,
|
||||
"collect_identifiers_from_comments_and_strings": 0,
|
||||
"collect_identifiers_from_tags_files": 0,
|
||||
"extra_conf_globlist": [],
|
||||
"global_ycm_extra_conf": "",
|
||||
"confirm_extra_conf": 1,
|
||||
"complete_in_comments": 0,
|
||||
"complete_in_strings": 1,
|
||||
"min_num_identifier_candidate_chars": 0,
|
||||
"max_diagnostics_to_display": 30,
|
||||
"auto_stop_csharp_server": 1,
|
||||
"seed_identifiers_with_syntax": 0,
|
||||
"csharp_server_port": 2000,
|
||||
"filetype_whitelist": {
|
||||
"*": 1
|
||||
},
|
||||
"auto_start_csharp_server": 1,
|
||||
"filetype_blacklist": {
|
||||
"tagbar": 1,
|
||||
"qf": 1,
|
||||
@ -28,5 +25,10 @@
|
||||
"markdown": 1,
|
||||
"unite": 1,
|
||||
"text": 1
|
||||
}
|
||||
},
|
||||
"server_use_vim_stdout": 0,
|
||||
"server_log_level": "info",
|
||||
"auto_start_csharp_server": 1,
|
||||
"auto_stop_csharp_server": 1,
|
||||
"csharp_server_port": 2000
|
||||
}
|
||||
|
@ -37,10 +37,10 @@ def Value( key ):
|
||||
|
||||
|
||||
def LoadDefaults():
|
||||
SetAll( _DefaultOptions() )
|
||||
SetAll( DefaultOptions() )
|
||||
|
||||
|
||||
def _DefaultOptions():
|
||||
def DefaultOptions():
|
||||
settings_path = os.path.join(
|
||||
os.path.dirname( os.path.abspath( __file__ ) ),
|
||||
'server/default_settings.json' )
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
import vim
|
||||
import os
|
||||
import json
|
||||
|
||||
def CurrentLineAndColumn():
|
||||
"""Returns the 0-based current line and 0-based current column."""
|
||||
@ -82,6 +83,26 @@ def GetBufferNumberForFilename( filename, open_file_if_needed = True ):
|
||||
int( open_file_if_needed ) ) ) )
|
||||
|
||||
|
||||
# Given a dict like {'a': 1}, loads it into Vim as if you ran 'let g:a = 1'
|
||||
# When |overwrite| is True, overwrites the existing value in Vim.
|
||||
def LoadDictIntoVimGlobals( new_globals, overwrite = True ):
|
||||
extend_option = '"force"' if overwrite else '"keep"'
|
||||
|
||||
# We need to use json.dumps because that won't use the 'u' prefix on strings
|
||||
# which Vim would bork on.
|
||||
vim.eval( 'extend( g:, {}, {})'.format( json.dumps( new_globals ),
|
||||
extend_option ) )
|
||||
|
||||
|
||||
# Changing the returned dict will NOT change the value in Vim.
|
||||
def GetReadOnlyVimGlobals():
|
||||
try:
|
||||
# vim.vars is fairly new so it might not exist
|
||||
return vim.vars
|
||||
except:
|
||||
return vim.eval( 'g:' )
|
||||
|
||||
|
||||
# Both |line| and |column| need to be 1-based
|
||||
def JumpToLocation( filename, line, column ):
|
||||
# Add an entry to the jumplist
|
||||
|
Loading…
Reference in New Issue
Block a user