How to extend Windows PATH env variable in Sublime Text? - python

How do I permanently extend my PATH variable from sublime text 3?
Specifically I am doing this for my scala REPL for the SublimeREPL package
"default_extend_env": {'{PATH};H:\\scala-2.10.2\\bin'},
I get "error trying to parse strings" error, and have tried with ", and with single \.

You forgot to add the key name "PATH":
"default_extend_env": { "PATH" : "{PATH};H:\\scala-2.10.2\\bin" }
Your full user config file should look like this:
{
"default_extend_env": { "PATH" : "{PATH};H:\\scala-2.10.2\\bin" }
}

Related

How to use variables from backend in .scss files

I have a site built with Django, Python and Wagtail.
What I want is to be able to add some styles in the backend and then use it in my frontent's .scss files.
For example I want to be able to set a primary color to #fff via backend and then use it in my .scss file as:
$g-color-primary: primary_color_from_backend;
$g-font-size-default: primary_font_size_from_backend;
I do not have any idea how I can do that and if it's possible at all?
Thanks for the help.
Unfortunately, it is not possible. You can instead define different classes in the CSS file, then use them in your HTML template dependent on the Django template variables there.
This would require to write out the sass color variables content (with scss syntax) in a physical .scss file, which depends on your development environment. And then import it into other .scss file to get compiled and output through a frontend build process tool like Gulp, Webpack.
For example, Webpack's sass-loader plugin provides option to prepend sass code at Frontend build/compile time.
https://github.com/webpack-contrib/sass-loader
module.exports = {
module: {
rules: [
{
test: /\.s[ac]ss$/i,
use: [
'style-loader',
'css-loader',
{
loader: 'sass-loader',
options: {
prependData: '$env: ' + process.env.NODE_ENV + ';',
},
},
],
},
],
},
};

change font color of meta.function-call visual studio code

I'm trying to configure the font color after the dot "." when a method is called after a parent class rute "meta.function-call" g.e:
import os
os.path()
in this case path, but i want to customize it for everything else, as others text editors for example sublimeText. Can't find anything related on the web
Here is an example that will color the function name and parentheses (the theme name level can be omitted to apply to all themes):
"editor.tokenColorCustomizations": {
"[Atom One Light]": {
"textMateRules": [
{
"scope": [
"meta.function-call.generic.python",
"punctuation.definition.arguments.begin.python",
"punctuation.definition.arguments.end.python"
], /*functions()*/
"settings": {
"foreground": "#0184BC"
}
}
]
}
You can use the Developer: Inspect Editor Tokens and Scopes (enter in the Run Commands menu) to identify each separate token:

How to customize docstring color for Python in VSCode's default theme?

Could some one explain to me please how to customize docstring color for Python in VSCode's default theme? I want to do it thru User Settings because want to be able to save my config file.
I tried to use "editor.tokenColorCustomizations": {} but it affects all strings.
Add this to your setting file:
<!-- language: json -->
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"scope":"string.quoted.docstring.multi.python",
"settings": {
"foreground": "#69676c" //change to your preference
}
}
]
}
additional info:
for finding out the scope of other element, you use the command Developer: Inspect TM Scopes , as described here https://github.com/Microsoft/vscode/pull/29393
more detail:
https://code.visualstudio.com/docs/getstarted/themes#_customize-a-color-theme
Adding to Leonard's answer, if you want to change the triple quotes and escapes too, use the below:
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"scope": [
"string.quoted.docstring.multi.python",
"string.quoted.docstring.multi.python punctuation.definition.string.begin.python",
"string.quoted.docstring.multi.python punctuation.definition.string.end.python",
"string.quoted.docstring.multi.python constant.character.escape.python"
],
"settings": {
"foreground": "#aab5da" //change to your preference
}
}
]
},
Also, I had a hard time finding the user settings file in json format. You can find that by:
CTRL + SHIFT + P > User Settings > On the open tab level extreme right hand side > Open Settings (JSON) icon (Hover to know which icon)
Leonard's answer above is perfect.
Just for the googlers in 2020, I would add that the command in Command Palette: Developer: Inspect TM Scopes seems to have changed to: Developer: Inspect Editor Tokens and Scopes.
This option shows both the standard token types, as well as TextMate scopes.

