Shougo / deoplete.nvim

:stars: Dark powered asynchronous completion framework for neovim/Vim8
Other
5.94k stars 295 forks source link

[Bug] broken indention at 'elif' when editting python files #1206

Closed stkid closed 1 year ago

stkid commented 1 year ago

Warning: I will close the issue without the minimal init.vim and the reproduction instructions.

Problems summary

broken indention at 'elif' when editting python files

Expected

well indented

Environment Information

Provide a minimal init.vim/vimrc with less than 50 lines (Required!)

call plug#begin('~/.vim/plugged')
  Plug 'roxma/nvim-yarp'
  Plug 'roxma/vim-hug-neovim-rpc'
  Plug 'Shougo/deoplete.nvim'
call plug#end()

set equalprg=indent\ -linux\ -il0\ 2>/dev/null
let g:deoplete#enable_at_startup = 1

How to reproduce the problem from neovim/Vim startup (Required!)

  1. edit a python source file
  2. type in a 'if ... elif ...' snippet
  3. observe the odd indention at keyword 'elif'

Generate a logfile if appropriate

  1. export NVIM_PYTHON_LOG_FILE=/tmp/log
  2. export NVIM_PYTHON_LOG_LEVEL=DEBUG
  3. nvim -u minimal.vimrc
  4. some works
  5. cat /tmp/log_{PID}

Screenshot (if possible)

Peek 2023-08-05 15-05

Upload the log file

NA

I have figured out the cause is in the function deoplete#util#indent_current_line():

function! deoplete#util#indent_current_line() abort
  let pos = getpos('.')
  let len = len(getline('.'))
  let equalprg = &l:equalprg
  try
    setlocal equalprg=
    silent normal! ==
  finally
    let &l:equalprg = equalprg
    let pos[2] += len(getline('.')) - len
    call setpos('.', pos)
  endtry
endfunction

The 'equalprg' still affects though it is setted to null locally in fact, please confirm whether this is the original intention.

Thanks

Shougo commented 1 year ago

I don't know the original intention. But it should not. I have removed it.