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 from ycm import utils
|
||||||
py utils.AddThirdPartyFoldersToSysPath()
|
py utils.AddThirdPartyFoldersToSysPath()
|
||||||
py from ycm import base
|
py from ycm import base
|
||||||
|
py base.LoadJsonDefaultsIntoVim()
|
||||||
py from ycm import vimsupport
|
py from ycm import vimsupport
|
||||||
py from ycm import user_options_store
|
py from ycm import user_options_store
|
||||||
py user_options_store.SetAll( base.BuildServerConf() )
|
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_strings = 1
|
||||||
let g:ycm_complete_in_comments = 1
|
let g:ycm_complete_in_comments = 1
|
||||||
endif
|
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
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
@ -60,32 +60,11 @@ endif
|
|||||||
|
|
||||||
let g:loaded_youcompleteme = 1
|
let g:loaded_youcompleteme = 1
|
||||||
|
|
||||||
let g:ycm_min_num_of_chars_for_completion =
|
" NOTE: Most defaults are in default_settings.json. They are loaded into Vim
|
||||||
\ get( g:, 'ycm_min_num_of_chars_for_completion', 2 )
|
" global with the 'ycm_' prefix if such a key does not already exist; thus, the
|
||||||
|
" user can override the defaults.
|
||||||
let g:ycm_min_num_identifier_candidate_chars =
|
" The only defaults that are here are the ones that are only relevant to the YCM
|
||||||
\ get( g:, 'ycm_min_num_identifier_candidate_chars', 0 )
|
" Vim client and not the server.
|
||||||
|
|
||||||
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', {} )
|
|
||||||
|
|
||||||
let g:ycm_register_as_syntastic_checker =
|
let g:ycm_register_as_syntastic_checker =
|
||||||
\ get( g:, 'ycm_register_as_syntastic_checker', 1 )
|
\ 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 =
|
let g:ycm_add_preview_to_completeopt =
|
||||||
\ get( g:, 'ycm_add_preview_to_completeopt', 0 )
|
\ 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 =
|
let g:ycm_autoclose_preview_window_after_completion =
|
||||||
\ get( g:, 'ycm_autoclose_preview_window_after_completion', 0 )
|
\ get( g:, 'ycm_autoclose_preview_window_after_completion', 0 )
|
||||||
|
|
||||||
let g:ycm_autoclose_preview_window_after_insertion =
|
let g:ycm_autoclose_preview_window_after_insertion =
|
||||||
\ get( g:, 'ycm_autoclose_preview_window_after_insertion', 0 )
|
\ 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 =
|
let g:ycm_key_list_select_completion =
|
||||||
\ get( g:, 'ycm_key_list_select_completion', ['<TAB>', '<Down>'] )
|
\ 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 =
|
let g:ycm_key_detailed_diagnostics =
|
||||||
\ get( g:, 'ycm_key_detailed_diagnostics', '<leader>d' )
|
\ 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 =
|
let g:ycm_cache_omnifunc =
|
||||||
\ get( g:, 'ycm_cache_omnifunc', 1 )
|
\ 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
|
" On-demand loading. Let's use the autoload folder and not slow down vim's
|
||||||
" startup procedure.
|
" startup procedure.
|
||||||
augroup youcompletemeStart
|
augroup youcompletemeStart
|
||||||
|
@ -22,6 +22,7 @@ import re
|
|||||||
import vim
|
import vim
|
||||||
from ycm import vimsupport
|
from ycm import vimsupport
|
||||||
from ycm import utils
|
from ycm import utils
|
||||||
|
from ycm import user_options_store
|
||||||
|
|
||||||
YCM_VAR_PREFIX = 'ycm_'
|
YCM_VAR_PREFIX = 'ycm_'
|
||||||
|
|
||||||
@ -40,12 +41,7 @@ def BuildServerConf():
|
|||||||
"""Builds a dictionary mapping YCM Vim user options to values. Option names
|
"""Builds a dictionary mapping YCM Vim user options to values. Option names
|
||||||
don't have the 'ycm_' prefix."""
|
don't have the 'ycm_' prefix."""
|
||||||
|
|
||||||
try:
|
vim_globals = vimsupport.GetReadOnlyVimGlobals()
|
||||||
# vim.vars is fairly new so it might not exist
|
|
||||||
vim_globals = vim.vars
|
|
||||||
except:
|
|
||||||
vim_globals = vim.eval( 'g:' )
|
|
||||||
|
|
||||||
server_conf = {}
|
server_conf = {}
|
||||||
for key, value in vim_globals.items():
|
for key, value in vim_globals.items():
|
||||||
if not key.startswith( YCM_VAR_PREFIX ):
|
if not key.startswith( YCM_VAR_PREFIX ):
|
||||||
@ -60,6 +56,15 @@ def BuildServerConf():
|
|||||||
return server_conf
|
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():
|
def CompletionStartColumn():
|
||||||
"""Returns the 0-based index where the completion string should start. So if
|
"""Returns the 0-based index where the completion string should start. So if
|
||||||
the user enters:
|
the user enters:
|
||||||
|
@ -1,26 +1,23 @@
|
|||||||
{
|
{
|
||||||
"filepath_completion_use_working_dir": 0,
|
"filepath_completion_use_working_dir": 0,
|
||||||
"min_num_of_chars_for_completion": 2,
|
"min_num_of_chars_for_completion": 2,
|
||||||
|
"min_num_identifier_candidate_chars": 0,
|
||||||
"semantic_triggers": {},
|
"semantic_triggers": {},
|
||||||
"collect_identifiers_from_comments_and_strings": 0,
|
|
||||||
"filetype_specific_completion_to_disable": {
|
"filetype_specific_completion_to_disable": {
|
||||||
"gitcommit": 1
|
"gitcommit": 1
|
||||||
},
|
},
|
||||||
|
"seed_identifiers_with_syntax": 0,
|
||||||
|
"collect_identifiers_from_comments_and_strings": 0,
|
||||||
"collect_identifiers_from_tags_files": 0,
|
"collect_identifiers_from_tags_files": 0,
|
||||||
"extra_conf_globlist": [],
|
"extra_conf_globlist": [],
|
||||||
"global_ycm_extra_conf": "",
|
"global_ycm_extra_conf": "",
|
||||||
"confirm_extra_conf": 1,
|
"confirm_extra_conf": 1,
|
||||||
"complete_in_comments": 0,
|
"complete_in_comments": 0,
|
||||||
"complete_in_strings": 1,
|
"complete_in_strings": 1,
|
||||||
"min_num_identifier_candidate_chars": 0,
|
|
||||||
"max_diagnostics_to_display": 30,
|
"max_diagnostics_to_display": 30,
|
||||||
"auto_stop_csharp_server": 1,
|
|
||||||
"seed_identifiers_with_syntax": 0,
|
|
||||||
"csharp_server_port": 2000,
|
|
||||||
"filetype_whitelist": {
|
"filetype_whitelist": {
|
||||||
"*": 1
|
"*": 1
|
||||||
},
|
},
|
||||||
"auto_start_csharp_server": 1,
|
|
||||||
"filetype_blacklist": {
|
"filetype_blacklist": {
|
||||||
"tagbar": 1,
|
"tagbar": 1,
|
||||||
"qf": 1,
|
"qf": 1,
|
||||||
@ -28,5 +25,10 @@
|
|||||||
"markdown": 1,
|
"markdown": 1,
|
||||||
"unite": 1,
|
"unite": 1,
|
||||||
"text": 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():
|
def LoadDefaults():
|
||||||
SetAll( _DefaultOptions() )
|
SetAll( DefaultOptions() )
|
||||||
|
|
||||||
|
|
||||||
def _DefaultOptions():
|
def DefaultOptions():
|
||||||
settings_path = os.path.join(
|
settings_path = os.path.join(
|
||||||
os.path.dirname( os.path.abspath( __file__ ) ),
|
os.path.dirname( os.path.abspath( __file__ ) ),
|
||||||
'server/default_settings.json' )
|
'server/default_settings.json' )
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
import vim
|
import vim
|
||||||
import os
|
import os
|
||||||
|
import json
|
||||||
|
|
||||||
def CurrentLineAndColumn():
|
def CurrentLineAndColumn():
|
||||||
"""Returns the 0-based current line and 0-based current column."""
|
"""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 ) ) ) )
|
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
|
# Both |line| and |column| need to be 1-based
|
||||||
def JumpToLocation( filename, line, column ):
|
def JumpToLocation( filename, line, column ):
|
||||||
# Add an entry to the jumplist
|
# Add an entry to the jumplist
|
||||||
|
Loading…
Reference in New Issue
Block a user