简体   繁体   English

VIM python文件类型特定的缩进在一个列表的50行之后失败

[英]VIM python filetype specific indent fails after 50 lines of one list

I'm currently working on reformatting a python project to follow the 4 spaces indent style. 我目前正在重新格式化python项目以遵循4个空格的缩进样式。 The project is being done in VIM with the following plugins: fugitive, snipmate, surround, git, supertab, minibufexpl, command-t. 该项目正在VIM中使用以下插件完成:逃犯,snipmate,round,git,supertab,minibufexpl,command-t。 pyflakes-pathogen, ack, gundo, pydoc, pep8, py.test, makegreen, tasklist, nerdtree, ropevim . pyflakes-pathogen,ack,gundo,pydoc,pep8,py.test,makegreen,tasklist,nerdtree,ropevim。

My .vimrc is currently: 我的.vimrc当前是:

set tabstop=4
set shiftwidth=4
set expandtab

let mapleader=","

filetype off

call pathogen#runtime_append_all_bundles()
call pathogen#helptags()


set foldmethod=indent
set foldlevel=99

map <leader>td <Plug>TaskList
map <leader>g :GundoToggle<CR>

syntax on
filetype on
filetype plugin indent on

let g:pyflakes_use_quickfix = 0

let g:pep8_map='<leader>8'

au FileType python set omnifunc=pythoncomplete#Complete
let g:SuperTabDefaultCompletionType = "context"

set completeopt=menuone,longest,preview

The project is not mine, and I would like to keep the code functionally untouched from the original. 该项目不是我的项目,我想使代码在功能上与原始版本保持一致。

The code consists of a few assignment operations. 该代码包含一些赋值操作。 The left side of each is the variable name, the right side is a very, very long list with multiple nested lists. 每个变量的左侧是变量名,右侧是一个非常长的列表,其中包含多个嵌套列表。

If I attempted to utilize VIM's re-indent functionality "gg=G" or even "100==" from the start of the asignment, VIM will properly indent the first fifty lines of the right side of the asignment. 如果我尝试使用VIM的重新缩进功能“ gg = G”甚至从开始就使用“ 100 ==”,VIM都会正确缩进该赋值右侧的前五十行。 However after the fiftieth line of the right side, VIM begins indenting the second level an additional four spaces. 但是,在右侧的第五十行之后,VIM开始向第二级缩进另外四个空格。

