Code Monkey home page Code Monkey logo

sublimelinter's Introduction

SublimeLinter

tests

The code linting framework for Sublime Text. No linters included: get them via Package Control.

Installation

Note

The current stable version of Sublime Text, Build 4169, has a bug and cannot install SublimeLinter without requiring a restart. You're fine if you have a later dev build, e.g. build 4173.

Note

We're in a transition phase to the newer ST4 plugin host. Unless we have more experience for the process, it may be necessary to restart Sublime Text after installing or upgrading helper packages. Just check if everything works or if the console shows permanent errors. On my machine, no restarts were necessary.

Probably don't get fancy and just install SublimeLinter via Package Control. Refer https://www.sublimelinter.com/en/latest/installation.html for further information, but, spoiler!, usually you install SublimeLinter, the plugin you're currently looking at, some command line tools, these are the actual linters (e.g. eslint or flake8), and then some plugins/adapters between both. These are typically named after the linter and should be installed via Package Control as well, examples would be SublimeLinter-eslint or SublimeLinter-flake8.

By default, SublimeLinter will run in the background and most linters support this mode so you should get squiggles immediately.

Note that you find all commands we're installing using the Command Palette (ctrl+shift+p). Just search for SublimeLinter. You may find https://github.com/kaste/SublimeLinter-addon-toggler and/or https://github.com/kaste/SublimeLinter-addon-goto-flash useful.

Settings

Settings are documented in the default settings. Open the settings using the Command Palette (ctrl+shift+p) searching for Preferences: SublimeLinter Settings (mnemonic: sls).

When you open the SublimeLinter settings you'll see the defaults on the left or top. Usually that's all that is needed for end-users but some additional information is in our docs at sublimelinter.com.

Key Bindings

SublimeLinter comes with some pre-defined keyboard shortcuts. You can customize these via the Package Settings menu.

Command Linux & Windows MacOS
Lint this view Ctrl + k, l Ctrl + + l
Open diagnostics panel Ctrl + k, a Ctrl + + a
Goto next error Ctrl + k, n Ctrl + + e
Goto prev error Ctrl + k, p Ctrl + + Shift + e

Take also a look at the default bindings because we document other commands and have usually some tricks in there too.

For example, it is very advisable to bind sublime_linter_quick_actions, e.g.

    // To trigger a quick action
    // { "keys": ["ctrl+k", "ctrl+f"],
    //   "command": "sublime_linter_quick_actions"
    // },

Quick Actions/Fixers

As we do just linting SublimeLinter naturally does not come with fixers and/or code formatters. However, we have a fixer API, see the Command Palette: SublimeLinter: Quick Action, and ship (mostly) "fix by ignoring" actions. These allow you to quickly ignore specific error messages inline and ad hoc.[1]

SublimeLinter currently ships actions for eslint, stylelint, flake8, mypy, shellcheck, codespell and phpcs.

Want to see actions for your favourite linter? Please open a PR with your addition to quick_fix.py. We have tests for them!

[1] Why this limitation though? Well it is usually easy to add a semicolon here and a space there, but the inline ignore rules and syntaxes are very cumbersome to type and to remember. And there is basically no project of any size where you don't have to ignore ad-hoc something somewhere once.

Support & Bugs

Yeah, totally! Often if it doesn't work, Sublime will have something in the console (View -> Show Console). Warnings will go there by default.

You can enable debug mode in the settings to get much more information about what's going on. Especially seeing the exact command and working dir SublimeLinter will use should be noted and helpful.

As some code only runs on startup, it is good practice to restart Sublime Text and to examine the console output for anything odd.

If your issue is specific to a particular linter, please report it on that linter's repository, otherwise open it right here.

Hack on it

Sure, you're welcome! Just clone the repository into your Packages folder (Preferences -> Browse Packages).

> git clone https://github.com/SublimeLinter/SublimeLinter.git
> subl SublimeLinter

This will overrule the installed package straight away. Just delete the folder to reverse the process. The dev requirements can be read in the pyproject.toml file. Just use rye and install them:

> rye sync

Creating a linter plugin

Use the template to get started on your plugin. It contains a how-to with all the information you need. Refer to https://www.sublimelinter.com/en/master/linter_plugin.html for more detailed information. Of course, take a look at a similar linter plugin and let it inspire you.

Also Support ❤️

SublimeLinter is the kind of software that needs active maintenance all the time. If you find SublimeLinter helpful and would like to show your appreciation, you can support its development by buying me a coffee! 😄☕ https://paypal.me/herrkaste

😏

sublimelinter's People

Contributors

