ST3 SublimeLinter with HTML tidy doesn't obey args - sublimetext3

I want to suppress various kind of useless linter error reports, e.g. lacks "content" attribute. So I tried experimenting with setting the options in SublimeLinter.sublime-settings:
"linters": {
"htmltidy": {
"#disable": false,
"args": [-xxx true],
"excludes": []
}
},
and so on and they don't seem to do anything. Am I doing something wrong?

The settings file is a JSON file, and it looks like your edits are not valid JSON. Try putting quotes around the args, either:
"args": ["-xxx true"]
or
"args": ["-xxx", "true"]

This worked for me:
"linters": {
"htmltidy": {
"#disable": false,
"args": [
//http://tidy.sourceforge.net/docs/quickref.html
"--drop-proprietary-attributes", "false"
],
"excludes": []
}...

Related

SublimeText - CSSLint ignore alphabetical order

I'm using Sublime Text 3 and SublimeLinter CSSLint.
How can I disable the order-alphabetical warnings?
I've found this link:
https://github.com/SublimeLinter/SublimeLinter-csslint/issues/15
Preferences > Package Settings > SublimeLinter > Settings.
I get this window:
Then what?
Someone suggested the following code:
"linters": {
"csslint": {
"#disable": false,
"args": [],
"errors": "",
"excludes": [],
"ignore": ["order-alphabetical"],
"warnings": ""
},
I've tried copying and pasting into the right hand pane (// SublimeLinter Settings - User) but I get an error message:
What am I doing wrong? Should I paste this into the left pane/window? Do I delete the text "// SublimeLinter Settings - User"?
Thank you
While Sublime Text allows comments in its JSON-like settings format, you need to make sure the rest of notation is valid. Hence, your settings should look something like this:
{
"linters": {
"csslint": {
"#disable": false,
"args": [],
"errors": "",
"excludes": [],
"ignore": ["order-alphabetical"],
"warnings": ""
}
}
}

Sublime Text 3 delete my php code when I save it

<?php
namespace App\Http\Controllers\Admin;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
class AdminHomeController extends Controller
{
public function index()
{
return view('AdminHome')->withPages(Page::all());
}
}
when i press ctrL+s to save it ,then some code is deleted . I don't know why ,can you give me a solution ?
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
class AdminHomeController extends Controller {
public function index() {
return view('AdminHome')->withPages(Page::all());
}
}
the code become like this .
I installed packages for my sublime text 3 ,in the follow picture . I think it's caused by sublimeLinter , but I don't kow how to fix it , my user settings as follows:
enter image description here
{
"user": {
"debug": false,
"delay": 0.15,
"error_color": "D02000",
"gutter_theme": "Packages/SublimeLinter/gutter-themes/Default/Default.gutter-theme",
"gutter_theme_excludes": [],
"lint_mode": "load/save",
"linters": {
"php": {
"#disable": false,
"args": [],
"excludes": []
},
"phplint": {
"#disable": false,
"args": [],
"excludes": []
}
},
"mark_style": "outline",
"no_column_highlights_line": false,
"passive_warnings": false,
"paths": {
"linux": [],
"osx": [],
"windows": [
"D:\\wamp64\\bin\\php\\php7.0.4"
]
},
"python_paths": {
"linux": [],
"osx": [],
"windows": []
},
"rc_search_limit": 3,
"shell_timeout": 10,
"show_errors_on_save": false,
"show_marks_in_minimap": true,
"syntax_map": {
"html (django)": "html",
"html (rails)": "html",
"html 5": "html",
"javascript (babel)": "javascript",
"magicpython": "python",
"php": "html",
"python django": "python",
"pythonimproved": "python"
},
"warning_color": "DDB700",
"wrap_find": true
}
}
This is the first time I ask question on this website ,and I am from China , my English is not very good .
your issue is reported before from phpfmt users. under package settings-> phpfmt -> setting - User then add "passes": ["OnlyOrderUseClauses"]. have a look on this issue
update: the working format is "passes": "OnlyOrderUseClauses", as #SHUIPING_YANG mentioned
I had the same issue, but couldn't figure out exactly why Sublime always deleting my PHP use statements; Moreover, while trying to troubleshoot the issue, I realized that my Sublime packages differed from the ones you had installed. Expect for one, that was SublimeCodeIntel. I removed it, and upon pressing Ctrl + S, Sublime no longer removed the use statements.

How to set key-bindings in Sublime that change values of settings?

I'm looking to bind the "alt+f11" binding to toggle "draw_centered", which centers the text as in Distraction-free mode. I'm not sure how to get it to work though.
Heres my keybinds so far:
//if draw_centered == true, set to false
{ "keys": ["alt+f11"], "command": "set_setting", "args":
{
"setting": "draw_centered",
"value": "true",
},
"context":
[
{ "key": "setting.draw_centered", "operator": "equal", "operand": false}
]
},
//if draw_centered == false, set to true
{ "keys": ["alt+f11"], "command": "set_setting", "args":
{
"setting": "draw_centered",
"value": "false",
},
"context":
[
{ "key": "setting.draw_centered", "operator": "equal", "operand": true}
]
}
I couldn't find a command that automatically toggled "draw_centered", so I had to resort to building some sort of advanced command. I'm having a bit of trouble understanding the documentation on keybindings, but I tried to follow the "Contexts" example. Could anyone point to what I'm doing wrong?
Thanks sergioFC for the tip about toggle_setting! I got it to work with this code:
{ "keys": ["alt+f11"], "command": "toggle_setting", "args":
{
"setting": "draw_centered",
}
}
EDIT: I discovered a bug with this. After using the key-combination "alt-f11" now, the distraction-free mode isn't behaving like it should. It now follows the draw_centered state that I am in when I switch from normal to distraction-free mode.
For example: if I have a file opened and click 'alt-f11' so I am left-aligned (i.e. draw_centered = false) , the window will remain left-aligned when I enter distraction-free mode. Any ideas as to why this is and how to fix it?
A little late, but it took me a while to find out how to do something similar and this was the most closest question to what I was trying to achieve.
toggle_setting only works in the current view(file you are working on), it also won't work in other options like show_encoding, because these aren't too related to the view specifically rather than being more part of the panel spectrum.
After digging a couple of hours I found an old plugin called Cycle Settings, this one was for Sublime 2, but after a little tweaking it worked as expected.
(I remember that there was an option to create packages directly in sublime, but don't remember where..)
Go to Preferences/Browse Packages... and create a new file there
"Cycle Settings/cycle_setting.py" and the following code there:
"""
Cycle Setting plugin for Sublime Text 3.
Copyright 2011 Jesse McCarthy <http://jessemccarthy.net/>
Adds a command that can be called from a key binding to toggle or
cycle through values for a setting.
The Software may be used under the MIT (aka X11) license or Simplified
BSD (aka FreeBSD) license. See LICENSE
"""
import sublime, sublime_plugin
class CycleSettingCommand(sublime_plugin.TextCommand):
def run(self, edit, setting, options):
"""Cycle $setting to next of $options"""
index = len(options)
if not index :
return
settings = sublime.load_settings('Preferences.sublime-settings')
value = settings.get(setting)
if value in options :
index = options.index(value)
index += 1
if index >= len(options) :
index = 0
value = options[index]
settings.set(setting, value)
sublime.save_settings('Preferences.sublime-settings')
self.view.set_status(
'cycle_setting',
"Setting '{setting}' cycled to value '{value}'".format(**locals())
)
Now, lets use our new command for bindings
Go to Preferences/Key Bindings
[
{
"keys": ["f5"],
"command": "cycle_setting",
"args": {
"setting": "draw_centered",
"options": [true, false]
}
},
{
"keys": ["shift+f5"],
"command": "cycle_setting",
"args": {
"setting": "default_line_ending",
"options": ["system", "windows", "unix"]
}
}
]
What our command is doing is cycling through the options array and saving the current one in the cycle to User/Preferences.sublime-settings.
I hope this helps someone else, I actually spend a while trying to find how to achieve this with many commands for external plugins and at this rate I was soon going to run out of key combinations, regards!

Hotkey for running command

I want to create a keyboard shortcut in Sublime Text 3.
The command I want to run is something like this:
[make.sublime-build]
{
"name": "boot-dev-svr",
"cmd": ["java","-jar","D:\\prg\\boot\\boot-1.1.1.jar","development"],
"working_dir": "D:/smx",
"path": "C:/Windows/System32",
}
The key I want to map this action to is F5:
[Default (Windows).sublime-keymap - User]
[
{ "keys": ["f5"], "command": "BLAH BLAH BLAH" },
]
Seems like it should be simple, but "cmd" and "command" seem to be fundamentally different. I have not managed to get it to work.
How do I put these things together to do what I want in Sublime Text 3?
Have you tried putting the actual command in []
That worked for me.
Another solution would be to update Sublime Text 3 to the latest release, sometimes that fixes the bug.
Hope I helped!
EDIT
Try removing the comma from the end of make.subime-build, like this
{
"name": "boot-dev-svr",
"cmd": ["java","-jar","D:\\prg\\boot\\boot-1.1.1.jar","development"],
"working_dir": "D:/smx",
"path": "C:/Windows/System32",
}
This is what I wound up doing, which seems to work, more or less.
Build:
{
"cmd": ["python","prj.py","--runmake","serve"],
"working_dir": "D:/smx",
"path": "C:/Python27",
"variants":
[
{
"name": "boot-dev-svr",
"cmd": ["java","-jar","D:\\prg\\boot\\boot-1.1.1.jar","development"],
"working_dir": "D:/smx",
"path": "C:/Windows/System32",
},
]
}
Keymap:
[
{ "keys": ["f5"], "command": "build", "args": {"variant": "boot-dev-svr"} },
]

SublimeLinter "max-line-length" setting not applied

I'm having difficulty setting user settings for SublimeLinter in SublimeText3. I've checked here: http://www.sublimelinter.com/en/latest/settings.html
I've tried setting my user settings, and setting "max-line-length" to 80 (the default is 100):
{
"user": {
"debug": false,
"delay": 0.25,
"error_color": "D02000",
"gutter_theme": "Packages/SublimeLinter/gutter-themes/Default/Default.gutter-theme",
"gutter_theme_excludes": [],
"lint_mode": "background",
"linters": {
"pylint": {
"#disable": false,
"args": [],
"disable": "",
"enable": "",
"excludes": [],
"max-line-length": 80,
"paths": [],
"rcfile": "",
"show-codes": false
}
},
"mark_style": "outline",
"no_column_highlights_line": true,
"passive_warnings": false,
"paths": {
"linux": [],
"osx": [],
"windows": []
},
"python_paths": {
"linux": [],
"osx": [],
"windows": []
},
"rc_search_limit": 3,
"shell_timeout": 10,
"show_errors_on_save": false,
"show_marks_in_minimap": true,
"syntax_map": {
"html (django)": "html",
"html (rails)": "html",
"html 5": "html",
"php": "html",
"python django": "python"
},
"warning_color": "DDB700",
"wrap_find": true
}
}
However, this setting is not applied. I have closed and re-opened sublime text. How do I get this setting to be applied? Thanks.
The syntax you are using seems to work for some linters, however, as far as I know it doesn't works for pylint.
Anyway, for using pylint from Sublime Text you can use the command argument --max-line-length=N,
so change
"args": []
for
"args": ["--max-line-length=90"]
In addition, if you do this, remove the max-line-length property.
Edit: where to place SublimeLinter settings.
You can learn about it in the SublimeLinter settings documentation
I used the user-settings-file, that you can usually find using the following menu option: Preferences > Package Settings > SublimeLinter > Settings-User. For this purpose you need to add the option inside linters/pylint:
{
"user": {
"linters": {
"pylint": {
// "exampleOtion": "exampleValue",
"args": ["--max-line-length=90"]
}
}
}
}
Please note that probably your config file is similar to the one in the question, so you just need to add the new option inside "pylint" without breaking the JSON format
As this message continues to appear regularly on the first page of Google and SublimeLinter has changed a lot, here is my solution:
I enter "pref lint" or "preferences linter" in the Command Palette in sublime text 3 (screenshot) to open the preferences file.
Here's the SublimeLinter.sublime-settings default config file I am using (W0312 is for using tabs instead of spaces):
// SublimeLinter Settings - User
{
"linters": {
"pylint": {
"filter_errors": ["warning:", "W0312"]
}
}
}
I use pylint-messages to find the right error/warning codes, with the help of the search box.

Resources