React - Django webpack config with dynamic 'output'

Have:
I have a Django app. It has react for front-end. I have 2 django apps. movies_list and series_list. I have all my .jsx files inside baseapplication/movies_list/interfaces/ and baseapplication/series_list/interfaces/. The entry point of 2 apps is given ...../index as given in entry object of web-pack.config.js .
Need:
I need to put my compiled .js files inside baseapplication/movies_list/static/movies_list and baseapplication/series_list/static/series_list. So I need to find each entry in entry and get the abs path and construct my output path dynamically for the future apps. This will help my python manage.py collectstatic to get static files from each directory.
How to configure the output to make it dynamic?
module.exports = {
//The base directory (absolute path) for resolving the entry option
context: __dirname,
entry: {
movies: '../movies_list/interfaces/index',
series: '../series_list/interfaces/index',
},
output: {
// I need help here.
path: path.join('<', "static"),
//path: path.resolve('../[entry]/static/react_bundles/'),
filename: "[name].js",
},
}
https://github.com/webpack/docs/wiki/configuration
You can set entry points to a full path of the resulting file. Something like this should work:
module.exports = {
context: __dirname,
entry: {
'baseapplication/movies_list/static/movies_list/index': '../movies_list/interfaces/index',
'baseapplication/series_list/static/series_list/index': '../series_list/interfaces/index',
},
output: {
path: './',
filename: "[name].js",
},
}

Autocomplete for Python in Codemirror?

I am trying to set up an autocomplete feature for Codemirror for the Python language. Unfortunately, it seems that Codemirror only includes the files necessary for Javascript key term completion.
Has anyone built Python hint file for CodeMirror similar to the JavaScript Version?
(Edit for future reference: link to similar question on CodeMirror Google Group)
I'm the original author of the Python parser for Codemirror (1 and 2). You are correct that the Python parser does not offer enough information for autocomplete. I tried to build it into the parser when Codemirror 2 came around but it proved too difficult for my JS skills at the time.
I have far more skills now but far less time. Perhaps someday I'll get back to it. Or if someone wants to take it up, I would be glad to help.
Add python-hint.js, show-hint.js, show-hint.css. Then
var editor = CodeMirror.fromTextArea(your editor instance codes here;
editor.on('inputRead', function onChange(editor, input) {
if (input.text[0] === ';' || input.text[0] === ' ' || input.text[0] === ":") {
return;
}
editor.showHint({
hint: CodeMirror.pythonHint
});
});
< script >
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
mode: {
name: "python",
version: 3,
singleLineStringErrors: false
},
lineNumbers: true,
indentUnit: 4,
extraKeys: {
"Ctrl-Space": "autocomplete"
},
matchBrackets: true
});
CodeMirror.commands.autocomplete = function (cm) {
CodeMirror.simpleHint(cm, CodeMirror.pythonHint);
}
</script>
I start the python autocomplete with a js based on pig-hint from codemirror 3.
You can get the python-hint.js from here.
to work, you need in your html:
include simple-hint,js and python-hint.js, simple-hint.css plus codemirror.js
add this script:
<script>
CodeMirror.commands.autocomplete = function(cm) {
CodeMirror.simpleHint(cm, CodeMirror.pythonHint);
}
</script>
python-hint.js is a basic js I have created today and not reviewed in depth.
You can initialize this way also, adding extraKeys parameter to CodeMirror initialization:
CodeMirror(function(elt) {
myTextArea.parentNode.replaceChild(elt, myTextArea);
}, {
mode: "python",
lineNumbers: true,
autofocus: true,
extraKeys: {"Ctrl-Space": "autocomplete"}
});

Categories

Resources