andrewdeandrade avatar andrewmast avatar aparajita avatar aruru99 avatar braver avatar brocoli avatar cixtor avatar dnicolson avatar fgimian avatar fichtefoll avatar gerardroche avatar grotewold avatar groteworld avatar iryusa avatar jawshooah avatar jtheletter avatar kaste avatar klonuo avatar lunixbochs avatar mataha avatar mheinzler avatar mokkabonna avatar nvtkaszpir avatar pykong avatar smanolloff avatar swdunlop avatar thekevjames avatar titobouzout avatar willrowe avatar yanokwa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sublimelinter's Issues

Cannot find the gutter theme

After installing a latest version error message will pop up
SublimeLinter: cannot find the gutter theme "Default", and the default is also not available. No gutter marks will display.

And I can't switch the gutter theme with the command+shift+P menu

When i change gutter theme to Blackberry with the User Settings
pop up message shows again.

syntax mapping not working

hi there,

I'm trying to get the sytntay mapping to work to lint jsx files with a js linter but it is not working.

These are my settings:

    "syntax_map": {
        "jsx": "js"
    },

The syntax definition I'm targeting is this one https://github.com/fabiantheblind/Sublime-ExtendScript

I also tried

    "syntax_map": {
        "ExtendScript": "JavaScript"
    },

or

    "syntax_map": {
        "extendscript": "javascript"
    },

with the jsl and the jshint linter.

Any suggestions how I can get this working?
Cheers
Fabian

Sublime Text 3 hanging on plugin loading

After upgrading from the sublime-text-3 branch of the old SublimeLinter repo to the latest version of this plugin (commit 4634adf), my Sublime Text 3 (build 3058), on a Linux Mint, started hanging on startup consistently.

After some digging in the code, I isolated to problem to this code in the lint/util.py file:

def extract_path(cmd, delim=':'):
    """Return the user's PATH as a colon-delimited list."""
    path = popen(cmd, os.environ).communicate()[0].decode()
    return ':'.join(path.strip().split(delim))

which is called like this:

shell_path = env['SHELL']
shell = os.path.basename(shell_path)
if shell in ('bash', 'zsh', 'ksh', 'sh'):
    return extract_path((shell_path, '-l', '-c', 'echo $PATH'))

This results in a call equivalent to this:

proc = subprocess.Popen(['/bin/bash', '-l', '-c', 'echo $PATH'], stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=os.environ, startupinfo=None)
proc.communicate()

which I have verified on the python interpreter that it hangs on the call to communicate.

I don't understand why is this blocking, I only know that adding shell=True to the Popen call prevents it from blocking, at least, but returns an empty string, and so is not the right fix or at least not the only fix required.

My "solution" for now was to remove the whole block of code in the get_shell_path function which uses extract_path to find the $PATH, since the rest of the code works for me.

If you need more info, I'll be happy to provide.

Preview the line of the error

ST3 provides an on_highlighted callback for quick panels (API), it would be great if it was used to preview the error when "hovering" it.

SublimeLinter3 doesn't show up in PackageManager and related problems (OS X + ST3)

In ST3, doing "Install Packages" doesn't show SublimeLinter3. It just shows SublimeLinter. This points to the old plugin repo.

I therefore manually added the SL3 github repo to the package manager and installed it that way. However, this caused a SublimeLinter3 folder to be created in the Packages folder, causing all plugins to break because they want it to be named just SublimeLinter.

Renaming the folder did not fix the problem perfectly. It created duplicate entries in the command list and caused various other problems.

Ultimately I had to create a symlink to point SublimeLinter3 to the SublimeLinter folder in Packages.

PHP Linter based on php binary built-in linter

I have been having issues with PHPLint throwing up far too many warnings to be useful, so I made a linter that uses the php binary built-in linter.

It's a pity I can't seem to get it to display notices and warnings, but it allows me to pick up any silly syntax errors.

I don't know if you want to take ownership of the repo? It's available here

TypeError: 'NoneType' object is not iterable

I am using ST3 and the jshint plugin.

this is my conf:

{
    "user": {
        "debug": true,
        "delay": 0.25,
        "error_color": "D02000",
        "gutter_theme": "Packages/SublimeLinter/gutter-themes/Default.gutter-theme",
        "gutter_theme_excludes": [],
        "lint_mode": "background",
        "linters": {
            "jshint": {
                "@disable": false,
                "args": [],
                "excludes": []
            }
        },
        "mark_style": "outline",
        "no_column_highlights_line": false,
        "paths": {
            "linux": [],
            "osx": [],
            "windows": []
        },
        "python_paths": {
            "linux": [],
            "osx": [],
            "windows": []
        },
        "rc_search_limit": 3,
        "show_errors_on_save": true,
        "show_marks_in_minimap": true,
        "syntax_map": {
            "php": "html"
        },
        "warning_color": "DDB700",
        "wrap_find": true
    }
}
Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 440, in is_enabled_
    ret = self.is_enabled()
  File "/Users/kilian/Library/Application Support/Sublime Text 3/Packages/SublimeLinter/commands.py", line 82, in is_enabled
    for lint in linters:
