emacs-lsp / lsp-pyright

lsp-mode :heart: pyright
https://emacs-lsp.github.io/lsp-pyright
GNU General Public License v3.0
291 stars 25 forks source link

How can I change the pyright's initialized folder path? #69

Closed avatar-lavventura closed 1 year ago

avatar-lavventura commented 2 years ago

The way I use

(use-package lsp-pyright
  :ensure t
  :hook (python-mode . (lambda ()
                          (require 'lsp-pyright)
                          (lsp))))  ; or lsp-deferred

When I start emacs I see following message: LSP :: pyright:438671 initialized successfully in folders: (/home/alper) , where /home/alper is my home folder that has many folders in it. Is it normal way to do it?

I just want to use pyright in my python folders where LSP is used. How can I change the pyright's initialized folder path?

knysfh commented 1 year ago

I think the message is from lsp-mode not pyright.You can try whether lsp-workspace-folders-switch appears /home/alper.

If you want delete /home/alper workspace you can use lsp-workspace-folders-remove.Detail about initialization notification

avatar-lavventura commented 1 year ago

This occurs when I try to open a file under ~ such as ~/.bashrc, ~/.zshrc, ~/.emacs.

.zshrc is not part of any project.

i ==> Import project root /Users/alper/
I ==> Import project by selecting root directory interactively
. ==> Import project at current directory /Users/alper/
d ==> Do not ask again for the current project by adding /Users/alper/ to lsp-session-folders-blacklist
D ==> Do not ask again for the current project by selecting ignore path interactively
n ==> Do nothing: ask again when opening other files from the current project

when I select i it gives following warning message:

[WARNING] You are trying to import your home folder as project root. This may cause performance issue because some language servers (python,
lua, etc) will try to scan all files under project root. To avoid that you may:

1. Use `I' option from the interactive project import to select subfolder(e. g. `~/foo/bar' instead of `~/').
2. If your file is under `~/' then create a subfolder and move that file in this folder.

Type `No' to go back to project selection.
Type `Yes' to confirm `HOME' as project root.
Type `C-g' to cancel project import process and stop `lsp' (y or n)
knysfh commented 1 year ago

Is /home/alper in your lsp-workspace? What will be prompted to delete it using the lsp-workspace-folders-remove command?

This is my configure for lsp-mode:

(use-package lsp-mode
  :ensure t
  :commands (lsp lsp-deferred)
  ;; See https://emacs-lsp.github.io/lsp-mode/page/settings/mode/
  ;; for details on parameters
  :config
  (setq lsp-auto-guess-root t
        lsp-log-io nil
        lsp-restart 'auto-restart
        lsp-enable-file-watchers nil
        lsp-keep-workspace-alive nil
        lsp-enable-symbol-highlighting nil
        lsp-enable-on-type-formatting nil
        lsp-signature-auto-activate nil
        lsp-signature-render-documentation nil
        lsp-eldoc-hook nil
        lsp-modeline-code-actions-enable nil
        lsp-modeline-diagnostics-enable nil
        lsp-headerline-breadcrumb-enable nil
        lsp-semantic-tokens-enable nil
        lsp-enable-folding nil
        lsp-enable-imenu nil
        lsp-enable-snippet nil
        gc-cons-threshold (* 100 1024 1024)
        read-process-output-max (* 1024 1024) ;; 1MB
        lsp-idle-delay 0.1)
  (setq lsp-pylsp-plugins-yapf-enabled t
        lsp-pylsp-plugins-flake8-enabled nil)
  (define-key lsp-mode-map (kbd "C-c l") lsp-command-map)
  :hook
  (lsp-mode . (lambda ()
                (let ((lsp-keymap-prefix "C-c l"))
                  (lsp-enable-which-key-integration))))
  )

I only run it when i use lsp command, not all the time.Because I have the need to view the python code instead of running.

avatar-lavventura commented 1 year ago

Yes /home/alper is in my lsp-workspace.

Thanks your configure file is helpful. Ok looks like I have to add ~ folder no matter what I am opening any config file under it.