• Stars
    star
    1,195
  • Rank 39,145 (Top 0.8 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created about 5 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Pyright extension for coc.nvim

coc-pyright

GitHub Sponsors Patreon donate button PayPal donate button

Pyright extension for coc.nvim, with additional features:

  • semanticTokens highlighting!
  • inlayHints supports
  • codeActions to add imports, ignore typing check, run tests and more
  • linting with bandit, flake8, mypy, ruff, prospector, pycodestyle, pydocstyle, pyflakes, pylama, pylint, pytype
  • formatting with yapf, black, autopep8, darker, blackd, pyink
  • testing with unittest or pytest, supports codeLens
  • sort imports with ruff, isort and pyright
  • extract method and variables with rope

10

Install

:CocInstall coc-pyright

Note: Pyright may not work as expected if can't detect project root correctly, check #521 and Using workspaceFolders in coc.nvim.

Commands

  • python.runLinting: Run linting
  • python.sortImports: Sort imports by isort
  • pyright.version: Show the currently used Pyright version
  • pyright.organizeimports: Organize imports by Pyright
  • pyright.restartserver: This command forces the type checker to discard all of its cached type information and restart analysis. It is useful in cases where new type stubs or libraries have been installed.
  • pyright.createtypestub: Creates Type Stubs with given module name, for example :CocCommand pyright.createtypestub numpy
  • pyright.fileTest: Run test for current test file
  • pyright.singleTest: Run test for single nearest test

Configurations

These configurations are used by coc-pyright, you need to set them in your coc-settings.json.

Configuration Description Default
pyright.enable Enable coc-pyright extension true
python.analysis.autoImportCompletions Determines whether pyright offers auto-import completions true
python.analysis.autoSearchPaths Automatically add common search paths like 'src' true
python.analysis.diagnosticMode Analyzes and reports errors for open only or all files in workspace openFilesOnly
python.analysis.stubPath Path to directory containing custom type stub files typings
python.analysis.typeshedPaths Paths to look for typeshed modules []
python.analysis.diagnosticSeverityOverrides Override the severity levels for individual diagnostics {}
python.analysis.typeCheckingMode Defines the default rule set for type checking basic
python.analysis.useLibraryCodeForTypes Use library implementations to extract type information true
python.pythonPath Path to Python python
python.venvPath Path to folder with a list of Virtual Environments ""
python.formatting.provider Provider for formatting autopep8
python.formatting.blackPath Custom path to black black
python.formatting.blackArgs Arguments passed to black []
python.formatting.darkerPath Custom path to darker darker
python.formatting.darkerArgs Arguments passed to darker []
python.formatting.pyinkPath Custom path to pyink pyink
python.formatting.pyinkArgs Arguments passed to pyink []
python.formatting.blackdPath Custom path to blackd blackd
python.formatting.blackdHTTPURL Custom blackd server url ""
python.formatting.blackdHTTPHeaders Custom blackd request headers {}
python.formatting.yapfPath Custom path to yapf yapf
python.formatting.yapfArgs Arguments passed to yapf []
python.formatting.autopep8Path Custom path to autopep8 autopep8
python.formatting.autopep8Args Arguments passed to autopep8 []
python.linting.enabled Whether to lint Python files with external linters true
python.linting.flake8Enabled Whether to lint with flake8 false
python.linting.banditEnabled Whether to lint with bandit false
python.linting.mypyEnabled Whether to lint with mypy false
python.linting.ruffEnabled Whether to lint with ruff false
python.linting.pytypeEnabled Whether to lint with pytype false
python.linting.pycodestyleEnabled Whether to lint with pycodestyle false
python.linting.prospectorEnabled Whether to lint with prospector false
python.linting.pydocstyleEnabled Whether to lint with pydocstyle false
python.linting.pylamaEnabled Whether to lint with pylama false
python.linting.pylintEnabled Whether to lint with pylint false
python.linting.pyflakesEnabled Whether to lint with pyflakes false
python.sortImports.path Path to isort script, default using inner version ''
python.sortImports.args Arguments passed to isort []
pyright.server Custom pyright-langserver path ''
pyright.disableCompletion Disables completion from Pyright false
pyright.disableDiagnostics Disable diagnostics from Pyright false
pyright.disableDocumentation Disables hover documentation from Pyright false
pyright.disableProgressNotifications Disable the initialization and workdone progress notifications false
pyright.completion.importSupport Enable python-import completion source support true
pyright.completion.snippetSupport Enable completion snippets support true
pyright.organizeimports.provider Organize imports provider, pyright, ruff or isort pyright
pyright.inlayHints.functionReturnTypes Enable inlay hints for function return types true
pyright.inlayHints.variableTypes Enable inlay hints for variable types true
pyright.testing.provider Provider for testing, supports unittest and pytest unittest
pyright.testing.unittestArgs Arguments passed to unittest []
pyright.testing.pytestArgs Arguments passed to pytest []

Additional configuration options can be found in package.json.

pyrightconfig.json

Pyright supports pyrightconfig.json that provide granular control over settings.

Python typing and stub files

To provide best experience, Pyright requires packages to be type annotated and/or have stub files. The Python community is currently in a transition phase where package authors are actively looking to provide that. Meanwhile, stub files for well-known packages may also be obtained from 3rd party, for example:

Conda setup

  1. Create the following file:

    #!/bin/bash
    python "$@"
  2. Make it executable: chmod +x $path

  3. Set python.pythonPath in your coc-settings.json: "python.pythonPath": "<PUT PATH HERE>"

  4. Activate the environment before starting vim

This way python from your currently activated environment will be used

My Workflow with Pyright

  1. create venv in project: python3 -m venv .venv
  2. source .venv/bin/activate
  3. install modules with pip and work with Pyright
  4. deactivate

License

MIT


This extension is built with create-coc-extension

More Repositories

1

coc-rust-analyzer

rust-analyzer extension for coc.nvim
TypeScript
1,049
star
2

create-coc-extension

Create a coc extension from command line
TypeScript
199
star
3

telescope-coc.nvim

coc.nvim integration for telescope.nvim
Lua
169
star
4

coc-markdownlint

markdownlint extension for coc.nvim
TypeScript
157
star
5

coc-deno

Deno extension for coc.nvim
TypeScript
147
star
6

coc-react-refactor

React refactor extension for coc.nvim
TypeScript
121
star
7

coc-sql

SQL extension for coc.nvim
TypeScript
114
star
8

coc-texlab

TexLab extension for coc.nvim
TypeScript
110
star
9

coc-styled-components

Styled component for coc.nvim as a tsserver plugin
TypeScript
92
star
10

init.vim

Neovim config of @fannheyward.
Vim Script
77
star
11

coc-julia

Julia extension for coc.nvim
TypeScript
77
star
12

coc-xml

XML extension for coc.nvim
TypeScript
54
star
13

coc-ci

支持中文分词的 w/b 移动
TypeScript
36
star
14

coc-postfix

Postfix completion for Vim/Neovim
TypeScript
34
star
15

coc-rome

Rome extension for coc.nvim
TypeScript
32
star
16

coc-terminal

Toggle terminal with coc.nvim
TypeScript
25
star
17

coc-nextword

nextword extension for coc.nvim
JavaScript
24
star
18

coc-ecdict

ECDICT extension for coc.nvim
TypeScript
19
star
19

coc-docthis

JSDoc extension for coc.nvim that generates detailed JSDoc comments for TypeScript/JavaScript files.
TypeScript
16
star
20

WeiboEngine

新浪微博 SDK,支持 OAuth 2.0 认证,支持 ARC。
Objective-C
12
star
21

fannheyward.github.io

Pages of @fannheyward.
CSS
6
star
22

coc-lit-html

coc.nvim extension that provides lit-html support with typescript-lit-html-plugin
TypeScript
4
star
23

coc-mocword

Mocword extension for coc.nvim
TypeScript
4
star
24

coc-biome

Biome extension for coc.nvim
TypeScript
4
star
25

coc-lines

Lines source for coc.nvim
TypeScript
3
star
26

telescope-maple.nvim

maple integration for telescope.nvim
Lua
3
star
27

pre.pages

My GitHub page.
1
star
28

ip

Go
1
star