未验证 提交 a306c47d 编写于 作者: F Frost Ming

add instruction about using PDM with Emacs

上级 6da22258
......@@ -177,3 +177,5 @@ can be run natively as [VSCode Tasks][vscode tasks].
[vscode tasks]: https://code.visualstudio.com/docs/editor/tasks
[pdm task provider]: https://marketplace.visualstudio.com/items?itemName=knowsuchagency.pdm-task-provider
[pdm scripts]: https://pdm.fming.dev/project/#run-scripts-in-isolated-environment
### [Seek for other IDEs or editors](usage/advanced.md#integrate-with-other-ide-or-editors)
......@@ -147,3 +147,45 @@ build-backend = "flit_core.buildapi"
```
PDM will call the correct backend when `pdm build`.
## Integrate with other IDE or editors
### Work with lsp-python-ms in Emacs
Below is a sample code snippet showing how to make PDM work with [lsp-python-ms](https://github.com/emacs-lsp/lsp-python-ms) in Emacs. Contributed by [@linw1995](https://github.com/pdm-project/pdm/discussions/372#discussion-3303501).
```emacs-lisp
;; TODO: Cache result
(defun linw1995/pdm-get-python-executable (&optional dir)
(let ((pdm-get-python-cmd "pdm info --python"))
(string-trim
(shell-command-to-string
(if dir
(concat "cd "
dir
" && "
pdm-get-python-cmd)
pdm-get-python-cmd)))))
(defun linw1995/pdm-get-packages-path (&optional dir)
(let ((pdm-get-packages-cmd "pdm info --packages"))
(concat (string-trim
(shell-command-to-string
(if dir
(concat "cd "
dir
" && "
pdm-get-packages-cmd)
pdm-get-packages-cmd)))
"/lib")))
(use-package lsp-python-ms
:ensure t
:init (setq lsp-python-ms-auto-install-server t)
:hook (python-mode
. (lambda ()
(setq lsp-python-ms-python-executable (linw1995/pdm-get-python-executable))
(setq lsp-python-ms-extra-paths (vector (linw1995/pdm-get-packages-path)))
(require 'lsp-python-ms)
(lsp)))) ; or lsp-deferred
```
Add zsh completion script
Add hand-written zsh completion script.
Move `dev-dependencies`, `includes`, `excludes` and `package-dir` out from `[project]` table to `[tool.pdm]` table. The migration will be done automaticaly if old format is detected.
`dev-dependencies` is now a table of dependencies groups, where key is the group name and value is an array of dependencies. These dependencies won't appear in the distribution's metadata. `dev-depedencies` of the old format will turn into `dev` group under `dev-dependencies`.
Add a special value `:all` given to `-s/--section` to refer to all sections under the same species.
Adjust `add`, `sync`, `install`, `remove` and `update` to support the new `dev-dependencies` groups. Old behavior will be kept the same.
- Move `dev-dependencies`, `includes`, `excludes` and `package-dir` out from `[project]` table to `[tool.pdm]` table.
- The migration will be done automaticaly if old format is detected.
- dev-dependencies is now a table of dependencies groups, where key is the group name and value is an array of dependencies. These dependencies won't appear in the distribution's metadata.
- dev-depedencies of the old format will turn into `dev` group under `dev-dependencies`.
- Add a special value `:all` given to `-s/--section` to refer to all sections under the same species.
- Adjust `add`, `sync`, `install`, `remove` and `update` to support the new `dev-dependencies` groups. Old behavior will be kept the same.
Add type annotations into untyped functions to start using mypy
Add type annotations into untyped functions to start using mypy.
Remove the support of project path following `-g/--global`. One should use `-g -p <project_path>` for that purpose.
Remove the support of project path following `-g/--global` that was deprecated in `1.4.0`. One should use `-g -p <project_path>` for that purpose.
Support non-interactive `init` command via `-n/--non-interactive` options. No question will be asked in this mode.
Support non-interactive `init` command via `-n/--non-interactive` option. No question will be asked in this mode.
Python runs in isolated mode via subprocess to avoid importing user packages
Python is now run in isolated mode via subprocess to avoid accidentally importing user packages.
Add instructions of how to integrate PDM with Emacs, contributed by @linw1995.
Show project packages(PEP 582) in the output of `pdm info`, also add an option `--packages` to show that value only.
Show project packages path(PEP 582) in the output of `pdm info`, also add an option `--packages` to show that value only.
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册