Skip to main content
;; Define and load custom.el file
(setq custom-file (expand-file-name "custom.el" user-emacs-directory))
(when (file-exists-p custom-file)
  (load custom-file))

;; Modify package repositories
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)

;; Load and activate Emacs packages
(package-initialize)

;; Install use-package if it's not installed
(unless (package-installed-p 'use-package)
  (package-refresh-contents)
  (package-install 'use-package))

;; Load use-package
(require 'use-package)
(setq use-package-hook-name-suffix nil) ;; Do not append text to the name of hooks mentioned by :hook

;; Load use-package-ensure
;; Support for :ensure and :pin keywords in use-package declarations
(require 'use-package-ensure)
(setq use-package-always-ensure t)

;; exec-path-from-shell
(use-package exec-path-from-shell
  :ensure t
  :if (eq system-type 'darwin)
  :custom
  (exec-path-from-shell-variables
   '("PATH" "MANPATH" "XDG_CONFIG_HOME" "WORKON_HOME" "LSP_USE_PLISTS" "PYTHONPATH" "IPYTHONDIR" "MPLCONFIGDIR"))
  (exec-path-from-shell-arguments nil)
  :config
  ;; (setenv "PKG_CONFIG_PATH" "/usr/local/Cellar/zlib/1.2.11/lib/pkgconfig:/usr/local/lib/pkgconfig"))
  (exec-path-from-shell-initialize))

;; Helm
;; Input completion
(use-package helm
  :ensure t
  :init
  (helm-mode 1)
  (require 'helm-config)
  :bind
  ;; ("C-c i"   . helm-imenu) ;; Select document heading
  ("C-x b"   . helm-mini) ;; Select buffers
  ("C-x C-f" . helm-find-files) ;; Open or create files
  ("C-x C-r" . helm-recentf) ;; Select recently saved files
  ("M-x"     . helm-M-x) ;; Evaluate functions
  ("M-y"     . helm-show-kill-ring) ;; Show the kill ring
  (:map helm-map
    ("<tab>" . helm-execute-persistent-action)
    ("C-z" . helm-select-action)))

;; which-key
;; Input completion
(use-package which-key
  :ensure t
  :custom
  (which-key-idle-delay 0.5)
  (which-key-idle-secondary-delay 0.5)
  :config
  (which-key-mode 1)
  (which-key-setup-side-window-bottom))

;; Company
;; Text completion
(use-package company
  :ensure t
  :custom
  (company-idle-delay 0.0)
  (company-minimum-prefix-length 4)
  (company-selection-wrap-around t)
  :hook
  ((text-mode-hook . company-mode)
   (prog-mode-hook . company-mode))
  :bind
  (:map company-active-map
    ("<tab>" . nil)
    ("TAB" . nil)
    ("M-<tab>" . company-complete-common-or-cycle)
    ("M-<tab>" . company-complete-selection)))

;; Flyspell
;; Spell checking for text (requires aspell)
(use-package flyspell
  :ensure t
  :init
  (setq ispell-program-name "aspell")
  :hook
  ((text-mode-hook . flyspell-mode)
   (prog-mode-hook . flyspell-prog-mode))
  :bind
  ("<f7>" . flyspell-word)
  ("M-<f7>" . flyspell-buffer))

;; Flycheck
;; Spell checking for code
(use-package flycheck
  :ensure t
  :init
  (setq flycheck-highlighting-mode 'symbols
    flycheck-indication-mode 'left-fringe
    flycheck-standard-error-navigation t)
  :hook
  (prog-mode-hook . flycheck-mode))

;; LSP Mode
;; Language Server Protocol Support
(use-package lsp-mode
  :ensure t
  :hook
  (lsp-mode-hook . lsp-enable-which-key-integration)
  :bind
  ("s-l" . lsp-keymap-prefix)
  :commands lsp)

(use-package lsp-ui
  :ensure t
  :after lsp-mode
  :hook
  (lsp-mode-hook . lsp-ui-mode)
  :bind
  (:map lsp-ui-mode-map
    ("C-c i" . lsp-ui-menu)))

(use-package lsp-pyright
  :ensure t
  :after (python lsp-mode)
  :custom
  (lsp-pyright-venv-path (getenv "WORKON_HOME"))
  :hook
  (python-mode-hook . (lambda ()
            (require 'lsp-pyright) (lsp))))

;; Python
(use-package python
  :ensure t
  :custom
  ;; (python-shell-completion-native-enable nil)
  (python-indent-guess-indent-offset-verbose nil)
  (python-shell-buffer-name "IPython")
  (python-shell-interpreter "ipython")
  (python-shell-interpreter-args "-i --simple-prompt")
  :hook
  ((python-mode-hook . flyspell-prog-mode)
   (python-mode-hook . flycheck-mode)
   (python-mode-hook . company-mode)
   (python-mode-hook . lsp)))

;; pyenv-mode
;; Integrate pyenv with python-mode
(use-package pyenv-mode
  :ensure t
  :if (eq system-type 'darwin)
  :after python
  :hook
  (python-mode-hook . pyenv-mode))

;; pyvenv
;; Python virtual environment support
(use-package pyvenv
  :ensure t
  :after python
  :custom
  (pyvenv-workon "env")
  :hook
  ((python-mode-hook . pyvenv-mode)
   (pyvenv-post-activate-hooks . pyvenv-restart-python)
   (pyvenv-post-deactivate-hooks . pyvenv-restart-python))
  :config
  (defalias 'workon 'pyvenv-workon)
  (defalias 'deactivate 'pyvenv-deactivate))

;;; init.el ends here
;; Define and load custom.el file
(setq custom-file (expand-file-name "custom.el" user-emacs-directory))
(when (file-exists-p custom-file)
  (load custom-file))

;; Modify package repositories
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)

;; Load and activate Emacs packages
(package-initialize)

;; Install use-package if it's not installed
(unless (package-installed-p 'use-package)
  (package-refresh-contents)
  (package-install 'use-package))

;; Load use-package
(require 'use-package)
(setq use-package-hook-name-suffix nil) ;; Do not append text to the name of hooks mentioned by :hook

;; Load use-package-ensure
;; Support for :ensure and :pin keywords in use-package declarations
(require 'use-package-ensure)
(setq use-package-always-ensure t)

;; exec-path-from-shell
(use-package exec-path-from-shell
  :ensure t
  :if (eq system-type 'darwin)
  :custom
  (exec-path-from-shell-variables
   '("PATH" "MANPATH" "XDG_CONFIG_HOME" "WORKON_HOME" "LSP_USE_PLISTS" "PYTHONPATH" "IPYTHONDIR" "MPLCONFIGDIR"))
  (exec-path-from-shell-arguments nil)
  :config
  ;; (setenv "PKG_CONFIG_PATH" "/usr/local/Cellar/zlib/1.2.11/lib/pkgconfig:/usr/local/lib/pkgconfig"))
  (exec-path-from-shell-initialize))

;; Helm
;; Input completion
(use-package helm
  :ensure t
  :init
  (helm-mode 1)
  (require 'helm-config)
  :bind
  ;; ("C-c i"   . helm-imenu) ;; Select document heading
  ("C-x b"   . helm-mini) ;; Select buffers
  ("C-x C-f" . helm-find-files) ;; Open or create files
  ("C-x C-r" . helm-recentf) ;; Select recently saved files
  ("M-x"     . helm-M-x) ;; Evaluate functions
  ("M-y"     . helm-show-kill-ring) ;; Show the kill ring
  (:map helm-map
    ("<tab>" . helm-execute-persistent-action)
    ("C-z" . helm-select-action)))

;; which-key
;; Input completion
(use-package which-key
  :ensure t
  :custom
  (which-key-idle-delay 0.5)
  (which-key-idle-secondary-delay 0.5)
  :config
  (which-key-mode 1)
  (which-key-setup-side-window-bottom))

;; Company
;; Text completion
(use-package company
  :ensure t
  :custom
  (company-idle-delay 0.0)
  (company-minimum-prefix-length 4)
  (company-selection-wrap-around t)
  :hook
  ((text-mode-hook . company-mode)
   (prog-mode-hook . company-mode))
  :bind
  (:map company-active-map
    ("<tab>" . nil)
    ("TAB" . nil)
    ("M-<tab>" . company-complete-common-or-cycle)
    ("M-<tab>" . company-complete-selection)))

;; Flyspell
;; Spell checking for text (requires aspell)
(use-package flyspell
  :ensure t
  :init
  (setq ispell-program-name "aspell")
  :hook
  ((text-mode-hook . flyspell-mode)
   (prog-mode-hook . flyspell-prog-mode))
  :bind
  ("<f7>" . flyspell-word)
  ("M-<f7>" . flyspell-buffer))

;; Flycheck
;; Spell checking for code
(use-package flycheck
  :ensure t
  :init
  (setq flycheck-highlighting-mode 'symbols
    flycheck-indication-mode 'left-fringe
    flycheck-standard-error-navigation t)
  :hook
  (prog-mode-hook . flycheck-mode))

;; LSP Mode
;; Language Server Protocol Support
(use-package lsp-mode
  :ensure t
  :hook
  (lsp-mode-hook . lsp-enable-which-key-integration)
  :bind
  ("s-l" . lsp-keymap-prefix)
  :commands lsp)

(use-package lsp-ui
  :ensure t
  :after lsp-mode
  :hook
  (lsp-mode-hook . lsp-ui-mode)
  :bind
  (:map lsp-ui-mode-map
    ("C-c i" . lsp-ui-menu)))

(use-package lsp-pyright
  :ensure t
  :after (python lsp-mode)
  :custom
  (lsp-pyright-venv-path (getenv "WORKON_HOME"))
  :hook
  (python-mode-hook . (lambda ()
            (require 'lsp-pyright) (lsp))))

;; Python
(use-package python
  :ensure t
  :custom
  ;; (python-shell-completion-native-enable nil)
  (python-indent-guess-indent-offset-verbose nil)
  (python-shell-buffer-name "IPython")
  (python-shell-interpreter "ipython")
  (python-shell-interpreter-args "-i --simple-prompt")
  :hook
  ((python-mode-hook . flyspell-prog-mode)
   (python-mode-hook . flycheck-mode)
   (python-mode-hook . company-mode)
   (python-mode-hook . lsp)))

;; pyenv-mode
;; Integrate pyenv with python-mode
(use-package pyenv-mode
  :ensure t
  :if (eq system-type 'darwin)
  :after python
  :hook
  (python-mode-hook . pyenv-mode))

;; pyvenv
;; Python virtual environment support
(use-package pyvenv
  :ensure t
  :after python
  :custom
  (pyvenv-workon "env")
  :hook
  ((python-mode-hook . pyvenv-mode)
   (pyvenv-post-activate-hooks . pyvenv-restart-python)
   (pyvenv-post-deactivate-hooks . pyvenv-restart-python))
  :config
  (defalias 'workon 'pyvenv-workon)
  (defalias 'deactivate 'pyvenv-deactivate))

;;; init.el ends here
brew install pyright
brew install pyright
;; Define and load custom.el file
(setq custom-file (expand-file-name "custom.el" user-emacs-directory))
(when (file-exists-p custom-file)
  (load custom-file))

;; Modify package repositories
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)

;; Load and activate Emacs packages
(package-initialize)

;; Install use-package if it's not installed
(unless (package-installed-p 'use-package)
  (package-refresh-contents)
  (package-install 'use-package))

;; Load use-package
(require 'use-package)
(setq use-package-hook-name-suffix nil) ;; Do not append text to the name of hooks mentioned by :hook

;; Load use-package-ensure
;; Support for :ensure and :pin keywords in use-package declarations
(require 'use-package-ensure)
(setq use-package-always-ensure t)

;; exec-path-from-shell
(use-package exec-path-from-shell
  :ensure t
  :if (eq system-type 'darwin)
  :custom
  (exec-path-from-shell-variables
   '("PATH" "MANPATH" "XDG_CONFIG_HOME" "WORKON_HOME" "LSP_USE_PLISTS" "PYTHONPATH" "IPYTHONDIR" "MPLCONFIGDIR"))
  (exec-path-from-shell-arguments nil)
  :config
  ;; (setenv "PKG_CONFIG_PATH" "/usr/local/Cellar/zlib/1.2.11/lib/pkgconfig:/usr/local/lib/pkgconfig"))
  (exec-path-from-shell-initialize))

;; Helm
;; Input completion
(use-package helm
  :ensure t
  :init
  (helm-mode 1)
  (require 'helm-config)
  :bind
  ;; ("C-c i"   . helm-imenu) ;; Select document heading
  ("C-x b"   . helm-mini) ;; Select buffers
  ("C-x C-f" . helm-find-files) ;; Open or create files
  ("C-x C-r" . helm-recentf) ;; Select recently saved files
  ("M-x"     . helm-M-x) ;; Evaluate functions
  ("M-y"     . helm-show-kill-ring) ;; Show the kill ring
  (:map helm-map
    ("<tab>" . helm-execute-persistent-action)
    ("C-z" . helm-select-action)))

;; which-key
;; Input completion
(use-package which-key
  :ensure t
  :custom
  (which-key-idle-delay 0.5)
  (which-key-idle-secondary-delay 0.5)
  :config
  (which-key-mode 1)
  (which-key-setup-side-window-bottom))

;; Company
;; Text completion
(use-package company
  :ensure t
  :custom
  (company-idle-delay 0.0)
  (company-minimum-prefix-length 4)
  (company-selection-wrap-around t)
  :hook
  ((text-mode-hook . company-mode)
   (prog-mode-hook . company-mode))
  :bind
  (:map company-active-map
    ("<tab>" . nil)
    ("TAB" . nil)
    ("M-<tab>" . company-complete-common-or-cycle)
    ("M-<tab>" . company-complete-selection)))

;; Flyspell
;; Spell checking for text (requires aspell)
(use-package flyspell
  :ensure t
  :init
  (setq ispell-program-name "aspell")
  :hook
  ((text-mode-hook . flyspell-mode)
   (prog-mode-hook . flyspell-prog-mode))
  :bind
  ("<f7>" . flyspell-word)
  ("M-<f7>" . flyspell-buffer))

;; Flycheck
;; Spell checking for code
(use-package flycheck
  :ensure t
  :init
  (setq flycheck-highlighting-mode 'symbols
    flycheck-indication-mode 'left-fringe
    flycheck-standard-error-navigation t)
  :hook
  (prog-mode-hook . flycheck-mode))

;; LSP Mode
;; Language Server Protocol Support
(use-package lsp-mode
  :ensure t
  :hook
  (lsp-mode-hook . lsp-enable-which-key-integration)
  :bind
  ("s-l" . lsp-keymap-prefix)
  :commands lsp)

(use-package lsp-ui
  :ensure t
  :after lsp-mode
  :hook
  (lsp-mode-hook . lsp-ui-mode)
  :bind
  (:map lsp-ui-mode-map
    ("C-c i" . lsp-ui-menu)))

(use-package lsp-pyright
  :ensure t
  :after (python lsp-mode)
  :custom
  (lsp-pyright-venv-path (getenv "WORKON_HOME"))
  :hook
  (python-mode-hook . (lambda ()
            (require 'lsp-pyright) (lsp))))

;; Python
(use-package python
  :ensure t
  :custom
  ;; (python-shell-completion-native-enable nil)
  (python-indent-guess-indent-offset-verbose nil)
  (python-shell-buffer-name "IPython")
  (python-shell-interpreter "ipython")
  (python-shell-interpreter-args "-i --simple-prompt")
  :hook
  ((python-mode-hook . flyspell-prog-mode)
   (python-mode-hook . flycheck-mode)
   (python-mode-hook . company-mode)
   (python-mode-hook . lsp)))

;; pyenv-mode
;; Integrate pyenv with python-mode
(use-package pyenv-mode
  :ensure t
  :if (eq system-type 'darwin)
  :after python
  :hook
  (python-mode-hook . pyenv-mode))

;; pyvenv
;; Python virtual environment support
(use-package pyvenv
  :ensure t
  :after python
  :custom
  (pyvenv-workon "env")
  :hook
  ((python-mode-hook . pyvenv-mode)
   (pyvenv-post-activate-hooks . pyvenv-restart-python)
   (pyvenv-post-deactivate-hooks . pyvenv-restart-python))
  :config
  (defalias 'workon 'pyvenv-workon)
  (defalias 'deactivate 'pyvenv-deactivate))

;;; init.el ends here
brew install pyright
;; Define and load custom.el file
(setq custom-file (expand-file-name "custom.el" user-emacs-directory))
(when (file-exists-p custom-file)
  (load custom-file))

;; Modify package repositories
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)

;; Load and activate Emacs packages
(package-initialize)

;; Install use-package if it's not installed
(unless (package-installed-p 'use-package)
  (package-refresh-contents)
  (package-install 'use-package))

;; Load use-package
(require 'use-package)
(setq use-package-hook-name-suffix nil) ;; Do not append text to the name of hooks mentioned by :hook

;; Load use-package-ensure
;; Support for :ensure and :pin keywords in use-package declarations
(require 'use-package-ensure)
(setq use-package-always-ensure t)

;; exec-path-from-shell
(use-package exec-path-from-shell
  :ensure t
  :if (eq system-type 'darwin)
  :custom
  (exec-path-from-shell-variables
   '("PATH" "MANPATH" "XDG_CONFIG_HOME" "WORKON_HOME" "LSP_USE_PLISTS" "PYTHONPATH" "IPYTHONDIR" "MPLCONFIGDIR"))
  (exec-path-from-shell-arguments nil)
  :config
  ;; (setenv "PKG_CONFIG_PATH" "/usr/local/Cellar/zlib/1.2.11/lib/pkgconfig:/usr/local/lib/pkgconfig"))
  (exec-path-from-shell-initialize))

;; Helm
;; Input completion
(use-package helm
  :ensure t
  :init
  (helm-mode 1)
  (require 'helm-config)
  :bind
  ;; ("C-c i"   . helm-imenu) ;; Select document heading
  ("C-x b"   . helm-mini) ;; Select buffers
  ("C-x C-f" . helm-find-files) ;; Open or create files
  ("C-x C-r" . helm-recentf) ;; Select recently saved files
  ("M-x"     . helm-M-x) ;; Evaluate functions
  ("M-y"     . helm-show-kill-ring) ;; Show the kill ring
  (:map helm-map
    ("<tab>" . helm-execute-persistent-action)
    ("C-z" . helm-select-action)))

;; which-key
;; Input completion
(use-package which-key
  :ensure t
  :custom
  (which-key-idle-delay 0.5)
  (which-key-idle-secondary-delay 0.5)
  :config
  (which-key-mode 1)
  (which-key-setup-side-window-bottom))

;; Company
;; Text completion
(use-package company
  :ensure t
  :custom
  (company-idle-delay 0.0)
  (company-minimum-prefix-length 4)
  (company-selection-wrap-around t)
  :hook
  ((text-mode-hook . company-mode)
   (prog-mode-hook . company-mode))
  :bind
  (:map company-active-map
    ("<tab>" . nil)
    ("TAB" . nil)
    ("M-<tab>" . company-complete-common-or-cycle)
    ("M-<tab>" . company-complete-selection)))

;; Flyspell
;; Spell checking for text (requires aspell)
(use-package flyspell
  :ensure t
  :init
  (setq ispell-program-name "aspell")
  :hook
  ((text-mode-hook . flyspell-mode)
   (prog-mode-hook . flyspell-prog-mode))
  :bind
  ("<f7>" . flyspell-word)
  ("M-<f7>" . flyspell-buffer))

;; Flycheck
;; Spell checking for code
(use-package flycheck
  :ensure t
  :init
  (setq flycheck-highlighting-mode 'symbols
    flycheck-indication-mode 'left-fringe
    flycheck-standard-error-navigation t)
  :hook
  (prog-mode-hook . flycheck-mode))

;; LSP Mode
;; Language Server Protocol Support
(use-package lsp-mode
  :ensure t
  :hook
  (lsp-mode-hook . lsp-enable-which-key-integration)
  :bind
  ("s-l" . lsp-keymap-prefix)
  :commands lsp)

(use-package lsp-ui
  :ensure t
  :after lsp-mode
  :hook
  (lsp-mode-hook . lsp-ui-mode)
  :bind
  (:map lsp-ui-mode-map
    ("C-c i" . lsp-ui-menu)))

(use-package lsp-pyright
  :ensure t
  :after (python lsp-mode)
  :custom
  (lsp-pyright-venv-path (getenv "WORKON_HOME"))
  :hook
  (python-mode-hook . (lambda ()
            (require 'lsp-pyright) (lsp))))

;; Python
(use-package python
  :ensure t
  :custom
  ;; (python-shell-completion-native-enable nil)
  (python-indent-guess-indent-offset-verbose nil)
  (python-shell-buffer-name "IPython")
  (python-shell-interpreter "ipython")
  (python-shell-interpreter-args "-i --simple-prompt")
  :hook
  ((python-mode-hook . flyspell-prog-mode)
   (python-mode-hook . flycheck-mode)
   (python-mode-hook . company-mode)
   (python-mode-hook . lsp)))

;; pyenv-mode
;; Integrate pyenv with python-mode
(use-package pyenv-mode
  :ensure t
  :if (eq system-type 'darwin)
  :after python
  :hook
  (python-mode-hook . pyenv-mode))

;; pyvenv
;; Python virtual environment support
(use-package pyvenv
  :ensure t
  :after python
  :custom
  (pyvenv-workon "env")
  :hook
  ((python-mode-hook . pyvenv-mode)
   (pyvenv-post-activate-hooks . pyvenv-restart-python)
   (pyvenv-post-deactivate-hooks . pyvenv-restart-python))
  :config
  (defalias 'workon 'pyvenv-workon)
  (defalias 'deactivate 'pyvenv-deactivate))

;;; init.el ends here
brew install pyright
added 7 characters in body
Source Link
user36782
user36782

Why is it not finding my lsp-pyright installation?Why is it not finding my lsp-pyright installation? Perhaps I am missing something on Python's side (some packages, etc.)?

Why is it not finding my lsp-pyright installation? Perhaps I am missing something on Python's side (some packages, etc.)?

Why is it not finding my lsp-pyright installation? Perhaps I am missing something on Python's side (some packages, etc.)?

added 212 characters in body
Source Link
user36782
user36782

UPDATE:

All I needed to do to solve this problem was to install the actual language server for Python. I did this by using brew, as pyright is available there:

brew install pyright

UPDATE:

All I needed to do to solve this problem was to install the actual language server for Python. I did this by using brew, as pyright is available there:

brew install pyright
Source Link
user36782
user36782
Loading