TypeError: 'NoneType' object is not iterable

Search for files in PATH, *without* their extension, that match the linter's cmd

An issue I had with SublimeLinter-jshint, cross-posted here in case this is a SublimeLinter3 issue:

On windows (x64) node.js installs jshint as jshint.cmd not jshint which causes SublimeLinter to be unable to find the executable and therefore disable the linter.

The solution (for me) was to change:
cmd = 'jshint --verbose -'
to
cmd = 'jshint.cmd --verbose -'
in linter.py in the package folder

This may be more of an issue with SublimeLinter itself (should it do 'typical' windows search for the file, without extension, and call any *.exe *.bat *.cmd or other executable extension that exists ?)

No linter for lua

I work on lua,and sublimelinter2 has the linter for lua.hope 3 got it.

Linters left to convert

Following is a list of existing linters that need to be converted to SublimeLinter 3. There are two possible sources for existing code: SublimeLinter 1.7 and sublimelint. You should probably look at both and use whatever is useful.

Important: Remember, in SublimeLinter 3, linters are named after the linter binary, not after the language they lint, because there may be several linters for the same language.

If you wish to have the linter plugin included in the SublimeLinter organisation on github, please be sure to follow the coding guidelines.

If you are interested in working on any of these, please leave a comment. And please be aware that if you write it, you will also be expected to maintain and support it, even if it ends up in the SublimeLinter org.

  • applescript
  • c
  • c++ (cppcheck and cpplint)
  • capp_lint (objective-j)
  • eclim
  • go
  • git commit message
  • haml
  • haskell
  • html
  • iced (coffeescript)
  • java
  • lua
  • nasm
  • perl
  • puppet
  • pylint
  • rubocop (ruby)
  • todo
  • xml
  • yaml

Linting for every keystroke?

I'm using sshfs for editing files. SublimeLinter2 worked perfectly for me with sshfs.
In SublimeLinter3 typing is a little slow. For every keystroke it is connecting the remote server.

I've set lint_mode to background and delay on 2 seconds. This problem occurs with sublimelinter-php and sublimelinter-css. I currently don't have any other plugins installed.
Typing is slow from the first keystroke; not just after 2 seconds.

Does the delay perhaps only postpone displaying the error? I think it should postpone the linting-request. It doesn't seem to be like that, right now.

Donate Bitcoin

For an open source project, how about an open source currency?

You can use coinbase, and convert back into cold, hard cash.

Issue with linters that return variable results

This came up building the linter plugin for recess - recess returns output in different formats for errors:

Parse error: .box-shadow is undefined on line 91

and warnings:

demo.less:1:Universal selectors should be avoided

A regex something like this would match:

regex = r'(?:(^.+?:(?P<line>\d+|undefined):(?P<message>.*))|((?P<error>.*?)line (?P<line>\d+)))$'

but won't actually work, because you can't have multiple capture groups with the same name. So you can either rename the second group and have SublimeLinter ignore it, or call it and get a regex compile error from python.

Is the correct fix for this to change the regex to something like ^(?P<message>.*)$ and do all custom parsing inside and overridden split_match()?

Or is there a better way?

Package Control availablity?

It seems that this and the subsequent plugins have yet to be published to Package Control. Do you know when this will happen?

SublimeLinter3 Not running

I'm lost here, no idea what is wrong. I installed via Package Control and it is not running a linter in my JS files. My ST2 installation is working fine.

Installed via Package Control, SublimeLinter3, doesn't appear to run at all. Default settings.

ST3
OSX 10.9.1

SubimeLinter3 tasks

  • error types (warning/error)
  • lint modes (background, load-save, etc.)
  • highlight styles
  • highlight style chooser
  • gutter mark themes
  • gutter mark theme chooser
  • next/previous error commands
  • command to insert SublimeLinter3 styles into current color scheme
  • show all errors command
  • show_errors_on_save setting
  • disable linter setting
  • per-project settings
  • syntax_map setting
  • inline settings
  • user-configurable delay
  • command to create linter plugin with documentation
  • full online documentation

SyntaxError: invalid syntax on installation

After trying to install the plugin, I'm getting the following error in the console:

