ycm-core / YouCompleteMe

A code-completion engine for Vim
http://ycm-core.github.io/YouCompleteMe/
GNU General Public License v3.0
25.45k stars 2.81k forks source link

YCM overrides .vimrc for .py files #3560

Closed suuuehgi closed 4 years ago

suuuehgi commented 4 years ago

Issue Prelude

Issue Details

Provide a clear description of the problem, including the following key questions:

Add command to last line of .vimrc:

$ tail -1 ~/.vimrc
set shiftwidth=2

Include steps to reproduce here. Include description of a minimal test case, including any actual code required to reproduce the issue.

vim test    -c "set t_te=" -c "echo shiftwidth()" -c quit
"test" [New File]
2
vim test.py -c "set t_te=" -c "echo shiftwidth()" -c quit
"test.py" [New File]
4

Obey the .vimrc.

See above.

Diagnostic data

Output of vim --version

vim --version
VIM - Vi IMproved 8.1 (2018 May 18, compiled Nov  7 2019 22:30:47)
Included patches: 1-2268
Compiled by Arch Linux
Huge version without GUI.  Features included (+) or not (-):
+acl               -farsi             -mouse_sysmouse    -tag_any_white
+arabic            +file_in_path      +mouse_urxvt       +tcl/dyn
+autocmd           +find_in_path      +mouse_xterm       +termguicolors
+autochdir         +float             +multi_byte        +terminal
-autoservername    +folding           +multi_lang        +terminfo
-balloon_eval      -footer            -mzscheme          +termresponse
+balloon_eval_term +fork()            +netbeans_intg     +textobjects
-browse            +gettext           +num64             +textprop
++builtin_terms    -hangul_input      +packages          +timers
+byte_offset       +iconv             +path_extra        +title
+channel           +insert_expand     +perl/dyn          -toolbar
+cindent           +job               +persistent_undo   +user_commands
-clientserver      +jumplist          +postscript        +vartabs
-clipboard         +keymap            +printer           +vertsplit
+cmdline_compl     +lambda            +profile           +virtualedit
+cmdline_hist      +langmap           +python/dyn        +visual
+cmdline_info      +libcall           +python3/dyn       +visualextra
+comments          +linebreak         +quickfix          +viminfo
+conceal           +lispindent        +reltime           +vreplace
+cryptv            +listcmds          +rightleft         +wildignore
+cscope            +localmap          +ruby/dyn          +wildmenu
+cursorbind        +lua/dyn           +scrollbind        +windows
+cursorshape       +menu              +signs             +writebackup
+dialog_con        +mksession         +smartindent       -X11
+diff              +modify_fname      -sound             -xfontset
+digraphs          +mouse             +spell             -xim
-dnd               -mouseshape        +startuptime       -xpm
-ebcdic            +mouse_dec         +statusline        -xsmp
+emacs_tags        +mouse_gpm         -sun_workshop      -xterm_clipboard
+eval              -mouse_jsbterm     +syntax            -xterm_save
+ex_extra          +mouse_netterm     +tag_binary        
+extra_search      +mouse_sgr         -tag_old_static    
   system vimrc file: "/etc/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H   -D_FORTIFY_SOURCE=2  -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       
Linking: gcc   -L. -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -fstack-protector-strong -rdynamic -Wl,-export-dynamic -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.30/core_perl/CORE  -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -L/usr/local/lib -Wl,--as-needed -o vim        -lm -ltinfo -lelf -lnsl    -lacl -lattr -lgpm -ldl   -Wl,-E -Wl,-rpath,/usr/lib/perl5/5.30/core_perl/CORE -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -fstack-protector-strong -L/usr/local/lib  -L/usr/lib/perl5/5.30/core_perl/CORE -lperl -lpthread -ldl -lm -lcrypt -lutil -lc   -L/usr/lib -ltclstub8.6 -ldl -lz -lpthread -lm

Output of YcmDebugInfo

Printing YouCompleteMe debug information...
-- Client logfile: /tmp/ycm_y5v233ws.log
-- Server Python interpreter: /usr/bin/python3
-- Server Python version: 3.8.0
-- Server has Clang support compiled in: True
-- Clang version: clang version 9.0.0 (/home/vagrant/llvm/llvm-9.0.0.src/tools/clang 038587147cf2f97d1c3e677042f69560c65b5bea)
-- No extra configuration file found
-- Server running at: http://127.0.0.1:45071
-- Server process ID: 420433
-- Server logfiles:
--   /tmp/ycmd_45071_stdout_8_zxaub_.log
--   /tmp/ycmd_45071_stderr_35lz6aue.log