animations = [
        ["stand", 0, amf_client_prediction,
            #   [3.0, "myanim", 0, 50, arf_cyclic|arf_loop_pos_0_25],
            [3.0, "anim_human", 50, 52, arf_use_stand_progress|arf_cyclic, 0, (0, 0, 0), 0.25],
            [3.0, "anim_human", 60, 62, arf_use_stand_progress|arf_cyclic, 0, (0, 0, 0), 0.75],
            [3.0, "anim_human", 70, 72, arf_use_stand_progress|arf_cyclic, 0, (0, 0, 0), 0.25],
            [3.0, "anim_human", 80, 82, arf_use_stand_progress|arf_cyclic|arf_two_handed_blade, 0, (0, 0, 0), 0.5],
            ##   [35.0, "stand_woman", 0, 1059, arf_use_stand_progress|arf_cyclic|arf_two_handed_blade, 0, (0, 0, 0), 0.5],
            ##   [43.0, "stand_woman_public", 0, 1313, arf_use_stand_progress|arf_cyclic|arf_two_handed_blade, 0, (0, 0, 0), 0.5],
            #  [35.0, "tavern_stand", 0, 472, arf_cyclic|arf_loop_pos_0_25],
            ],
        ["stand_man", 0, amf_client_prediction,
            [11.0, "stand_man", 0, 315, arf_use_stand_progress|arf_cyclic, 0, (0, 0, 0), 0.25],
            ],
        ["stand_player_first_person", 0, amf_client_prediction,
            [3.5, "anim_human", 90, 100, arf_use_stand_progress|arf_cyclic, 0, (0, 0, 0), 0.25],
            [3.5, "anim_human", 110, 120, arf_use_stand_progress|arf_cyclic, 0, (0, 0, 0), 0.25],
            ],
        ["jump", acf_enforce_lowerbody, amf_priority_jump|amf_play|amf_client_prediction|amf_continue_to_next,
            ##   [1.09, "jump", 22, 48, arf_blend_in_1],
            [1.0, "jump", 22, 46, arf_blend_in_1],
            ##   [0.8, "anim_human", 270, 272, arf_blend_in_4],
            ],
        ["jump_loop", acf_enforce_lowerbody, amf_priority_jump|amf_play|amf_client_prediction,
            ##   [0.8, "jump_loop", 0, 30, arf_blend_in_2|arf_cyclic],
            [0.5, "jump_loop", 0, 14, arf_blend_in_3|arf_cyclic],
            ],
        ["jump_end", acf_enforce_lowerbody, amf_priority_jump_end|amf_play|amf_client_prediction,
            ##   [0.1, "jump", 48, 55, arf_blend_in_1],
            [0.3, "jump", 48, 55, arf_blend_in_2],
            ],
        ["jump_end_hard", acf_enforce_lowerbody, amf_priority_jump_end|amf_play|amf_client_prediction,
            ##   [0.8, "jump_end_hard", 29, 54, arf_blend_in_1],
            [0.6, "jump_end_hard", 36, 54, arf_blend_in_1],
            ],
        ["stand_unarmed", 0, amf_client_prediction,
            [8, "noweapon_cstance", 0, 100, arf_use_stand_progress|arf_cyclic, 0, (0, 0, 0), 0.25],
            ],
        ["stand_single", 0, amf_client_prediction,
            [9.0, "sword_loop01", 0, 200, arf_use_stand_progress|arf_cyclic, 0, (0, 0, 0), 0.25],
            ],
        ["stand_greatsword", 0, amf_client_prediction,
            [6.0, "greatsword_cstance", 0, 91, arf_use_stand_progress|arf_cyclic, 0, (0, 0, 0), 0.25],  
            ],
        ["stand_staff", 0, amf_client_prediction,
            [2.0, "staff_cstance", 0, 60, arf_use_stand_progress|arf_cyclic, 0, (0, 0, 0), 0.0],  
            ],
        ["stand_crossbow", 0, amf_client_prediction,
            [2.0, "staff_cstance", 0, 60, arf_use_stand_progress|arf_cyclic, 0, (0, 0, 0), 0.0],  
            ],
        ["turn_right", acf_enforce_lowerbody, amf_play|amf_client_prediction,
                [0.95, "stand_man", 0, 30, arf_use_stand_progress|arf_cyclic, 0, (0, 0, 0), 0.25], #TODO
                ],
        ["turn_left", acf_enforce_lowerbody, amf_play|amf_client_prediction,
                [0.95, "stand_man", 0, 30, arf_use_stand_progress|arf_cyclic, 0, (0, 0, 0), 0.25], #TODO
                ],
        ["turn_right_single", acf_enforce_lowerbody, amf_play|amf_client_prediction,
                [0.95, "turn_man_onehanded", 0, 23, arf_cyclic|blend_in_walk|arf_make_walk_sound,pack2f(0.4,0.9), (0, 0, 0), 0.0],
                ],
        ["turn_left_single", acf_enforce_lowerbody, amf_play|amf_client_prediction,
                [0.95, "turn_man_onehanded", 30, 53, arf_cyclic|blend_in_walk|arf_make_walk_sound,pack2f(0.4,0.9), (0, 0, 0), 0.0],
                ],
        ["turn_right_staff", acf_enforce_lowerbody, amf_play|amf_client_prediction,
                [0.95, "turn_man_staff", 0, 20, arf_cyclic|blend_in_walk|arf_make_walk_sound,pack2f(0.4,0.9), (0, 0, 0), 0.0],
                ],
        ["turn_left_staff", acf_enforce_lowerbody, amf_play|amf_client_prediction,
                [0.95, "turn_man_staff", 30, 50, arf_cyclic|blend_in_walk|arf_make_walk_sound,pack2f(0.4,0.9), (0, 0, 0), 0.0],
                ],
        ["turn_right_greatsword", acf_enforce_lowerbody, amf_play|amf_client_prediction,
                [0.95, "turn_man_greatsword", 0, 20, arf_cyclic|blend_in_walk|arf_make_walk_sound,pack2f(0.4,0.9), (0, 0, 0), 0.0],
                ],
        ["turn_left_greatsword", acf_enforce_lowerbody, amf_play|amf_client_prediction,
                [0.95, "turn_man_greatsword", 30, 50, arf_cyclic|blend_in_walk|arf_make_walk_sound,pack2f(0.4,0.9), (0, 0, 0), 0.0],
                ],
        ["prepare_kick_0", acf_enforce_lowerbody, amf_priority_kick|amf_play|amf_client_prediction|amf_continue_to_next,
                [0.05, "kick_rightleg", 10, 12, arf_blend_in_3],
                ],

Does VIM utilize some sort of a buffer that sets a maximum number of lines that will be tracked for indentations? VIM是否使用某种缓冲区来设置将针对缩进进行跟踪的最大行数? If so, is there any way to increase this buffer size? 如果可以,是否有任何方法可以增加此缓冲区的大小?

Otherwise, if this is simply a fault of the built-in indentation logic, do more robust third-party solutions exists that can provide indentation functionality for such a specific case? 否则,如果这仅仅是内置缩进逻辑的错误,是否存在可以为这种特定情况提供缩进功能的更强大的第三方解决方案?

If more information is necessary, I will update. 如果需要更多信息,我将进行更新。

hmmm in $VIMRUNTIME/indent/python.vim it looks like it scans back the past 50 lines to get context $ VIMRUNTIME / indent / python.vim中的hmmm看起来它回扫了过去的50行以获取上下文

let s:maxoff = 50        " maximum number of lines to look backwards for ()

you can see what VIM is using to indent by checking the indentexpr of the current buffer 您可以通过检查当前缓冲区的indentexpr来查看VIM用于缩进的内容

:set indentexpr?   

which returns, indentexpr=GetPythonIndent(v:lnum) 返回, indentexpr=GetPythonIndent(v:lnum)

and that filetype plugin indent on in your .vimrc is whats loading it when you load a python file 而在您的.vimrc中filetype plugin indent on是什么,当您加载python文件时会加载它

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM