Git Product home page Git Product logo

collective.recipe.vscode's Introduction

Package Status Travis Build Status Test Coverage Python Versions Latest Version License

collective.recipe.vscode is the buildout recipe for Visual Studio Code lover who wants python autocomplete and intelliSense features while developing python Buildout based 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 as python extraPath but 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 create Visual Studio Code project settings easily (we have better knowledge over Visual Studio Code configuration)? Well i completely agree with you, but if you want to get benefited from Visual Studio Code autocompletion 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 any Plone powered project), beside it is good practice allways use project specific linter path. For example my global flake8 linter doesn't work for my python3 project!

Install collective.recipe.vscode is simple enough, just need to create a section for vscode to your buildout. Before using collective.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 88

You can also use the following to include the vscode recipe in all your buildouts automatically

Modify/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}
eggs

Required: No

Default: 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 for autocomplete and intelliSense.

python-path

Required: No

Default: collective.recipe.vscode will 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-enabled

Required: No

Default: False

Flag that indicates flake8 based linting.

flake8-path

Required: No

Default: try to find flake8 executable path automatically.

flake8-args

Required: No

Default: ""

pylint-enabled

Required: No Default: False
pylint-path

Required: No

Default: try to find pylint executable path automatically.

pylint-args

Required: No

Default:

pep8-enabled

Required: No

Default: False

pep8-path

Required: No

Default: try to find pep8 executable path automatically.

pep8-args

Required: No

Default: ""

jedi-enabled

Required: No

Default: False

If False then python.languageServer will be Pylance. Ensure you have installed the Pylance vscode extension.

omelette-location

Required: No

Default: ${buildout:directory}/parts/omelette - the default omelette location.

autocomplete-use-omelette

Required: No

Default: False

black-enabled

Required: No

Default: False

black-path

Required: No

Default: 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/black ii.) $project_path/bin/black iii.) ./bin/black iv.) ~/path/bin/black

black-args

Required: No

Default: ''

isort-enabled

Required: No

Default: False

Flag that indicates isort is enabled.

isort-path

Required: No

Default: try to find isort executable path automatically.

isort-args

Required: No

Default: ''

ignore-develop

Required: No

Default: False

If you don't want development eggs, should go for autocompletion.

ignores

Required: No

Default: ""

If you want specific eggs should not go for autocompletion.

packages

Required: No

Default: ""

