reddit / emacs

Help for getting started with lsp-mode

blimbu1 · 2022-10-14 14:53
Hi, I am trying to use emacs for python IDE. I have installed pyright and lsp-pyright. Is there any docs/video on getting started. I want features similar to vscode such as class definition, jumping into class code and suggestions/help for code completion. Many thanks.
NoisyFrequency · 2022-10-14 16:02
My config: (use-package python :ensure t :defer t :delight "Py" :config ;; Remove guess indent python message (setq python-indent-guess-indent-offset-verbose nil)) ;; Hide the modeline for inferior python processes [OPTIONAL] (use-package hide-mode-line :ensure t :defer t :hook (python-mode . hide-mode-line-mode)) ;; Main pkg for Python support, requires LSP-mode (use-package lsp-pyright :ensure t :defer t :custom (lsp-pyright-disable-language-service nil) (lsp-pyright-disable-organize-imports nil) (lsp-pyright-auto-import-completions t) (lsp-pyright-use-library-code-for-types t) (lsp-completion-enable t) :hook ((python-mode . (lambda () (poetry-tracking-mode) (require 'lsp-pyright) (lsp-deferred))))) ;; uses the right venv when created with poetry [OPTIONAL] (use-package poetry :ensure t :defer t :config (setq poetry-tracking-strategy 'switch-buffer)) ;; Buffer formatting on save [OPTIONAL] (use-package blacken :ensure t :defer t :custom (blacken-allow-py36 t) (blacken-skip-string-normalization t) :hook (python-mode . blacken-mode)) ;; numpy docstring for python [OPTIONAL] (use-package numpydoc :ensure t :defer t :custom (numpydoc-insert-examples-block nil) (numpydoc-template-long nil) :bind (:map python-mode-map ("C-c C-n" . numpydoc-generate))) ;; Syntax highlighting [OPTIONAL] (use-package tree-sitter :ensure t :defer t :delight " tree" :hook (python-mode . (lambda () (tree-sitter-mode) (tree-sitter-hl-mode))) (use-package tree-sitter-langs :ensure t :defer t) ;;;; Completion (use-package corfu :ensure t ;; Optional customizations :custom (corfu-cycle t) ;; Enable cycling for `corfu-next/previous' (corfu-auto t) ;; Enable auto completion (corfu-separator ?\s) ;; Orderless field separator (corfu-quit-at-boundary t) ;; Never quit at completion boundary (corfu-quit-no-match t) ;; Never quit, even if there is no match (corfu-preview-current nil) ;; Disable current candidate preview (corfu-preselect-first nil) ;; Disable candidate preselection (corfu-on-exact-match nil) ;; Configure handling of exact matches (corfu-echo-documentation nil) ;; Disable documentation in the echo area (corfu-scroll-margin 5) ;; Use scroll margin ;; Recommended: Enable Corfu globally. ;; This is recommended since Dabbrev can be used globally (M-/). ;; See also `corfu-excluded-modes'. :init (global-corfu-mode)) ;;; Enhances completion at point see https://github.com/minad/cape (use-package cape :ensure t)
yyoncho · 2022-10-14 18:36
You may check System Crafters tutorials on youtube.