Build Haml automatic in sublime 3 doesn't work - haml

I'm trying to let Sublime build haml files automatic on save.
I've installed SublimeOnSaveBuild, added haml extension:
{
"filename_filter": "\\.(css|js|sass|less|scss|haml)$",
"build_on_save": 1
}
and created haml.sublime-build in AppData\Roaming\Sublime Text 3\Packages\User:
{
"cmd": ["haml"],
"working_dir": "${file_path:${folder}}",
"selector": "source.haml",
"file_regex": "(.*\\.ts?)\\s\\(([0-9]+)\\,([0-9]+)\\)\\:\\s(...*?)$",
"windows":
{
"cmd": ["haml", "--trace", "$file", "${file_base_name}.html"],
"shell": "true"
}
}
As a result it works fine if I set build system = haml, but it doesn't if I try to set automatic ddetection of build system.
Can anyone help with this issue?
P.S. I'm using sublime 3 without any additional plugins and extensions, but SublimeOnSaveBuild
P.P.S Also automatic detection works good for scss files

The problem was in line
"selector": "source.haml"
It happens because file's scope for haml looks a bit different - "text.haml" instead of "source.haml". So I've change line above to:
"selector": "text.haml"
and in works for me.
You may find out the file's scope in sublime by pressing Ctrl + Alt + Shift + P on file's tab

Related

Autofix or shortcut for prettier issues in VS Code React Native project

I am using Visual Studio Code with a React Native project. ESLint is used to check the stuff specified in the .prettierrc.js.
When something isn't correct I get a hint like this:
Instead of getting these notifications and right clicking on them, selecting Fix this prettier/prettier problem, I want the problems to be fixed either automatically or using a shortcut combination. How can I configure that? I am currently using pure JavaScript, no Typescript.
Edit/create .vscode/settings.json so it will contain
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
}
Fixes issues on save.
Thanks for #jonrsharpe! Just want to add my few cents.
Go to settings.json file:
Windows %APPDATA%\Code\User\settings.json
macOS $HOME/Library/Application Support/Code/User/settings.json
Linux $HOME/.config/Code/User/settings.json
Add there:
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
}
Restart VSCode
Enjoy coding!))
UPDATE
While on Mac the solution above worked for me, on Windows to make it works I had to add following to settings.json :
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true,
"source.fixAll": true
},
"eslint.autoFixOnSave": true

Sublime text 3, Package Controll - cant install packages

I realized like a week ago that I cannot install any new packages via Package Control. I tried everything even reinstalling sublime, while cleaning all files /Library/Application Support/ everything. Still the same problem. Any ideas?
ignored packages updated to: ["Emmet", "Vintage"]
reloading settings Packages/User/Package Control.sublime-settings
reloading settings Packages/User/Preferences.sublime-settings
Package Control: Error downloading package. HTTP exception InvalidCertificateException (Host codeload.github.com returned an invalid certificate ([SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:548))) downloading https://codeload.github.com/sergeche/emmet-sublime/zip/master.
error: Package Control
Unable to download Emmet. Please view the console for more details.
ignored packages updated to: ["Vintage"]
reloading settings Packages/User/Package Control.sublime-settings
reloading settings Packages/User/Preferences.sublime-settings
reloading settings Packages/User/Preferences.sublime-settings
You can change the precedence of the downloader in ~/.config/sublime-text-3/Packages/User/Package Control.sublime-settings.
"downloader_precedence":
{
"linux":
[
"urllib",
"curl",
"wget"
],
"osx":
[
"curl",
"urllib"
],
"windows":
[
"wininet"
]
},
Changing urllib to curl has worked for me.
For OSX:
bhanu's answer is correct but my "Package Control Settings - User" file was not at that exact location. More general instructions:
Open Command Palette (Cmd+Shift+P on Mac)
Type Package Control Settings
Open 'Package Control Settings - Default' and search for downloader_precedence
It probably looks like this - note the default osx downloader is "urllib":
"downloader_precedence": {
"windows": ["wininet"],
"osx": ["urllib"],
"linux": ["urllib", "curl", "wget"]
},
You can't actually edit the Default. Override this setting by going to Command Palette > 'Package Control Settings - User'
Copy-paste the snippet above into the User file (correct indentation and add comma after existing settings if needed) and make "curl" the first osx downloader:
"downloader_precedence": {
"windows": ["wininet"],
"osx": ["curl", "urllib"],
"linux": ["urllib", "curl", "wget"]
},

What steps need to be taken to get autocomplete working for React Native in Visual Studio Code?