Location of some python scripts or non standard modules (don't have setup file), you want to be in system path.

generate-envfile

Required: No

Default: True

Generate .env file to add eggs to PYTHONPATH

robot-enabled

Required: No

Default: False

Generate setting robot.python.env with buildout eggs for Robot Framework Language Server. Generate task Start Plone Test Server into tasks.json. Generate task Robot Framework: Launch Template into launch.json for Robot Framework Language Server.

Code repository:

https://github.com/nazrulworld/collective.recipe.vscode

Continuous Integration:

https://travis-ci.org/nazrulworld/collective.recipe.vscode

Issue Tracker:

https://github.com/nazrulworld/collective.recipe.vscode/issues

collective.recipe.vscode's People

Contributors

datakurre avatar djay avatar mrtango avatar nazrulworld avatar parruc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

collective.recipe.vscode's Issues

Linter disabling simply not working

Case 1

If you trying to disable any liner from buildout parts(options), like pylint-enabled = False. In the result there is no reflection but should be in settings "python.linting.pylintEnabled": false

Case 2

If you enable any linter first time, again try to disable from buildout parts (options), that's also not working it kept enabled permanently!

make eggs= optional

It would be nice if you can add the recipe to ~/.buildout/default.cfg and it will find all eggs without having to know anything about the buildout. This would mean the only thing needed to get vscode support is run a buildout without changing it.

I think this should be possible as I did something similar in collective.hostout. If the recipe installs itself as dependent on all other parts of the buildout it will run last. At that point all resolution is done. Buildout compiles a signature of each recipe based on what eggs it's dependent on. It should be possible to hook into that and read that list of eggs.

Question: How to configure VSCode properly?

Hi,

I need more information about configuring VSCode after installed this recipe. This is the relevant part of my develop.cfg:

[omelette]
recipe = collective.recipe.omelette
eggs = ${buildout:eggs}

[vscode]
recipe = collective.recipe.vscode
eggs = ${buildout:eggs}
pylint-enabled = True
autocomplete-use-omelette = True
generate-envfile = True

Within VSCode I connect to my Linux server using the Remote Explorer and cd into ~/plone/zeocluster/parts/omelette/ where I find all the eggs and also my own addons. I then change the Python interpreter to ~/plone/zeocluster/bin/zopepy and enable linting using pylint. It seems to work somehow but it is very slow. Pressing F12 on an import lasts up to a minute until it opens a new tab with the module I am looking for. Any idea to speed this up? Can I do something better here or did I something wrong?

Generate .env file for pylint

Pylint does not use python.autoComplete.extraPaths to decide if an import is valid or not.

microsoft/vscode-python#2791

Could be useful to generate a .env file containing PYTHONPATH env variable definition that adds same paths in python.autoComplete.extraPaths to the path

pep8 enabling configuration added even not mentioned in buildout

[vscode]
recipe = collective.recipe.vscode
eggs = ${instance:eggs}
flake8-enabled = True
flake8-path = ${buildout:directory}/bin/flake8
flake8-arg = --max-line-length 88
black-enabled = True

{'python.pythonPath': '/home/nazrul/www/python/CONTRIBUTIONS_FOLDER/collective.recipe.vscode/bin/python3', 'python.autoComplete.extraPaths': ['/tmp/eggs/egg1.egg', '/tmp/eggs/egg2.egg'], 'python.jediEnabled': True, 'python.linting.flake8Enabled': True, 'python.linting.flake8Path': '/fake/path/flake8', 'python.linting.pylintEnabled': True, 'python.linting.pep8Enabled': 'False', 'python.formatting.provider': 'black', 'python.formatting.blackPath': '/tmp/bin/black', 'python.formatting.blackArgs': ['--line-length', '88']}

install default launch.json and unittests

Perhaps detect recipes like zc.testrunner and zope2instance and come up with some default launch configurations for those.

Enabling unittest functionality using zc.testrunner would also be nice but doesn't seem there is currently a way to do this even though the vscode unittest runner can find zope tests - see microsoft/vscode-python#12779.

Transfer the project to GitHub collective organization?

Hi @nazrulworld ๐Ÿ‘‹๐Ÿพ

Given that you are already a member of https://github.com/collective would you be ok with transferring this project there? ๐Ÿคž๐Ÿพ

With GitHub being owned by Microsoft and VSCode being developed by them, we keep seeing more and more integration of the two.

Moreover a quick glance at Plone developers preferred code editor shows that VSCode is gaining more and more popularity ๐Ÿš€

It would be great if we have it there so more collaboration can happen ๐Ÿ˜„

don't ignore html files

This is a really nice extension, but it does a bit more than it should do.
One thing is, that when used vs code will hide all html files in the explorer.
That not helpful when you work on a theme ;).

remove pythonPath in settings.json and replace it with...?

It's no longer used and you get annoying warnings asking if you want to remove it from your settings.json. see https://visualstudiomagazine.com/articles/2020/05/14/vs-code-python.aspx

Maybe there is a way to write it into launch.json or .env or maybe .direnv? see https://code.visualstudio.com/docs/python/environments (note these docs still mention pythonPath so they are out of date)

Otherwise I think you have to set it yourself which is annoying. Unless someone makes a buildout extension.

Error with vscode during buildout

I've encountered a problem where an error during the buildout is thrown.

Updating vscode.
While:
  Updating vscode.
Error: Expecting property name enclosed in double quotes: line 6 column 5 (char 162)

In the end I noticed the additional comma in my .vscode/settings.json (after "editor.formatOnType": true). This comma leads to the error and if you remove it buildout will work again.

{
    "[python]": {
        "editor.defaultFormatter": "ms-python.black-formatter",
        "editor.formatOnSave": true,
        "editor.formatOnType": true,
    },
}

I don't know if this behavior is desired or not but I wanted to share this (& especially the solution).

Undocumented (but useful) isort

isort has his own configuration option but there is no trace in config. Not knowing it made me change the settings manually and find it overwrited on the next buildout

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.