Package: collective.recipe.vscode
ContentsIntroductionInstallationAvailable OptionsLinksExample UsageContributorsChangelog0.1.9 (2023-06-30)0.1.8 (2021-10-28)0.1.7 (2021-06-23)0.1.6 (2020-07-15)0.1.5 (2020-06-26)0.1.4 (2019-05-28)0.1.3 (2019-03-12)0.1.2 (2019-02-14)0.1.1 (2019-02-11)0.1.0 (2019-02-10)Introductioncollective.recipe.vscodeis the buildout recipe forVisual Studio Codelover who wants pythonautocomplete and intelliSensefeatures while developing pythonBuildoutbased project,
normally buildout eggs are not available in python path even if you provide virtualenv python path.
This tool will help not only adding eggs path aspython extraPathbut also you can manage per project basis vscode settings
for linter, autoformatting.A general question may arise that why we will use this tool, whether we can createVisual Studio Codeproject settings easily (we have better knowledge overVisual Studio Codeconfiguration)?
Well i completely agree with you, but if you want to get benefited fromVisual Studio Codeautocompletion feature (basically I am lover of autocompletion), you have to add all eggs links and it is hard to manage eggs links manually
if the size of project is big (think about anyPlonepowered project),
beside it is good practice allways use project specific linter path. For example my globalflake8linter doesn’t work
for my python3 project!InstallationInstallcollective.recipe.vscodeis simple enough, just need to create a section forvscodeto your buildout.
Before usingcollective.recipe.vscode, if you are going to use linter feature, make those are added in eggs section or globally installed.Example Buildout:[buildout]
parts += vscode

[vscode]
recipe = collective.recipe.vscode
flake8-enabled = True
flake8-path = ${buildout:directory}/bin/flake8
black-enabled = True
black-args = ----line-length 88You can also use the following to include the vscode recipe in all your buildouts automaticallyModify/Add~/.buildout/default.cfg:[buildout]
_to_always_include_vscode = ${vscode:recipe}

