如何为Vim的syntastic页脚添加powerline段? ( new powerline,而不是vim-powerline)Syntastic docs只说如何将它添加到标准的Vim页脚,我找不到如何在powerline docs中添加它。
答案 0 :(得分:6)
这些指令大多来自this pull request (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": {
文件: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": {
文件: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": {
文件: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": {
文件: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 = {
在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
完成所有这些更改后,您需要现在打开该细分。一种方法是编辑配置文件~/.config/powerline/themes/vim/default.json
在segments:
部分中,将以下内容放在右侧或左侧。
{
"name": "syntastic_segment",
"before": " "
},
在完成所有这些更改后,您现在应该能够看到电源线段上的合成错误输出。
故障排除:
vim --noplugin
启动vim,启动vim而不插入powerline就不会尝试解析文件。