Why is my sublime-build not being picked up automatically? - sublimetext2

I have the following sass.sublime-build file in my User directory:
{
"cmd": ["C:/ruby193/bin/ruby.exe", "C:/ruby193/bin/sass", "$file", "$file_path/$file_base_name.css", "--precision", "5"]
, "selector": "source.scss"
}
Yet whenever I open files like Builder.scss the Automatic build is disabled. I have to manually change it to "sass" before it will build (which it does then perfectly fine).
I have similar build files set up with coffee script and it picks up automatically, no problem. Am I missing something?

It looks like the file name is taking preference over the provided selector. Is it fixed if you change your build preferences file to scss.sublime-build?

Related

module pygame has no init member pylint [duplicate]

This is the code I have:
import pygame
pygame.init()
I'm very confused because if I try to run the file, then there seems to be no issue, but pylint says the following:
E1101:Module 'pygame' has no 'init' member
I have searched thoroughly for a solution to this "error". In every relevant case I found, the solution was to make sure that I have not made another file or folder with the name "pygame", because in that case, I would just be importing my own file or folder.
However, I have not made a folder or file with a name even close to "pygame", so I don't know what the problem is.
As said earlier, it seems like I'm able to run the file without any issues and having errors like this confuses me in my learning process.
I write code in Visual Studio Code, I'm using python 3.6, I'm using pygame 1.9.3 and have updated my pylint. Any help would be appreciated.
Summarizing all answers.
This is a security measure to not load non-default C extensions.
You can white-list specific extension(s).
Open user settings and add the following between {}:
"python.linting.pylintArgs": [
"--extension-pkg-whitelist=extensionname" // comma separated
]
You can allow to "unsafe load" all extensions.
Open user settings and add the following between {}:
"python.linting.pylintArgs": [
"--unsafe-load-any-extension=y"
]
If you have VS code, go in your .vscode folder > settings.json or search for python.linting.mypyArgs Under user settings tab paste inbetween curly braces
"python.linting.pylintArgs": [
"--extension-pkg-whitelist=lxml" // The extension is "lxml" not "1xml"
]
I no longer see the pyinit error.
I had the same issue when I started using Visual Studio Code with Python. It has nothing to do with having another pygame.py or not installing it properly. It has to do with the fact that Visual Studio Code takes your code literally, and since you cannot import pygame.init(), it thinks that it isn't a correct module.
To fix this, open up settings.json (go into your settings, and click the {} icon) and paste
"python.linting.pylintArgs": [
"--extension-pkg-whitelist=pygame"
]
to it.
I had the same issue with one of my modules. This is what I did to resolve the problem. (I'm using visual studio on windows 10)
Press CTRL+SHIFT+P in visual studio
Choose "Preferences: Open Settings (JSON)"
Add "python.linting.pylintArgs": ["--generate-members"] below one of the lines (put a comma if necessary)
Save the .json file (CTRL+S)
For me, the code looks like this :
{
"breadcrumbs.enabled": false,
"editor.minimap.enabled": false,
"python.pythonPath": "C:\\Users\\xxx\\Anaconda3",
"terminal.integrated.rendererType": "dom",
"window.menuBarVisibility": "default",
"workbench.activityBar.visible": false,
"workbench.statusBar.visible": true,
"python.linting.pylintArgs": ["--generate-members"], //line to add
"[json]": {
}
}
Hope it helps.
Credit to #Alamnoor on github
This answer includes the answer to your question. In short it explains:
Pylint imports modules to effectively identify valid methods and attributes. It was decided that importing c extensions that are not part of the python stdlib is a security risk and could introduce malicious code.
and as a solution it mentions, among others:
Disable safety using the .pylintrc setting unsafe-load-any-extensions=yes.
See here for more information about pylint.rc. Quickest method is to just create the file .pylintrc in your project directory or your home directory.
I found adding this in settings.json() solves the problem.
"python.linting.pylintArgs":[
"--extension-pkg-whitelist=pygame",
"--erros-only"
]
I find an answer and it really works for me.
See the accepted answer and change it to extension-pkg-whitelist=lxml
pylint 1.4 reports E1101(no-member) on all C extensions
I recommend going to the view tab, clicking command palette and searching preferences: open settings.json. Then add a comma on the last line of code.Below that paste this:
"python.linting.pylintArgs": [
"--extension-pkg-whitelist=extensionname" // comma separated
]
Then save your document (ctrl + s).
Check if you have a python file named pygame.py created by you in your directory. If you do, then the import pygame line is importing your own file instead of the real Pygame module. Since you don't have an init() function in that file, you're seeing this particular error message.
I found a solution, modifying the most voted answer:
"python.linting.pylintArgs": [
"--extension-pkg-whitelist=pygame"
]
Replaced the "lxml" with "pygame".
Disable Pylint
1.Press ctrl + shift + p
2.Then type Disable Pylint
If you are using vscode then you can go to settings:
python.linting.pylintEnabled = False
It will fix the problem. If you aren't using vscode then you can go the command prompt and manually uninstall pylint with the command
pip uninstall pylint.

Excluding files from auto save (autoSave), in Visual Studio Code

I have just picked up the Visual Studio Code, and am not very familiar with how the settings should actually be.
I have been trying to exclude a file type from Auto Save but I am not able to get this to work.
The auto save works, but the part which defines the exclusion does not work (It is basically suppose to exclude .liquid extension from autosave).
This is what I have done by far; in the settings.json file I added:
"files.exclude": {
"*.liquid": true
},
"files.autoSaveDelay": 1000,
"files.autoSave": "afterDelay"
All other override settings I wrote int the .json file are working property, but this one does not.
Any help is greatly appreciated, thank you.
Currently(2019-12-06), the answer is not. But you can follow the progress in develop.
https://github.com/Microsoft/vscode/issues/42170
This extension helps : AutoSaveExt
It enables to specify what all file extensions to auto-save.
How-to:
install it
keep the auto-save option in vscode to off
open settings.json
add below entry:
"autoSaveExt": {
"debounce": 999,
"extensions": [".c", ".cpp", ".h"]
}
reload window or relaunch vscode
now all files with extensions .c, .cpp and .h will be auto-saved after 999 ms of editing
Original reference : wclr's comment # Allow to set files.autoSave as language specific or folder setting
#42170

Different user settings for synced sublime

I've synced my User folder with sublime settings.
But what if I want to use different settings for different machines? For example, in settings of terminal package I define path to Git Bash, and it's
"terminal": "C:/Program Files (x86)/Git/bin/sh.exe"
on one machine, and
"terminal": "C:/Program Files/Git/bin/sh.exe"
on another.
I've tried to use default settings, but they refresh all the time.
Maybe look into this package: https://packagecontrol.io/packages/PackageSync
I've never used it, but according to the README,
PackageSync provides the following user configurable settings:
...
ignore_files [array]
The list of files to ignore when backing up.
So you would want to create a PackageSync.sublime_settings file that has this in it:
{
"ignore_files": "Terminal.sublime_settings"
}
This isn't ideal since it prevents the enitre file from syncing, not just that one entry (the "terminal": "C:/Program Files (x86)/Git/bin/sh.exe" entry), but it should work. (Disclaimer: I have not tried this myself)
Alternative: Possible workaround:
You could also just use the line "terminal" : "~/my_custom_terminal_shortcut" in your settings and then create a ~/my_custom_terminal_shortcut file on each computer that links to the appropriate location

SublimeCodeIntel and Symfony2 autoloading

I am trying to move from PHPStorm to Sublime Text 3 but I got stuck on the autocomplete using SublimeCodeIntel in conjunction with Symfony 2. How can I make SublimeCodeIntel to scan all the vendor/ and src/ directory of my project?
Right now whenever I'm in the controller and I'm typing something like
$response = new Response()
$response->get
I get Warning: evaluating 'Request' at GamesController.php#27: could not resolve first part of 'Request'.
First, select the Settings-Default and Settings-User options under Preferences -> Packages -> SublimeCodeIntel. Copy the full text of the Default file and paste it into the User file, which should be empty if you haven't customized the plugin at all. You can now close the Default file.
Now, in the main body of the preferences, set
"codeintel_max_recursive_dir_depth": 25,
"codeintel_scan_files_in_project": true,
Next, scroll down to the bottom to the codeintel_config array, and edit the PHP section to the following:
"PHP": {
"phpExtraPaths": ["/path/to/library/files", "/another/path"],
"codeintel_scan_files_in_project": true,
"codeintel_max_recursive_dir_depth": 25
}
Save the file, restart Sublime, and you should be all set. If for some reason it's still not working, go to your ~/.codeintel/db directory and delete the PHP directory. You may also find a similar directory in the root of your project, so if it exists go ahead and delete that one too. This forces a reindexing of your code and includes, and since it's based on your new config options everything should work as expected. Remember that reindexing can take some time, so be patient.
Good luck!

How do you configure JSHint options globally in Sublime Text 2?

I'd like to turn off particular warnings globally when using Sublime Text 2's JSHint plugin. For instance, "laxcomma".
I tried editing the .jshintrc file in JSHint's Sublime Packages folder, but this did not work.
{
"laxcomma": true
}
Adding a project specific .jshintrc file with the same options solves the issue for that particular project, but I would like these options to be global.
Any suggestions?
From the JSHint docs page:
http://www.jshint.com/docs/
JSHint will look for this file in the current working directory and, if not found, will move one level up the directory tree all the way up to the filesystem root.
So, technically you could put a .jshintrc file at the root level of your filesystem (/.jshintrc) and every new project would default to those options. Individual projects could override them as needed.
If anyone's having trouble creating a .jshintrc in Windows, you could go to AppData\Roaming\Sublime Text 3\Packages\SublimeLinter, copy .editorconfig for example, rename and edit it then place it in your root directory like #philip-walton suggested.
If you edit the file here, you may need to Run your text editor as administrator.
If you try to rename the file here, you may need to right-click the file, go to Security, Advanced, change the Owner object name to yourself (PC-Name\User-Name), then also Add yourself to the list of Permissions by selecting the Principal.