[vscode]
recipe = collective.recipe.vscode
_to_remove_buildout_warning = ${buildout:_to_always_include_vscode}Available OptionseggsRequired: NoDefault: Will find all recipes with eggs specified and include them.Your project’s list of eggs, those are going to be added as extra path forautocomplete and intelliSense.python-pathRequired: NoDefault:collective.recipe.vscodewill find current python executable path.The python executable path for current project, if you are using virtual environment then should be that python path. FYI: ${home} and ${project} variable should work.flake8-enabledRequired: NoDefault: FalseFlag that indicates flake8 based linting.flake8-pathRequired: NoDefault: try to find flake8 executable path automatically.flake8-argsRequired: NoDefault: “”pylint-enabledRequired: No
Default: Falsepylint-pathRequired: NoDefault: try to find pylint executable path automatically.pylint-argsRequired: NoDefault:pep8-enabledRequired: NoDefault: Falsepep8-pathRequired: NoDefault: try to find pep8 executable path automatically.pep8-argsRequired: NoDefault: “”jedi-enabledRequired: NoDefault: FalseIf False thenpython.languageServerwill bePylance. Ensure you have installed the Pylance vscode extension.omelette-locationRequired: NoDefault: ${buildout:directory}/parts/omelette - the default omelette location.autocomplete-use-omeletteRequired: NoDefault: Falseblack-enabledRequired: NoDefault: Falseblack-pathRequired: NoDefault: try to find black executable path automatically.You could provide buildout specific black executable. It is very flexible way to avoid using global pylint.
Example of relative path usecase:
i.)${buildout:directory}/bin/blackii.)$project_path/bin/blackiii.)./bin/blackiv.)~/path/bin/blackblack-argsRequired: NoDefault: ‘’isort-enabledRequired: NoDefault: FalseFlag that indicates isort is enabled.isort-pathRequired: NoDefault: try to find isort executable path automatically.isort-argsRequired: NoDefault: ‘’ignore-developRequired: NoDefault: FalseIf you don’t want development eggs, should go for autocompletion.ignoresRequired: NoDefault: “”If you want specific eggs should not go for autocompletion.packagesRequired: NoDefault: “”Location of some python scripts or non standard modules (don’t have setup file), you want to be in system path.generate-envfileRequired: NoDefault: TrueGenerate .env file to add eggs to PYTHONPATHrobot-enabledRequired: NoDefault: FalseGenerate settingrobot.python.envwith buildout eggs for Robot Framework Language Server.
Generate taskStart Plone Test Serverintotasks.json.
Generate taskRobot Framework: Launch Templateintolaunch.jsonfor Robot Framework Language Server.LinksCode repository:https://github.com/nazrulworld/collective.recipe.vscodeContinuous Integration:https://travis-ci.org/nazrulworld/collective.recipe.vscodeIssue Tracker:https://github.com/nazrulworld/collective.recipe.vscode/issuesExample UsageInstall  vscode recipe with stndard settings:>>> write(sample_buildout, 'buildout.cfg',
... """
... [buildout]
... develop =
...     %(test_dir)s/develop/vscodetest_pkg1
... eggs =
...     vscodetest_pkg1
...     zc.recipe.egg
...     zc.buildout
... parts = vscode
...
... [vscode]
... recipe = collective.recipe.vscode
... packages = %(test_dir)s/Products
... ignore-develop = False
... eggs = ${buildout:eggs}
... flake8-enabled = True
... flake8-path = ${buildout:directory}/bin/flake8
... black-enabled = True
... black-path = $project_path/bin/black
... black-args = --line-length 88
...              --skip-string-normalization
... """ % globals())
>>> output_lower = system(buildout + ' -c buildout.cfg').lower()
>>> "installing vscode." in output_lower
True
>>> 'tests/develop/vscodetest_pkg1' in output_lower
True
>>> ls(sample_buildout)
-  .installed.cfg
d  .vscode
d  bin
-  buildout.cfg
d  develop-eggs
d  eggs
d  parts
<BLANKLINE>
>>> import json
>>> import os
>>> from collective.recipe.vscode.recipes import mappings
>>> settings_dir = os.path.join(sample_buildout, ".vscode")
>>> vsc_settings = json.loads(read(settings_dir, 'settings.json'))
>>> len(vsc_settings[mappings['autocomplete-extrapaths']]) == 4
True
>>> mappings['flake8-enabled'] in vsc_settings
True
>>> vsc_settings[mappings['formatting-provider']] == "black"
TrueVS Code settings with all default options::>>> os.unlink(os.path.join(settings_dir, 'settings.json'))
>>> write(sample_buildout, 'buildout.cfg',
... """
... [buildout]
... develop =
...     %(test_dir)s/develop/vscodetest_pkg1
... eggs =
...     vscodetest_pkg1
...     zc.recipe.egg
... parts = vscode
...
... [vscode]
... recipe = collective.recipe.vscode
... eggs = ${buildout:eggs}
... """ % globals())
>>> output = system(buildout + ' -c buildout.cfg').lower()
>>> vsc_settings = json.loads(read(settings_dir, 'settings.json'))
>>> mappings['flake8-path'] not in vsc_settings
True
>>> len(vsc_settings[mappings['autocomplete-extrapaths']]) == 3
TrueContributorsMd Nazrul Islam<email2nazrul@gmail.com>, Original Author.Matteo ParrucciChangelog0.1.9 (2023-06-30)Add optionrobot-enabled(defaultfalse) to enable support for Robot Framework Language Server
[datakurre]0.1.8 (2021-10-28)Change languageserver to Pylance (Microsoft no longer works)Default to generating .env file to aid in debuggingOptions are removed.jedi-pathvsintellicode.python.completionsEnabledis no longer part of VS code settings.0.1.7 (2021-06-23)fix vscode debugger by including terminal.integrated.env.* settings and zc.recipe.egg in paths.0.1.6 (2020-07-15)Auto find all eggs for all recipes so eggs argument no longer required. [djay]Document how to automatically include the vscode recipe in all your buildouts [djay]Added python.analysis.extraPaths which Microsoft language server/Pylance use to find eggs [djay]If jedi-enabled is off ensure “python.languageServer” is set to ‘Microsoft’  and
‘vsintellicode.python.completionsEnabled’ is turned on [djay]0.1.5 (2020-06-26)Issue#10don’t ignore html files[MrTango]0.1.4 (2019-05-28)Issue#3Fixed  typo[parruc]Issue#4Documented isort[parruc]Issue#5Automatic .env file generation[parruc]0.1.3 (2019-03-12)Bug fixesIssue#2Linter disabling simply not working0.1.2 (2019-02-14)New featuresdefaultfiles.associationsandfiles.excludefor python file now will be automatically included
if those are not in existingsettings.jsonBug fixesNormally buildout removed generated file/directory first if exists, that’s why previouslysettings.jsonfile
removed and ultimately existing settings were lost! [nazrulworld]0.1.1 (2019-02-11)Bug fixesIssue#1pep8 enabling configuration added even not mentioned in buildoutOpen existing settings file (mode was missing while opening file)0.1.0 (2019-02-10)Initial release.
[nazrulworld]