I have followed the steps outlined in the VS Code documentation for getting Intellisense working for React Native by installing typings for React Native. Now, what do I need to do to get autocomplete working? For instance, if I type <Text>, I would like to see an automatic closing of that tag. What am I missing here? This seems like it shuld work out of the box.
To enable IntelliSense (autocomplete) you have to install the official React Native Tools extension.
Installation
Open Command Palette by pressing F1, type ext install and press Enter, then look for React Native Tools extension.
Create a jsconfig.json file
You should create a jsconfig.json file in you root directory. It can be empty but must be present. The presence of such a file in a directory indicates that the directory is the root of a JavaScript project.
(Optional)
The file itself can optionally list the files belonging to the project, the files to be excluded from the project, as well as compiler options.
{
"compilerOptions": {
"target": "ES6",
"module": "commonjs",
"allowSyntheticDefaultImports": true
},
"exclude": [
"node_modules"
]
}
You can find more at https://code.visualstudio.com/docs/languages/javascript#_javascript-projects-jsconfigjson
Create a .babelrc file for ReactNative Packger transformer (optional, if you want to use TypeScript)
You should create a .babelrc file with sourceMaps = true and "presets": [ "react-native" ] for better source-mapping support. (required if you want TypeScript support).
{
"presets": [
"react-native" // this is required for debugging with react-native/packager/transformer
],
"plugins": [],
"sourceMaps": true // must be true react-native/packager/transformer using with node-module-debug
// because of some bugs from vscode-node-debug & vscode-react-native, "sourceMaps" cannot be "inline" or "both"
}
Install typings for React Native (optional)
To get IntelliSense for React Native, run npm install typings -g and then typings install dt~react-native --global in your terminal.
Hope this helps!!
React Native Tools in VSCode can't help you close the Tag after you typed<Text>,you can try to install Auto Close Tag and Auto Rename Tag
In my case, I have to copy jsconfig.json to tsconfig.json, close Visual Code and reopen it. Then it works properly.
jsconfig.json
{
"compilerOptions": {
"allowSyntheticDefaultImports": true
},
"exclude": [
"node_modules"
]
}
tsconfig.json
{
"compilerOptions": {
"allowJs": true,
"allowSyntheticDefaultImports": true
},
"exclude": [
"node_modules"
]
}
I am also not getting any IntelliSense and also package auto-import is not working. Since I am not using Typescript, deleting the tsconfig.json helped me.
Take backup of your tsconfig.json file first
In my case, I've already installed many react-native extensions for autoSuggestion and another helper extension, e.g. "React Native Tools", and "React-Native/React/Redux snippets for es6/es7"
Issues:
autoSuggestion keywords not coming while typing.
command(in IOS) + click not letting me to jump on the target files.
Recently I have seen in VS Code editor for new React-native applications autoSuggestion not working.
Steps I have followed to solve:
Go to Extensions
Search for React or React-native
Remove the installed extension
Reload it.

lein-less not running on figwheel start or when a .less file changes

I'm trying to setup a clojurescript project that uses the lein-less plugin to compile .less files. I should say I'm new to clojurescript. The problem is that it doesn't seem to run. It doesn't run when I run "lein figwheel" and neither when I change a .less file.
This is my project.cljs
(defproject fed-repo "0.1.0"
:description "Frontend Repository"
:dependencies [
[org.clojure/clojure "1.7.0"]
[org.clojure/clojurescript "1.7.170"]
[org.omcljs/om "1.0.0-alpha22"]
]
:plugins [
[lein-less "1.7.5"]
[lein-cljsbuild "1.1.2"]
[lein-figwheel "0.5.0-4"]
]
:less {
:source-paths ["src"]
:target-path "resources/public/css"
}
:hooks [
leiningen.less
leiningen.cljsbuild
]
:cljsbuild {
:builds [
{
:id "dev"
:source-paths ["src"]
:figwheel true
:compiler {
:main "fed-repo.core"
:asset-path "js/out"
:output-to "resources/public/js/main.js"
:output-dir "resources/public/js/out"
}
}
]
}
)
What is wrong with this setup?
Under :less the values for the keys :source-paths and :target-path need to go to actual files. You seem to have stopped at the directory.
Here's a working example:
:less {:source-paths ["src/less/"]
:target-path "resources/public/css/"}
Another issue is that you are not telling Figwheel where to hot code reload css from. Example:
:figwheel { :css-dirs ["resources/public/css"] }
With the set up so far there is still no .less -> .css file generation. You could have a terminal open that is dedicated to running lein less once. After changing the .less file run that command. Alternatively automatic generation can be done with the command lein less auto.

Error6 while trying to use sublime text to msbuild

I'm trying to use msbuild with my sublime project. I created the build file suggested here and the following is my project file
{
"folders":
[
{
"path": "/W/MyOrg/MyApp",
"folder_exclude_patterns": ["_ReSharper.*", "bin", "obj"]
}
]
}
I select the msbuild40 build system and hit Build and get the output:
[Error 6] The handle is invalid
[Finished]
I'm not even sure if this is a python or an msbuild error. Which is it, how can I fix it, and whats a good way to troubleshoot this sort of stuff in the future?
Update
I tried updating my project to the following and using that build and still no dice
{
"folders":
[
{
"path": "/W/MyOrg/MyApp",
"folder_exclude_patterns": ["_ReSharper.*", "bin", "obj"]
}
],
"build_systems":
[
{
"name": "msbuild",
"cmd": ["c:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\MSBuild.exe", "w:\\MyOrg\\MyApp\\MyApp.sln"]
}
]
}
Turns out that this happens whenever you start sublime from command line ( I was starting it via a powershell alias).
You can fix this by using a batch file and the START command. I created sublime_text.bat:
START "Sublime Text 2" "C:\Program Files\Sublime Text 2\sublime_text.exe" %*
and set my powershell alias to that bat file. Now everything works.