reloading plugin SublimeLinter.SublimeLinter
Traceback (most recent call last):
  File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 73, in reload_plugin
    m = importlib.import_module(modulename)
  File "X/importlib/__init__.py", line 88, in import_module
  File "<frozen importlib._bootstrap>", line 1577, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1558, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1525, in _find_and_load_unlocked
  File "/Applications/Sublime Text.app/Contents/MacOS/sublime_plugin.py", line 671, in load_module
    exec(compile(source, source_path, 'exec'), mod.__dict__)
  File "SublimeLinter in /Users/chrisgunther/Library/Application Support/Sublime Text 3/Installed Packages/SublimeLinter.sublime-package", line 393
    print 'SublimeLinter: {0} {1} ({2})'.format(language, 'enabled' if enabled else 'disabled', message)
                                       ^
SyntaxError: invalid syntax

The package control message does successfully show after installation, but this is in the console.

I'm running Sublime Text 3 Build 3047 on OS X 10.9.1.

Thanks for the package!

Syntax and/or file specific linter settings

Hi, would it be possible to add syntax and/or file specific override settings for linters? So that in global settings for jshint I can have an option for indent: 4. But for within html file indent can be set to something else. I'm not sure if it is supported or not yet. Thank you.

Strange JS linting

var id = 123;

id
  ? true
  : false;

Error: Missing space after id.

But this code:

var _id = 123;

_id
  ? true
  : false;

Has no errors!

Display checkbox for menu items

I'm referring to the rightclick context menu and Tools > Sublime Linter (notably mark style and lint mode). There is an is_checked interface for commands that can be implemented and used to check which setting is currently selected. Should also get the same parameters as the run method.

https://www.sublimetext.com/docs/3/api_reference.html#sublime_plugin.ApplicationCommand
For some reason it doesn't list that this method is available for the other command types too, but I checked in sublime_plugin.py that it is.

Creation of Packages/User/SublimeLinter.sublime-settings

Same setup as in #18

The various ways to open the user setting file will say:
Unable to open /home/USER/.config/sublime-text-3/Packages/User/SublimeLinter.sublime-settings and open an empty file.

One way to correctly create the settings file is to use "Choose gutter Theme" and choose any option.

Is there a more obvious way ?

Linter bug

There seems to be a bug somewhere in the persist module or in commands. I'm not too sure what can reproduce it but here's the output in the console:

Traceback (most recent call last):
  File "C:\Program Files\Sublime Text 3\sublime_plugin.py", line 442, in is_enabled_
    ret = self.is_enabled()
  File "C:\Users\Administrators\AppData\Roaming\Sublime Text 3\Packages\SublimeLinter\commands.py", line 82, in is_enabled
    for lint in linters:
TypeError: 'NoneType' object is not iterable

Python 2 and Python 3 questions

Sorry not sure where to ask this, so I'm creating an issue.

If one were to switch between Python 2 and Python 3 work... is there a way to make SublimeLinter smart enough to know which to use?

Great work!

Great work on this, I've been waiting for decent linting with colorized highlight in ST3. Thanks for your time!

Trying to write a linter for less - can't figure out working directories using tmp

I'm trying to implement a linter for LESS, using Recess.

Everything seems to work okay, expect for this one thing:

Afaik, recess doesn't accept input on stdin, so I'm using tmpfile_suffix = 'less' - which means that the file that I'm linting will reside in /tmp (or somewhere similar) at lint time - correct?

LESS supports an @import statement that can use relative paths to import other files. This doesn't seem to be working, because the linted file isn't where it's expected to be - it's in /tmp, I think?

Recess supports an --includePath parameter to fix this, but I can't figure out how to get hold of the original path to the file currently being linted from inside my linter.py file.

How can I fix this?

Current version of this linter plugin is here, btw.

sublimelinter fails on new files that are not yet saved

Steps:

  • create new file
  • set syntax to something recognized by a linter (I tested with the Python syntax, with pep8 and flake8 activated)
  • admire error in console :
SublimeLinter: error in SublimeLinter daemon: 
SublimeLinter: -------------------- 
SublimeLinter: Traceback (most recent call last):
File "/home/notsqrt/.config/sublime-text-3/Packages/SublimeLinter/lint/queue.py", line 59, in loop
item = self.q.get(block=True, timeout=self.MIN_DELAY)
File "X/queue.py", line 175, in get
queue.Empty

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/notsqrt/.config/sublime-text-3/Packages/SublimeLinter/lint/queue.py", line 67, in loop
self.lint(view_id, timestamp)
File "/home/notsqrt/.config/sublime-text-3/Packages/SublimeLinter/lint/queue.py", line 113, in lint
self.callback(view_id, timestamp)
File "/home/notsqrt/.config/sublime-text-3/Packages/SublimeLinter/sublimelinter.py", line 127, in lint
Linter.lint_view(view_id, filename, code, sections, hit_time, callback)
File "/home/notsqrt/.config/sublime-text-3/Packages/SublimeLinter/lint/linter.py", line 708, in lint_view
linter.lint(hit_time)
File "/home/notsqrt/.config/sublime-text-3/Packages/SublimeLinter/lint/linter.py", line 985, in lint
os.chdir(os.path.dirname(self.filename))
FileNotFoundError: [Errno 2] No such file or directory: ''