Contents of YCM, ycmd and completion engine logfiles

ycmd_55431_stdout_b6p_z322.log

serving on http://localhost:55431

ycmd_55431_stderr_78ma0l7h.log

2019-12-18 16:13:34,168 - DEBUG - No global extra conf, not calling method YcmCorePreload
2019-12-18 16:13:34,274 - INFO - Received ready request
2019-12-18 16:13:37,222 - INFO - Received debug info request
2019-12-18 16:13:37,223 - ERROR - Error retrieving completer debug info
Traceback (most recent call last):
  File "/home/username/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/handlers.py", line 287, in DebugInfo
    response[ 'completer' ] = _GetCompleterForRequestData(
  File "/home/username/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/handlers.py", line 354, in _GetCompleterForRequestData
    return _server_state.GetFiletypeCompleter( request_data[ 'filetypes' ] )
  File "/home/username/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/server_state.py", line 99, in GetFiletypeCompleter
    raise ValueError( 'No semantic completer exists for filetypes: {0}'.format(
ValueError: No semantic completer exists for filetypes: ['']

ycm_2ig4y8h8.log

2019-12-18 16:17:03,544 - DEBUG - GET b'http://127.0.0.1:35503/ready'
{'content-type': 'application/json', 'x-ycm-hmac': b'azztA8Lzrbgb4tqP1OXNXbLSOujjdbwZM9ekLvyBmSg='}
2019-12-18 16:17:03,580 - ERROR - HTTPConnectionPool(host='127.0.0.1', port=35503): Max retries exceeded with url: /ready (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f284df8fa90>: Failed to establish a new connection: [Errno 111] Connection refused'))
2019-12-18 16:17:03,681 - DEBUG - GET b'http://127.0.0.1:35503/ready'
{'content-type': 'application/json', 'x-ycm-hmac': b'azztA8Lzrbgb4tqP1OXNXbLSOujjdbwZM9ekLvyBmSg='}
2019-12-18 16:17:03,689 - DEBUG - RX: True
2019-12-18 16:17:06,525 - DEBUG - POST b'http://127.0.0.1:35503/debug_info'
{'content-type': 'application/json', 'x-ycm-hmac': b'kMZICt5c4rpLzpD9hgpGK12kC2Xt+RW7Rc8ugl/ofc4='}
b'{"filepath": "/home/username/1", "line_num": 1, "column_num": 1, "working_dir": "/home/username", "file_data": {"/home/username/1": {"contents": "\\n", "filetypes": [""]}}}'
2019-12-18 16:17:06,535 - DEBUG - RX: {'python': {'executable': '/usr/bin/python3', 'version': '3.8.0'}, 'clang': {'has_support': True, 'version': 'clang version 9.0.0 (/home/vagrant/llvm/llvm-9.0.0.src/tools/clang 038587147cf2f97d1c3e677042f69560c65b5bea)'}, 'extra_conf': {'path': None, 'is_loaded': False}, 'completer': None}

OS version, distribution, etc.

Linux hostname 5.4.3-arch1-1 #1 SMP PREEMPT Fri, 13 Dec 2019 09:39:02 +0000 x86_64 GNU/Linux

bstaletic commented 4 years ago

YCM doesn't touch your shiftwidth. Check the output of :verbose set sw to see from where did it get set.

suuuehgi commented 4 years ago

Thanks a lot - It was a pain for months! I didn't know that command.

:verbose set sw
  shiftwidth=4
        Last set from /usr/share/vim/vim81/ftplugin/python.vim line 118

So, for anyone else stumbling about this, it's hardcoded in:

/usr/share/vim/vim81/ftplugin/python.vim line:118

if !exists("g:python_recommended_style") || g:python_recommended_style != 0
    " As suggested by PEP8.
    setlocal expandtab shiftwidth=4 softtabstop=4 tabstop=8
endif

Solution: Add let g:python_recommended_style = 0 to the .vimrc.