You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Thanks to minimal for getting me started, I think I've finally gotten to a python IDE setup that I am happy with.
Requirements:
In python buffers have well-behaved completions. Corfu does this nicely.
Run python subprocesses. Be able to have completions here. Be able to use ipython, so things like _1 will work.
Be able to send python buffer, or region to subprocess.
pyvenv works
I had tried many ways to get ipython to work with emacs before, but results have been buggy until now using vterm. Using vterm is still a bit buggy but I think I can live with it.
Here is the relevant parts of my setup
(use-package corfu
:ensure t
:commands (corfu-mode global-corfu-mode)
:hook ((prog-mode . corfu-mode)
(shell-mode . corfu-mode)
(eshell-mode . corfu-mode))
:custom
;; Hide commands in M-x which do not apply to the current mode.
(read-extended-command-predicate #'command-completion-default-include-p)
;; Disable Ispell completion function. As an alternative try `cape-dict'.
(text-mode-ispell-word-completion nil)
(tab-always-indent 'complete)
;; Enable Corfu
:config
(global-corfu-mode))
;; Enable Corfu auto popup
(setq corfu-auto t)
;; Cape, or Completion At Point Extensions, extends the capabilities of
;; in-buffer completion. It integrates with Corfu or the default completion UI,
;; by providing additional backends through completion-at-point-functions.
(use-package cape
:ensure t
:commands (cape-dabbrev cape-file cape-elisp-block)
:bind ("C-c p" . cape-prefix-map)
:init
;; Add to the global default value of `completion-at-point-functions' which is
;; used by `completion-at-point'.
(add-hook 'completion-at-point-functions #'cape-dabbrev)
(add-hook 'completion-at-point-functions #'cape-file)
(add-hook 'completion-at-point-functions #'cape-elisp-block))
(use-package highlight-indent-guides)
(add-hook 'python-mode-hook #'(lambda ()(define-key python-mode-map (kbd "C-c #") 'comment-region)))
(add-hook 'python-mode-hook 'highlight-indent-guides-mode)
(setq highlight-indent-guides-method 'column)
(use-package vterm
:ensure t)
(use-package pyvenv
:ensure t
:config
(pyvenv-mode 1))
(use-package py-vterm-interaction
:ensure t
:hook ((python-mode . py-vterm-interaction-mode)
(python-ts-mode . py-vterm-interaction-mode))
:init
(setq-default
py-vterm-interaction-repl-program "ipython"
py-vterm-interaction-silent-cells t)
:config
(with-eval-after-load 'vterm
(define-key vterm-mode-map (kbd "M-p") (lambda () (interactive) (vterm-send-key "<up>")))
(define-key vterm-mode-map (kbd "M-n") (lambda () (interactive) (vterm-send-key "<down>")))))
;; Set up the Language Server Protocol (LSP) servers using Eglot.
(use-package eglot
:ensure nil
:commands (eglot-ensure
eglot-rename
eglot-format-buffer))
;; Configure Eglot to enable or disable certain options for the pylsp server
;; in Python development. (Note that a third-party tool,
;; https://github.com/python-lsp/python-lsp-server, must be installed),
(add-hook 'python-mode-hook #'eglot-ensure)
(add-hook 'python-ts-mode-hook #'eglot-ensure)
(setq-default eglot-workspace-configuration
`(:pylsp (:plugins
(;; Fix imports and syntax using `eglot-format-buffer`
:isort (:enabled t)
:autopep8 (:enabled t)
;; Syntax checkers (works with Flymake)
:pylint (:enabled t
:args ["--disable=C0411,C0413"])
:pycodestyle (:enabled t
:ignore ["E501" ;; line too long
"W291" ;; trailing whitespace
"E203" ;; whitespace before ‘:’
"E402" ;; module import
"E302" ;; blank link
"E211" ;; whitespace
"E305" ;; blank
]
:maxLineLength 180)
:flake8 (:enabled :json-false)
:pyflakes (:enabled :json-false)
:pydocstyle (:enabled t)
:mccabe (:enabled t)
:yapf (:enabled :json-false)
:rope_autoimport (:enabled :json-false)))))
;; Tree-sitter in Emacs is an incremental parsing system introduced in Emacs 29
;; that provides precise, high-performance syntax highlighting. It supports a
;; broad set of programming languages, including Bash, C, C++, C#, CMake, CSS,
;; Dockerfile, Go, Java, JavaScript, JSON, Python, Rust, TOML, TypeScript, YAML,
;; Elisp, Lua, Markdown, and many others.
(use-package treesit-auto
:ensure t
:custom
(treesit-auto-install 'prompt)
:config
(treesit-auto-add-to-auto-mode-alist 'all)
(global-treesit-auto-mode))
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Thanks to minimal for getting me started, I think I've finally gotten to a python IDE setup that I am happy with.
Requirements:
I had tried many ways to get ipython to work with emacs before, but results have been buggy until now using vterm. Using vterm is still a bit buggy but I think I can live with it.
Here is the relevant parts of my setup
Beta Was this translation helpful? Give feedback.
All reactions