SublimeLinter: -------------------- 

My understanding: there is no folder to go to, until the file is properly saved.

Allow setting paths in projects

I'm on OS X 10.9.1 and using flake8 installed through Homebrew's Python. I've configured SL3 to look in /usr/local by adding this to my user settings:

{
    "user": {
        ...
        "paths": {
            "linux": [],
            "osx": [
                "/usr/local/bin"
            ],
            "windows": []
        },
        "python_paths": {
            "linux": [],
            "osx": [
                "/usr/local/lib/python2.7/site-packages"
            ],
            "windows": []
        }
        ...
    }
}

I wanted to override this on a per-project basis, though (since some of my projects use Python 3). I tried editing my project settings like so:

{
    ...
    "SublimeLinter": {
        "@python": 2,
         "paths": {
            "linux": [],
            "osx": ["/usr/local/bin"],
            "windows": []
        },
        "python_paths": {
           "linux": [],
           "osx": ["/usr/local/lib/python2.7/site-packages"],
           "windows": []
        }
    }
}

However, those settings are ignored. Unless I configure the paths in my user settings, they don't get applied.

If I've entered this wrong, please let me know and I'll update the docs with appropriate examples and open a pull request.

Cannot locate Node modules

I have globally installed jshint and csslint on my machine and i've added Node's path to my PATH.

export NODE_PATH=/usr/local/share/npm/lib/node_modules
export PATH=/usr/local/share/npm/bin:$PATH

However here's the console output in Sublime 3:

SublimeLinter: csslint disabled, cannot locate 'csslint' 
SublimeLinter: jshint disabled, cannot locate 'jshint' 

Can't figure out why Sublimelinter isn't loading these modules. Any ideas?

SublimeLinter displays "No lint errors" even could not run linter

