添加天气小部件电力线

时间:2014-01-30 12:14:58

标签: vim macvim vim-powerline

我正在尝试为powerline启用天气小部件,但没有成功。我添加了这段代码

{
    "name": "weather",
    "priority": 50,
    "args": {
        "unit": "F",
        "location_query": "oslo, norway"
    }
}

在我的主题文件的末尾。当我启动MacVim时出现错误

Error detected while processing VimEnter Auto commands for "*":
2014-01-30 14:13:11,122:ERROR:vim:segment_generator:Failed to generate segment from {u'priority': 50, u'args': {u'location_query': u'oslo, norway', u'u
nit': u'F'}, u'name': u'weather'}: 'module' object has no attribute 'weather'

我已阅读powerline文档,但我仍然感到困惑。任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:2)

以下是我为壳牌配置天气的方法。我不认为VI是可能的,因为它没有列在可用的段

https://powerline.readthedocs.org/en/latest/configuration/segments/vim.html

创建以下文件夹树:

    ~/.config/powerline/config.json
    ~/.config/powerline/themes/shell/netsamir.json
    ~/.config/powerline/colorschemes/shell/netsamir.json

<强>〜/的.config /电力线/ config.json

{
    "common": {
        "term_truecolor": false
    },
    "ext": {
      "shell": {
            "theme": "netsamir",
            "colorscheme": "netsamir"
        },            
    }
}

<强>〜/的.config /电力线/主题/壳/ netsamir.json

{
    "segments": {
        "above": [
            {
                "left": [
                   {
                        "function":  "powerline.segments.common.wthr.weather",
                        "args": {
                            "unit": "C"
                       }
                    },
                    {
                        "name": "user",
                        "function": "powerline.segments.common.env.user",
                        "priority": 30
                    },
                    {
                        "function": "powerline.segments.common.vcs.branch",
                        "args": {
                            "status_colors": true,
                            "ignore_statuses": ["U"]
                         }
                    },
                    {
                        "name": "cwd",
                        "function": "powerline.segments.common.env.cwd"
                    }
                ]
            }
         ],
        "left": [
            {
                "type": "string",
                "contents": ">",
                "highlight_groups": ["promptline"],
                "draw_soft_divider": false
            },
            {
                "type": "string",
                "contents": "",
                 "highlight_groups": ["blank"],
                "draw_hard_divider": false
            }
        ]
    }
}

<强>〜/的.config /电力线/ colorschemes /壳/ netsamir.json

{
    "name": "netsamir",
    "groups": {
        "information:additional":    { "fg": "gray9", "bg": "gray4", "attrs": [] },
        "information:regular":       { "fg": "gray10", "bg": "gray4", "attrs": [] },
        "information:highlighted":   { "fg": "white", "bg": "gray4", "attrs": ["bold"] },
        "information:priority":      { "fg": "brightyellow", "bg": "mediumorange", "attrs": [] },
        "hostname":                  { "fg": "black", "bg": "gray10", "attrs": ["bold"] },
        "background:divider":        "information:additional",
        "weather":                   { "fg": "gray9", "bg": "gray2", "attrs": [] },
        "user":                      { "fg": "brightcyan", "bg": "darkestblue", "attrs": ["bold"] },
        "branch":                    { "fg": "gray9", "bg": "gray2", "attrs": [] },
        "branch_dirty":              { "fg": "black", "bg": "orangered", "attrs": [] },
        "branch_clean":              { "fg": "gray9", "bg": "gray2", "attrs": [] },
        "branch:divider":            { "fg": "gray7", "bg": "gray2", "attrs": [] },
        "cwd":                       "information:additional",
        "cwd:current_folder":        "information:highlighted",
        "cwd:divider":               { "fg": "gray7", "bg": "gray4", "attrs": [] },
        "promptline": { "fg": "white", "bg": "darkestblue", "attrs": ["bold"] },
        "blank": { "fg": "black", "bg": "black", "attrs": [] }
    }
}