minimal adjustments
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-python / Readme.md
1 # coc-python
2
3 Python extension for [coc.nvim](https://github.com/neoclide/coc.nvim), fork of
4 [vscode-python](https://github.com/Microsoft/vscode-python) from commit
5 [16899f6b13477786212f29eb3cb7a459b5ebf0a4](https://github.com/microsoft/vscode-python/commit/16899f6b13477786212f29eb3cb7a459b5ebf0a4).
6
7 Basic working, but still **W.I.P**.
8
9 Built with rich support for the Python language (for all actively supported
10 versions of the language: 2.7, >=3.5), including features such as linting,
11 IntelliSense, code navigation, code formatting, refactoring, snippets, and more!
12
13 [关于 VS Code 中 python 的智障补全的解决方案,以 pytorch 为例](https://zhuanlan.zhihu.com/p/69317932)
14
15 ## Install
16
17 In your vim/neovim, run command:
18
19 ```
20 :CocInstall coc-python
21 ```
22
23 ## Get start
24
25 - To use Microsoft Python Language Server, add `"python.jediEnabled": false` in your settings file, coc-python would download latest stable MPLS for you.
26 - Checkout `:h coc-status` to have statusline integration with coc.nvim, so you can get download status.
27 - When jedi is not enabled, the language server will be downloaded. Make sure you have coc statusline integrated, check out `:h coc-status`.
28 - [Install a linter](https://code.visualstudio.com/docs/python/linting) to get errors and warnings -- you can further customize linting rules to fit your needs.
29 - Select your preferred Python interpreter/version/environment using the `python.setInterpreter` command.
30   - **Note** the autoselected python interpreter could be wrong, make sure select the right one for you.
31 - Install `ctags` for Workspace Symbols, from [here](http://ctags.sourceforge.net/), or using `brew install ctags` on macOS.
32
33 ## Useful commands
34
35 Open the Command List (use `:CocCommand` command in vim) and type in one of the following commands:
36
37 | Command                              | Description                                                                              |
38 | ------------------------------------ | ---------------------------------------------------------------------------------------- |
39 | `python.setInterpreter`              | Switch between Python interpreters, versions, and environments.                          |
40 | `python.startREPL`                   | Start an interactive Python REPL using the selected interpreter in the VS Code terminal. |
41 | `python.execInTerminal`              | Runs the active Python file in the VS Code terminal.                                     |
42 | `python.setLinter`                   | Switch from PyLint to flake8 or other supported linters.                                 |
43 | `python.upgradePythonLanguageServer` | Upgrade MPLS to latest daily version.                                                    |
44
45 To see all available Python commands, open the Command Palette and type `Python`.
46
47 **Note:** to enable multiple linters, edit the configuration file instead of use `python.setLinter` command.
48
49 ## Features
50
51 Except from `test`, `debug` and `datascience` features of [vscode-python](https://github.com/Microsoft/vscode-python).
52
53 - IDE-like features
54   - Automatic indenting
55   - Code navigation ("Go to", "Find all" references)
56   - Code definition (Peek and hover definition, View signatures)
57   - Rename refactoring
58   - Sorting import statements (use the `Python: Sort Imports` command)
59 - Intellisense and autocomplete (including PEP 484 and PEP 526 support)
60   - Ability to include custom module paths (e.g. include paths for libraries like Google App Engine, etc.; use the setting `python.autoComplete.extraPaths = []`)
61 - Code formatting
62   - Auto formatting of code upon saving changes (default to 'Off')
63   - Use either [yapf](https://pypi.org/project/yapf/), [autopep8](https://pypi.org/project/autopep8/), or [Black](https://pypi.org/project/black/) for code formatting (defaults to autopep8)
64 - Linting
65   - Support for multiple linters with custom settings (default is [Pylint](https://pypi.org/project/pylint/), but [Prospector](https://pypi.org/project/prospector/), [Flake8](https://pypi.org/project/flake8/), [pylama](https://pypi.org/project/pylama/), [pydocstyle](https://pypi.org/project/pydocstyle/), and [mypy](https://pypi.org/project/mypy/) are also supported)
66 - Snippets
67 - Miscellaneous
68   - Running a file or selected text in python terminal
69   - Automatic activation of environments in the terminal
70 - Refactoring
71   - Rename refactorings
72   - Extract variable refactorings
73   - Extract method refactorings
74   - Sort imports
75
76 ## Options
77
78 - `python.autoComplete.addBrackets`:Automatically add brackets for functions, not work for MPLS., default: `false`
79 - `python.autoComplete.extraPaths`:List of paths to libraries and the like that need to be imported by auto complete engine. E.g. when using Google App SDK, the paths are not in system path, hence need to be added into this list., default: `[]`
80 - `python.autoComplete.showAdvancedMembers`:Controls appearance of methods with double underscores in the completion list., default: `true`
81 - `python.autoComplete.typeshedPaths`:Specifies paths to local typeshed repository clone(s) for the Python language server., default: `[]`
82 - `python.autoUpdateLanguageServer`:Automatically update the language server., default: `true`
83 - `python.disableInstallationCheck`:Whether to check if Python is installed (also warn when using the macOS-installed Python)., default: `false`
84 - `python.envFile`:Absolute path to a file containing environment variable definitions., default: `"${workspaceFolder}/.env"`
85 - `python.trace.server`:Trace level of tsserver, default: `"off"`
86 - `python.formatting.autopep8Args`:Arguments passed in. Each argument is a separate item in the array., default: `[]`
87 - `python.formatting.autopep8Path`:Path to autopep8, you can use a custom version of autopep8 by modifying this setting to include the full path., default: `"autopep8"`
88 - `python.formatting.provider`:Provider for formatting. Possible options include 'autopep8', 'black', and 'yapf'., default: `"autopep8"`
89 - `python.formatting.blackArgs`:Arguments passed in. Each argument is a separate item in the array., default: `[]`
90 - `python.formatting.blackPath`:Path to Black, you can use a custom version of Black by modifying this setting to include the full path., default: `"black"`
91 - `python.formatting.yapfArgs`:Arguments passed in. Each argument is a separate item in the array., default: `[]`
92 - `python.formatting.yapfPath`:Path to yapf, you can use a custom version of yapf by modifying this setting to include the full path., default: `"yapf"`
93 - `python.globalModuleInstallation`:Whether to install Python modules globally when not using an environment., default: `false`
94 - `python.jediEnabled`:Enables Jedi as IntelliSense engine instead of Microsoft Python Analysis Engine., default: `true`
95 - `python.jediMemoryLimit`:Memory limit for the Jedi completion engine in megabytes. Zero (default) means 1024 MB. -1 means unlimited (disable memory limit check), default: `0`
96 - `python.jediPath`:Path to directory containing the Jedi library (this path will contain the 'Jedi' sub directory)., default: `""`
97 - `python.analysis.diagnosticEnabled`: Enable diagnostic support of language server, default: `true`
98 - `python.analysis.openFilesOnly`:Only show errors and warnings for open files rather than for the entire workspace., default: `true`
99 - `python.analysis.diagnosticPublishDelay`:Delay before diagnostic messages are transferred to the problems list (in milliseconds)., default: `1000`
100 - `python.analysis.typeshedPaths`:Paths to look for typeshed modules., default: `[]`
101 - `python.analysis.errors`:List of diagnostics messages to be shown as errors., default: `[]`
102 - `python.analysis.warnings`:List of diagnostics messages to be shown as warnings., default: `[]`
103 - `python.analysis.information`:List of diagnostics messages to be shown as information., default: `[]`
104 - `python.analysis.disabled`:List of suppressed diagnostic messages., default: `[]`
105 - `python.analysis.logLevel`:Defines type of log messages language server writes into the output window., default: `"Error"`
106 - `python.analysis.symbolsHierarchyDepthLimit`:Limits depth of the symbol tree in the document outline., default: `10`
107 - `python.linting.enabled`:Whether to lint Python files., default: `true`
108 - `python.linting.flake8Args`:Arguments passed in. Each argument is a separate item in the array., default: `[]`
109 - `python.linting.flake8CategorySeverity.E`:Severity of Flake8 message type 'E'., default: `"Error"`
110 - `python.linting.flake8CategorySeverity.F`:Severity of Flake8 message type 'F'., default: `"Error"`
111 - `python.linting.flake8CategorySeverity.W`:Severity of Flake8 message type 'W'., default: `"Warning"`
112 - `python.linting.flake8Enabled`:Whether to lint Python files using flake8, default: `false`
113 - `python.linting.flake8Path`:Path to flake8, you can use a custom version of flake8 by modifying this setting to include the full path., default: `"flake8"`
114 - `python.linting.ignorePatterns`:Patterns used to exclude files or folders from being linted., default: `[".vscode/*.py","**/site-packages/**/*.py"]`
115 - `python.linting.lintOnSave`:Whether to lint Python files when saved., default: `true`
116 - `python.linting.maxNumberOfProblems`:Controls the maximum number of problems produced by the server., default: `100`
117 - `python.linting.banditArgs`:Arguments passed in. Each argument is a separate item in the array., default: `[]`
118 - `python.linting.banditEnabled`:Whether to lint Python files using bandit., default: `false`
119 - `python.linting.banditPath`:Path to bandit, you can use a custom version of bandit by modifying this setting to include the full path., default: `"bandit"`
120 - `python.linting.mypyArgs`:Arguments passed in. Each argument is a separate item in the array., default: `["--ignore-missing-imports","--follow-imports=silent","--show-column-numbers"]`
121 - `python.linting.mypyCategorySeverity.error`:Severity of Mypy message type 'Error'., default: `"Error"`
122 - `python.linting.mypyCategorySeverity.note`:Severity of Mypy message type 'Note'., default: `"Information"`
123 - `python.linting.mypyEnabled`:Whether to lint Python files using mypy., default: `false`
124 - `python.linting.mypyPath`:Path to mypy, you can use a custom version of mypy by modifying this setting to include the full path., default: `"mypy"`
125 - `python.linting.pep8Args`:Arguments passed in. Each argument is a separate item in the array., default: `[]`
126 - `python.linting.pep8CategorySeverity.E`:Severity of Pep8 message type 'E'., default: `"Error"`
127 - `python.linting.pep8CategorySeverity.W`:Severity of Pep8 message type 'W'., default: `"Warning"`
128 - `python.linting.pep8Enabled`:Whether to lint Python files using pep8, default: `false`
129 - `python.linting.pep8Path`:Path to pep8, you can use a custom version of pep8 by modifying this setting to include the full path., default: `"pep8"`
130 - `python.linting.prospectorArgs`:Arguments passed in. Each argument is a separate item in the array., default: `[]`
131 - `python.linting.prospectorEnabled`:Whether to lint Python files using prospector., default: `false`
132 - `python.linting.prospectorPath`:Path to Prospector, you can use a custom version of prospector by modifying this setting to include the full path., default: `"prospector"`
133 - `python.linting.pydocstyleArgs`:Arguments passed in. Each argument is a separate item in the array., default: `[]`
134 - `python.linting.pydocstyleEnabled`:Whether to lint Python files using pydocstyle, default: `false`
135 - `python.linting.pydocstylePath`:Path to pydocstyle, you can use a custom version of pydocstyle by modifying this setting to include the full path., default: `"pydocstyle"`
136 - `python.linting.pylamaArgs`:Arguments passed in. Each argument is a separate item in the array., default: `[]`
137 - `python.linting.pylamaEnabled`:Whether to lint Python files using pylama., default: `false`
138 - `python.linting.pylamaPath`:Path to pylama, you can use a custom version of pylama by modifying this setting to include the full path., default: `"pylama"`
139 - `python.linting.pylintArgs`:Arguments passed in. Each argument is a separate item in the array., default: `[]`
140 - `python.linting.pylintCategorySeverity.convention`:Severity of Pylint message type 'Convention/C'., default: `"Information"`
141 - `python.linting.pylintCategorySeverity.error`:Severity of Pylint message type 'Error/E'., default: `"Error"`
142 - `python.linting.pylintCategorySeverity.fatal`:Severity of Pylint message type 'Fatal/F'., default: `"Error"`
143 - `python.linting.pylintCategorySeverity.refactor`:Severity of Pylint message type 'Refactor/R'., default: `"Hint"`
144 - `python.linting.pylintCategorySeverity.warning`:Severity of Pylint message type 'Warning/W'., default: `"Warning"`
145 - `python.linting.pylintEnabled`:Whether to lint Python files using pylint., default: `true`
146 - `python.linting.pylintPath`:Path to Pylint, you can use a custom version of pylint by modifying this setting to include the full path., default: `"pylint"`
147 - `python.linting.pylintUseMinimalCheckers`:Whether to run Pylint with minimal set of rules., default: `true`
148 - `python.pythonPath`:Path to Python, you can use a custom version of Python by modifying this setting to include the full path., default: `"python"`
149 - `python.condaPath`:Path to the conda executable to use for activation (version 4.4+)., default: `""`
150 - `python.pipenvPath`:Path to the pipenv executable to use for activation., default: `"pipenv"`
151 - `python.poetryPath`:Path to the poetry executable., default: `"poetry"`
152 - `python.sortImports.args`:Arguments passed in. Each argument is a separate item in the array., default: `[]`
153 - `python.sortImports.path`:Path to isort script, default using inner version, default: `""`
154 - `python.terminal.activateEnvironment`:Activate Python Environment in Terminal created using the Extension., default: `true`
155 - `python.terminal.executeInFileDir`:When executing a file in the terminal, whether to use execute in the file's directory, instead of the current open folder., default: `false`
156 - `python.terminal.launchArgs`:Python launch arguments to use when executing a file in the terminal., default: `[]`
157 - `python.venvFolders`:Folders in your home directory to look into for virtual environments., default: `["envs",".pyenv",".direnv"]`
158 - `python.venvPath`:Path to folder with a list of Virtual Environments (e.g. ~/.pyenv, ~/Envs, ~/.virtualenvs)., default: `""`
159 - `python.workspaceSymbols.ctagsPath`:Fully qualified path to the ctags executable (else leave as ctags, assuming it is in current path)., default: `"ctags"`
160 - `python.workspaceSymbols.enabled`:Set to 'false' to disable Workspace Symbol provider using ctags., default: `true`
161 - `python.workspaceSymbols.exclusionPatterns`:Pattern used to exclude files and folders from ctags See http://ctags.sourceforge.net/ctags.html., default: `["**/site-packages/**"]`
162 - `python.workspaceSymbols.rebuildOnFileSave`:Whether to re-build the tags file on when changes made to python files are saved., default: `true`
163 - `python.workspaceSymbols.rebuildOnStart`:Whether to re-build the tags file on start (defaults to true)., default: `true`
164 - `python.workspaceSymbols.tagFilePath`:Fully qualified path to tag file (exuberant ctags file), used to provide workspace symbols., default: `"${workspaceFolder}/.vscode/tags"`
165
166 ## F.A.Q
167
168 **Q:** `"python.linting.enabled": false` not work when jedi disabled.
169
170 **A:** That setting only works when python files are used, not MPLS, you have to use `"python.analysis.diagnosticEnabled": false` to disable diagnostics from language server.
171
172 **Q:** MPLS using too much memory and CPU.
173
174 **A:** It's bug of MPLS, checkout https://github.com/Microsoft/python-language-server/issues/832.
175
176 **Q:** MPLS doesn't work with unsaved buffer.
177
178 **A:** Yes, it's not. You have to save your buffer to make it work.
179
180 **Q:** Get unable to find document error from MPLS.
181
182 **A:** Some filename would cause MPLS throw this error.
183
184 ## License
185
186 MIT