How to reproduce:

  • Install SublimeLinter

  • Install language linter, for example SublimeLinter-jshint

  • Do not install jshint itself or remove it from PATH

  • Enable "debug" in SublimeLinter.sublime-settings

  • Select "Show All Errors" in the menu

  • "No lint errors" will be displayed

  • Look at the Sublime Text console, there is the following:

    SublimeLinter: jshint: api.js ['jshint', '--verbose', '', '-']
    SublimeLinter: error launching ['jshint', '--verbose', '
    ', '-']
    SublimeLinter: error was: No such file or directory: 'jshint'

It is hard for user to understand if there are any errors in the file or no linters were executed at all.

Donate work

Can we help with code instead of money? I would like to help with the development of sublimelinter3 and probably other people too.

Linters not loaded

Hi,
I am trying to install python linters on Sublime Text 3 (more specifically PyFlakes)
I am not sure what is the problem, but this is what I have done:
Installed Sublime Text 3, installed Package Control plugin, installed PyFlakes (comes as part of Anaconda to my surprise), installed SublimeLinter and finally installed SublimeLinter-pyflakes.

Nothing happens...

I don't thing SublimeLinter main config file gets update with the new linter plugin (was I supposed to add it manually??)

Here's what I have at the moment at Sublimelint-sublime.settings default
{
"default": {
"debug": false,
"plugins": {
"Java": {
"disable": true
}
}
}
}

How can this be resolved?

Thank you

Add option to redirect all error dialogs to console output.

Everytime I set a color theme, subllime linter prompts with "we will overrwrite X theme" ertc etc - this is quite cumbersome and causing issues with my workflow.

Can we have an option that redirects all errors to the console, instead?

Here's what I've done, temporarrily to util.py - to prevent the issue from happening:

@@ -246,15 +246,7 @@
     generate = True
     have_existing = os.path.exists(scheme_path)

-    if have_existing:
-        generate = sublime.ok_cancel_dialog(
-            'SublimeLinter wants to generate an amended version of �{}�,'
-            ' but one already exists. Overwrite it, or cancel and use'
-            ' the existing amended version?'.format(original_name),
-            'Overwrite'
-        )
-
-    if (generate):
+    if not have_existing:
         with open(scheme_path, 'w', encoding='utf8') as f:
             f.write(COLOR_SCHEME_PREAMBLE)
             f.write(ElementTree.tostring(plist, encoding='unicode'))
@@ -264,13 +256,6 @@
     prefs.set('color_scheme', packages_relative_path(path))
     sublime.save_settings('Preferences.sublime-settings')

-    if generate and not have_existing:
-        sublime.message_dialog(
-            'SublimeLinter generated and switched to an amended version'
-            ' of �{}�.'.format(original_name)
-        )
-
-
 def change_mark_colors(error_color, warning_color):
     """Change SublimeLinter error/warning colors in user color schemes."""

@@ -335,12 +320,6 @@

                     copy = my_version > other_version
                 else:
-                    copy = sublime.ok_cancel_dialog(
-                        'An existing {} syntax package exists, '.format(syntax) +
-                        'and SublimeLinter wants to overwrite it with its version. ' +
-                        'Is that okay?')
-
-                if copy:
                     try:
                         shutil.rmtree(dest_dir)
                     except OSError as ex:

Exception when calling "Choose Lint Mode"

Traceback (most recent call last):
  File "C:\Program Files\Sublime Text 3 Portable Beta\sublime_plugin.py", line 526, in run_
    return self.run()
  File "C:\Program Files\Sublime Text 3 Portable Beta\Data\Packages\SublimeLinter\commands.py", line 434, in run
    self.choose(**kwargs)
  File "C:\Program Files\Sublime Text 3 Portable Beta\Data\Packages\SublimeLinter\commands.py", line 363, in choose
    setting = self.transform_setting(persist.settings.get(self.setting), matching=True)
  File "C:\Program Files\Sublime Text 3 Portable Beta\Data\Packages\SublimeLinter\commands.py", line 345, in transform_setting
    return setting.lower()
AttributeError: 'NoneType' object has no attribute 'lower'

Judging by the error type I assume that the settings handler did not consider the possibility of a setting not existing? Here is my User settings file, everything except delay has been preinserted:

{
    "user": {
        "delay": 0.5,
        "linters": {
            "flake8": {
                "@disable": false,
                "args": [],
                "excludes": [],
                "ignore": "",
                "max-complexity": -1,
                "max-line-length": null,
                "select": ""
            }
        }
    }
}

SublimeLinter with Sublime Text 3059

Today I upgrade my Sublime to 3059 and silently SublimeLinter now doesn't show errors for Python+flake8.

Sublime console:

startup, version: 3059 osx x64 channel: stable
executable: /Applications/Sublime Text.app/Contents/MacOS/Sublime Text
working dir: /
packages path: .../Library/Application Support/Sublime Text 3/Packages
state path: .../Library/Application Support/Sublime Text 3/Local
hardware concurrency: 4
zip path: /Applications/Sublime Text.app/Contents/MacOS/Packages
zip path: .../Library/Application Support/Sublime Text 3/Installed Packages
found 9 files for base name Default.sublime-keymap
found 2 files for base name Default.sublime-mousemap
found 9 files for base name Main.sublime-menu
loading bindings
loading pointer bindings
found 1 files for base name Nil.sublime-theme
theme loaded
app ready
wrote startup cache, added files: 1 orphaned files: 0 total files: 215 cache hits: 214
pre session restore time: 0.249722
using gamma: 2 (err: 6.9282)
first paint time: 0.307123
startup time: 0.31554
launching: /Applications/Sublime Text.app/Contents/MacOS/plugin_host
reloading plugin Default.block
reloading plugin Default.comment
reloading plugin Default.copy_path
reloading plugin Default.delete_word
reloading plugin Default.detect_indentation
reloading plugin Default.duplicate_line
reloading plugin Default.echo
reloading plugin Default.exec
reloading plugin Default.fold
reloading plugin Default.font
reloading plugin Default.goto_line
reloading plugin Default.history_list
reloading plugin Default.indentation
reloading plugin Default.kill_ring
reloading plugin Default.mark
reloading plugin Default.new_templates
reloading plugin Default.open_file_settings
reloading plugin Default.open_in_browser
reloading plugin Default.pane
reloading plugin Default.paragraph
reloading plugin Default.paste_from_history
reloading plugin Default.save_on_focus_lost
reloading plugin Default.scroll
reloading plugin Default.set_unsaved_view_name
reloading plugin Default.side_bar
reloading plugin Default.sort
reloading plugin Default.swap_line
reloading plugin Default.switch_file
reloading plugin Default.symbol
reloading plugin Default.transform
reloading plugin Default.transpose
reloading plugin Default.trim_trailing_white_space
reloading plugin CSS.css_completions
reloading plugin Diff.diff
reloading plugin HTML.encode_html_entities
reloading plugin HTML.html_completions
reloading plugin AutoPEP8.sublautopep8
reloading plugin BracketHighlighter.bh_core
loaded 842 snippets
reloading plugin BracketHighlighter.bh_plugin
reloading plugin BracketHighlighter.bh_remove
reloading plugin BracketHighlighter.bh_swapping
reloading plugin BracketHighlighter.bh_wrapping
reloading plugin BracketHighlighter.ure
reloading plugin Git.add
reloading plugin Git.annotate
reloading plugin Git.commit
reloading plugin Git.diff
reloading plugin Git.flow
reloading plugin Git.git
reloading plugin Git.history
reloading plugin Git.repo
reloading plugin Git.stash
reloading plugin Git.status
reloading plugin Git.statusbar
reloading plugin GitGutter.git_gutter
reloading plugin GitGutter.git_gutter_change
reloading plugin GitGutter.git_gutter_events
reloading plugin GitGutter.git_gutter_handler
reloading plugin GitGutter.git_helper
reloading plugin GitGutter.view_collection
reloading plugin Package Control.Package Control
reloading plugin SideBarEnhancements.Edit
reloading plugin SideBarEnhancements.SideBar
reloading plugin SideBarEnhancements.SideBarDefaultDisable
reloading plugin SideBarEnhancements.StatusBarFileSize
reloading plugin SideBarEnhancements.StatusBarModifiedTime
reloading plugin GoSublime.GoSublime
reloading plugin GoSublime.gs9o
reloading plugin GoSublime.gscommands
reloading plugin GoSublime.gscomplete
reloading plugin GoSublime.gsdoc
reloading plugin GoSublime.gsev
reloading plugin GoSublime.gslint
reloading plugin GoSublime.gspalette
reloading plugin GoSublime.gssynforce
reloading plugin GoSublime.gstest
reloading plugin SublimeLinter.commands
reloading plugin SublimeLinter.sublimelinter
reloading plugin SublimeLinter-flake8.linter
SublimeLinter: flake8 linter loaded 
plugins loaded
GoSublime r13.12.17-1: init mod(gs)
GoSublime r13.12.17-1: init mod(sh)
GoSblime r13.12.17-1 sh: load env vars ['/bin/bash', '-l', '-c', 'echo "..."']: go version: ['/usr/local/go/bin/go', 'version'] -> `go version go1.2 darwin/amd64
` -> `go1.2`: 0.193s
GoSublime r13.12.17-1: init mod(mg9)

** 2013-12-18 17:44:18.529651 **:
GoSublime init r13.12.17-1 (0.002s)
|   install margo: no
|   install state: done
| sublime.version: 3059
| sublime.channel: stable
|       about.ann: a13.12.17-1
|   about.version: r13.12.17-1
|         version: r13.12.17-1
|        platform: osx-x64
|            ~bin: ~/Library/Application Support/Sublime Text 3/Packages/User/GoSublime/osx-x64/bin
|       margo.exe: ~bin/gosublime.margo_r13.12.17-1_go1.2.exe (ok)
|          go.exe: /usr/local/go/bin/go (ok)
|      go.version: go1.2
|          GOROOT: /usr/local/go
|          GOPATH: ~/Documents/Projects/gocode
|           GOBIN: (not set) (should usually be `(not set)`)
|       set.shell: []
|       env.shell: /bin/bash
|       shell.cmd: ['/bin/bash', '-l', '-c', '${CMD}']
--------------------------------

found 9 files for base name Main.sublime-menu
Package Control: Skipping automatic upgrade, last run at 2013-12-18 17:41:07, next run at 2013-12-18 18:41:07 or after
SublimeLinter: flake8 enabled: ('/usr/bin/python', '/usr/local/bin/flake8') 
Writing file .../data.py with encoding UTF-8 (atomic)

Yesterday with previous stable build everything worked fine.

Linter plugins not available in Package Control

After updating to ST3 Build 3059 the plugin has stopped working. I have reinstall the plugin from package control but when I try to install linter plugins, none of the plugins are available in the list.

TypeError: is_enabled() got an unexpected keyword argument 'setting'

On Linux, on a clean ST3 install:

Traceback (most recent call last):
  File "/opt/sublime_text/sublime_plugin.py", line 438, in is_enabled_
    ret = self.is_enabled(**args)
TypeError: is_enabled() got an unexpected keyword argument 'setting'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/sublime_text/sublime_plugin.py", line 442, in is_enabled_
    ret = self.is_enabled()
  File "/home/henri/.config/sublime-text-3/Packages/SublimeLinter/commands.py", line 249, in is_enabled
    return persist.settings.get(self.setting) is not self.value
AttributeError: 'ToggleSettingCommand' object has no attribute 'setting'

Steps to reproduce:

  • clean install of ST3 from ubuntu 64bits deb package
  • remove/backup previous settings mv ~/.config/sublime-text-3 ~/.config/sublime-text-3-bak
  • start ST3
  • install of package control
  • install of SublimeLinter3
  • close the message file that appeared
  • every action (file reload, ctrl+shift+p, open menu, ...) raises the above exception

Edit:
Real context of error, and shorter steps to reproduce:

  • close all files
  • any action will raise the exception (go to another application, open the menu, etc..)

Command prompt window briefly showed at startup (on Windows only ?)

This code from util.py open briefly a command prompt window in Windows (7?):

def get_python_version(path):
        ...
        output = subprocess.check_output((path, '-V'), stderr=subprocess.STDOUT)

Replacing it with the usual popen call seems to remove it:

        out = popen((path, '-V'))
        if out is not None:
            output = out.communicate(timeout=2)
            output = combine_output(output)
        else:
            output = ''

More information about installation

Please add more information about plugin configuration:

  • "linters" section in settings file. Ex. linters : {Javascript : {jshint : true}})
  • wrap_find
  • maybe other options

