配置SubLime Linter插件以使用Ruby 1.9语法

时间:2012-02-05 21:31:18

标签: ruby sublimetext

我想获得SubLime Linter插件(https://github.com/Kronuz/SublimeLinter)来识别Ruby 1.9语法。有没有人能够在SublimeText 2中使用它?

这是我当前的默认设置文件:

/*
    SublimeLinter default settings
*/
{
    /*
        Sets the mode in which SublimeLinter runs:

        true - Linting occurs in the background as you type (the default).
        false - Linting only occurs when you initiate it.
        "load-save" - Linting occurs only when a file is loaded and saved.
    */
    "sublimelinter": true,

    /*
        Maps linters to executables for non-built in linters. If the executable
        is not in the default system path, or on posix systems in /usr/local/bin
        or ~/bin, then you must specify the full path to the executable.
        Linter names should be lowercase.

        This is the effective default map; your mappings may override these.

        "sublimelinter_executable_map":
        {
            "perl": "perl",
            "php": "php",
            "ruby": "ruby"
        },
    */
    "sublimelinter_executable_map":
    {
    },

    /*
        Maps syntax names to linters. This allows variations on a syntax
        (for example "Python (Django)") to be linted. The key is
        the base filename of the .tmLanguage syntax files, and the value
        is the linter name (lowercase) the syntax maps to.
    */
    "sublimelinter_syntax_map":
    {
        "Python Django": "python"
    },

    // An array of linter names to disable. Names should be lowercase.
    "sublimelinter_disable":
    [
    ],

    /*
        The minimum delay in seconds (fractional seconds are okay) before
        a linter is run when the "sublimelinter" setting is true. This allows
        you to have background linting active, but defer the actual linting
        until you are idle. When this value is greater than the built in linting delay,
        errors are erased when the file is modified, since the assumption is
        you don't want to see errors while you type.
    */
    "sublimelinter_delay": 0,

    // If true, lines with errors or warnings will be filled in with the outline color.
    "sublimelinter_fill_outlines": false,

    // If true, lines with errors or warnings will have a gutter mark.
    "sublimelinter_gutter_marks": false,

    // If true, the find next/previous error commands will wrap.
    "sublimelinter_wrap_find": true,

    // If true, when the file is saved any errors will appear in a popup list
    "sublimelinter_popup_errors_on_save": false,

    // jshint: options for linting JavaScript. See http://jshint.com/#docs for more info.
    // By deault, eval is allowed.
    "jshint_options":
    {
        "evil": true,
        "regexdash": true,
        "browser": true,
        "wsh": true,
        "trailing": true,
        "sub": true,
        "strict": false
    },

    // A list of pep8 error numbers to ignore. By default "line too long" errors are ignored.
    // The list of error codes is in this file: https://github.com/jcrocholl/pep8/blob/master/pep8.py.
    // Search for "Ennn:", where nnn is a 3-digit number.
    "pep8_ignore":
    [
        "E501"
    ],

    /*
        If you use SublimeLinter for pyflakes checks, you can ignore some of the "undefined name xxx"
        errors (comes in handy if you work with post-processors, globals/builtins available only at runtime, etc.).
        You can control what names will be ignored with the user setting "pyflakes_ignore".

        Example:

        "pyflakes_ignore":
            [
                "some_custom_builtin_o_mine",
                "A_GLOBAL_CONSTANT"
            ],
    */
    "pyflakes_ignore":
    [
    ],

    /*
        Ordinarily pyflakes will issue a warning when 'from foo import *' is used,
        but it is ignored since the warning is not that helpful. If you want to see this warning,
        set this option to false.
    */
    "pyflakes_ignore_import_*": true,

    // Objective-J: if true, non-ascii characters are flagged as an error.
    "sublimelinter_objj_check_ascii": false
}

5 个答案:

答案 0 :(得分:41)

我能够使用我的ruby 1.9可执行文件的绝对路径来使用它。我正在使用rbenv,因此要获取我运行的路径rbenv which ruby,您可能需要输入/usr/local/bin/ruby/usr/local/bin/ruby19

这是我的sublimelinter默认设置的样子(如果您愿意,也可以将它放入项目特定的文件中)。

Preferences -> Package Settings -> SublimeLinter -> Settings - User

"sublimelinter_executable_map":
{
    "ruby": "~/.rbenv/versions/1.9.3-p0/bin/ruby"
},

答案 1 :(得分:19)

使用rvm时,您应该可以使用rvm-auto-ruby

这有一个问题,但我认为它现在已经解决了:https://github.com/SublimeLinter/SublimeLinter/issues/30

答案 2 :(得分:16)

所有,只是想插入,因为我也遇到了这个问题,以下内容适用于Ubuntu上的ST2 v 2.0.1,位于用户/ SublimeLinter.sublime-settings文件中,该文件位于

Preferences -> Package Settings -> SublimeLinter -> Settings - User

{
  "sublimelinter_executable_map": {
    "ruby": "~/.rvm/bin/rvm-auto-ruby"
  }
}

添加后,重新启动ST2,转到控制台并通过运行以下命令检查它是否已更新:

view.settings().get("sublimelinter_executable_map")

您应该获得以下输出:

{'ruby': u'~/.rvm/bin/rvm-auto-ruby'}

答案 3 :(得分:1)

我还能通过添加PATH和点ruby到rbenv shim到sublimelinter_executable_map来实现这一点(我认为这也是官方文档中的推荐方法。)这也使你能够切换ruby版本而不需要也更新配置。

{
  "sublimelinter_executable_map": {
    "path": "/usr/local/var/rbenv/shims:/Users/luke/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin",
    "ruby": "/usr/local/var/rbenv/shims/ruby"

  }
}

答案 4 :(得分:0)

在SublimeLinter 3中,rbenv(希望是rvm)支持开箱即用,没有额外的配置(除了确保它们在shell启动中的正确位置初始化)。