在Sublime 3

时间:2017-03-18 21:53:53

标签: json r sublimetext3 sublime-text-plugin sublimelinter

我在Sublime 3通过lintrSublimeLinter 3插件使用SublimeLinter-contrib-lintr。在lintr README.md文件中有一个short mention,其中介绍了如何配置应使用的linters:

{
  "user": {
    "linters": {
      "r": {
        "linters": "with_defaults(line_length_linter(120))"
      }
    }
  }
}

但是,我正在将其与SublimeLinter-contrib-lintr结合使用,而我却无法使用它。我的SublimeLinter.sublime-settings文件如下所示:

{
    "user": {
        "debug": true,
        "delay": 0.25,
        "error_color": "D02000",
        "gutter_theme": "Packages/SublimeLinter/gutter-themes/Default/Default.gutter-theme",
        "gutter_theme_excludes": [],
        "lint_mode": "background",
        "linters": {
            "lintr": {
                "@disable": false,
                "args": [],
                "cache": "TRUE",
                "excludes": [],
                "linters": "default_linters"
            }
        },
        "mark_style": "outline",
        "no_column_highlights_line": false,
        "passive_warnings": false,
        "paths": {
            "linux": [],
            "osx": [],
            "windows": [
                "C:/Program Files/R/R-3.3.3/bin/x64"
            ]
        },
        "python_paths": {
            "linux": [],
            "osx": [],
            "windows": []
        },
        "rc_search_limit": 3,
        "shell_timeout": 10,
        "show_errors_on_save": false,
        "show_marks_in_minimap": true,
        "syntax_map": {
            "r extended": "r"
        },
        "warning_color": "DDB700",
        "wrap_find": true
    }
}

lintr包有一堆短语(参见this link)。我要实现的目标是丢弃其中一些(例如,不使用,例如,assignment_linter)。你知道如何实现这个目标吗?它应该是可能的,对吧?

修改1:

我注意到,将"linters": "default_linters"更改为"linters": "assignment_linter",只会选择assignment_linter下的错误。我尝试使用数组扩展它,但它不起作用:

...
"lintr": {
    "@disable": false,
    "args": [],
    "cache": "TRUE",
    "excludes": [],
    "linters": [
        "assignment_linter",
        "object_name_linter"
    ]
}
...

Sublime 3控制台内,此尝试的消息错误消息为:Error: unexpected '[' in "lint(cache = TRUE, commandArgs(TRUE), ["

编辑2:可能的解决方案

查看with_defaults包中的lintr,我发现了两种方法,只选择我感兴趣的短片。假设我只想要assignment_linterno_tab_linter,配置是:

  • "linters": "default_linters[c('assignment_linter', 'no_tab_linter')]"
  • "linters": "with_defaults(assignment_linter, no_tab_linter, default = NULL)"

它有效,但还有其他不那么容易出错的方法吗?有了这种方法,如果我只想丢弃一个linter,我必须列出所有其他的。

1 个答案:

答案 0 :(得分:1)

关于“ Edit 2”的问题,您可以按以下步骤丢弃单个短绒:

{
  "user": {
    "linters": {
      "r": {
        "linters": "with_defaults(some_default_linter = NULL)"
      }
    }
  }
}

...,其中some_default_linter是列表lintr::default_linters中短绒的名称。