Settings are generated

You shouldn't commit the generated settings into default settings. They automatically come from inside linters and are merged with user and default settings. This has changed since the original sublimelint.

util.py function tmpfile does not work as intended on windows

The function tmpfile creates a temp file with a code snippet to be linted and runs the linter command on the file, finally returning the result, however on windows the temp file cannot be read while it is still open.

Apologies in advance for my messy code, but here is a working replacement tmpfile function:

def tmpfile(cmd, code, suffix='', output_stream=STREAM_STDOUT):
    """
    Return the result of running an executable against a temporary file containing code.

    It is assumed that the executable launched by cmd can take one more argument
    which is a filename to process.

    The result is a string combination of stdout and stderr.

    """

    with tempfile.NamedTemporaryFile(suffix=suffix, delete=False) as f:
        if isinstance(code, str):
            code = code.encode('utf8')

        f.write(code)
        f.flush()
        f.close()
        cmd = cmd + (f.name,)
        out = popen(cmd)
        if out:
            out = out.communicate()
            r = combine_output(out, output_stream)
        else:
            r = ''
    os.remove(f.name)
    return r

PS: This was noticed primarily when trying to get the phplint linter working

SublimeLinter: Choose Mark Style

If I set Mark Style via Command Palette, the setting in SublimeLinter.sublime-settings is set in Uppercase, for example:

