Mik*_*unk 4 vim vim-powerline syntastic
如何为Vim 的电力线页脚添加一个合成段?(新的 powerline,而不是vim-powerline)Syntastic docs只说如何将它添加到标准的Vim页脚,我找不到如何将它添加到powerline文档中.
这些指令中的大多数来自电力线的拉动请求(451).
此拉取请求会向电力线添加语法段.由于该段未合并到主电力线树中,因此您需要手动预先形成补丁.值得庆幸的是,您只需要修改三个文件.(+表示添加行/ - 表示删除行).查看彩色差异的拉取请求.
档案:( powerline/config_files/colorschemes/vim/default.json第28行)
"line_current_symbol": { "fg": "gray1", "bg": "gray10" },
"virtcol_current_gradient": { "fg": "dark_GREEN_Orange_red", "bg": "gray10" },
"col_current": { "fg": "gray6", "bg": "gray10" },
- "modified_buffers": { "fg": "brightyellow", "bg": "gray2" }
+ "modified_buffers": { "fg": "brightyellow", "bg": "gray2" },
+ "syntastic_segment": { "fg": "brightestred", "bg": "gray2", "attr": ["bold"] }
},
"mode_translations": {
"nc": {
Run Code Online (Sandbox Code Playgroud)
档案:( powerline/config_files/colorschemes/vim/default.json第68行)
"groups": {
"mode": { "fg": "darkestcyan", "bg": "white", "attr": ["bold"] },
"background:divider": { "fg": "darkcyan", "bg": "darkestblue" },
- "branch:divider": { "fg": "darkcyan", "bg": "darkblue" }
+ "branch:divider": { "fg": "darkcyan", "bg": "darkblue" },
+ "syntastic_segment": { "fg": "white", "bg": "darkestblue", "attr": ["bold"] }
}
},
"v": {
Run Code Online (Sandbox Code Playgroud)
文件:powerline/config_files/colorschemes/vim/solarized.json(第27行)
"line_current": { "fg": "gray13", "bg": "lightyellow", "attr": ["bold"] },
"line_current_symbol": { "fg": "gray13", "bg": "lightyellow" },
"virtcol_current_gradient": { "fg": "GREEN_Orange_red", "bg": "gray10" },
- "col_current": { "fg": "azure4", "bg": "lightyellow" }
+ "col_current": { "fg": "azure4", "bg": "lightyellow" },
+ "syntastic_segment": { "fg": "red", "bg": "royalblue5", "attr": ["bold"] }
},
"mode_translations": {
"nc": {
Run Code Online (Sandbox Code Playgroud)
文件:powerline/config_files/colorschemes/vim/solarized.json(第65行)
"line_percent_gradient": { "fg": "oldlace", "bg": "gray61" },
"line_current": { "fg": "gray13", "bg": "oldlace", "attr": ["bold"] },
"line_current_symbol": { "fg": "gray13", "bg": "oldlace" },
- "col_current": { "fg": "azure4", "bg": "oldlace" }
+ "col_current": { "fg": "azure4", "bg": "oldlace" },
+ "syntastic_segment": { "fg": "lightyellow", "bg": "darkgreencopper", "attr": ["bold"] }
}
},
"v": {
Run Code Online (Sandbox Code Playgroud)
档案:( powerline/segments/vim.py第23行)
'expand': vim_get_func('expand', rettype=str),
'bufnr': vim_get_func('bufnr', rettype=int),
'line2byte': vim_get_func('line2byte', rettype=int),
+ 'exists': vim_get_func('exists', rettype=int),
}
vim_modes = {
Run Code Online (Sandbox Code Playgroud)
最后powerline/segments/vim.py添加以下功能.(确保使用制表符缩进该函数.您正在修改python文件缩进事项)
@window_cached
def syntastic_segment(pl):
'''Return the syntastic statusline flag
'''
if int(vim_funcs['exists']('*SyntasticStatuslineFlag')) > 0:
syntastic_flag_func = vim_get_func('SyntasticStatuslineFlag', rettype=str)
return [{
'contents': str(syntastic_flag_func()),
}]
else:
return None
Run Code Online (Sandbox Code Playgroud)
完成所有这些更改后,您需要现在打开该段.一种方法是编辑配置文件~/.config/powerline/themes/vim/default.json
在该部分中segments:,将以下部分放在右侧或左侧部分中.
{
"name": "syntastic_segment",
"before": " "
},
Run Code Online (Sandbox Code Playgroud)
完成所有这些更改后,您现在应该可以在电源线段上看到合成错误输出.
故障排除:
vim --noplugin来启动vim而没有插件到powerline不会尝试解析文件.