"mark_style": "Outline"

This produces the following error:

Traceback (most recent call last):
  File "C:\Users\Pyerro\AppData\Roaming\Sublime Text 3\Packages\SublimeLinter\lint\persist.py", line 185, in on_update
    self.on_update_callback(need_relint)
  File "C:\Users\Pyerro\AppData\Roaming\Sublime Text 3\Packages\SublimeLinter\sublimelinter.py", line 283, in on_settings_updated
    Linter.redraw_all()
  File "C:\Users\Pyerro\AppData\Roaming\Sublime Text 3\Packages\SublimeLinter\lint\linter.py", line 587, in redraw_all
    cls.apply_to_all_highlights('redraw')
  File "C:\Users\Pyerro\AppData\Roaming\Sublime Text 3\Packages\SublimeLinter\lint\linter.py", line 576, in apply_to_all_highlights
    util.apply_to_all_views(apply)
  File "C:\Users\Pyerro\AppData\Roaming\Sublime Text 3\Packages\SublimeLinter\lint\util.py", line 1119, in apply_to_all_views
    callback(view)
  File "C:\Users\Pyerro\AppData\Roaming\Sublime Text 3\Packages\SublimeLinter\lint\linter.py", line 574, in apply
    getattr(highlights, action)(view)
  File "C:\Users\Pyerro\AppData\Roaming\Sublime Text 3\Packages\SublimeLinter\lint\highlight.py", line 110, in redraw
    self.draw(view)
  File "C:\Users\Pyerro\AppData\Roaming\Sublime Text 3\Packages\SublimeLinter\lint\highlight.py", line 98, in draw
    all.draw(view)
  File "C:\Users\Pyerro\AppData\Roaming\Sublime Text 3\Packages\SublimeLinter\lint\highlight.py", line 358, in draw
    self.set_mark_style()
  File "C:\Users\Pyerro\AppData\Roaming\Sublime Text 3\Packages\SublimeLinter\lint\highlight.py", line 345, in set_mark_style
    self.mark_flags = MARK_STYLES[self.mark_style]
KeyError: 'Outline'

The solution is to set this in all lowercase letters, like this:

"mark_style": "outline"

So I guess the Mark Style command via Command Palette should also set this setting in lowercase letters. This happens on Sublime Text 3 (build: 3047), Win7 64-bit. I am using SublimeLinter 3.0.5 with SublimeLinter-php.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.