Skip to content

Commit 99b812e

Browse files
authored
[Suggestion] Do not try to guess a root if lsp--suggest-project-root failed (#3973)
* [Suggestion] Do not try to guess a root if lsp--suggest-project-root failed Currently, when `lsp-auto-guess-root` is set and `lsp--suggest-project-root` fails to find a project root, we fall back to `lsp-find-session-folder`. This PR makes `lsp--suggest-project-root` authoritative when `lsp-auto-guess-root` is set, thus giving full control to the user. * Introduce lsp-guess-root-without-session
1 parent 33afad3 commit 99b812e

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

lsp-mode.el

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,15 @@ following `projectile'/`project.el' conventions."
245245
:group 'lsp-mode
246246
:type 'boolean)
247247

248+
(defcustom lsp-guess-root-without-session nil
249+
"Ignore the session file when calculating the project root.
250+
You almost always want to set lsp-auto-guess-root too.
251+
Do *not* use this setting unless you are familiar with `lsp-mode'
252+
internals and you are sure that all of your projects are
253+
following `projectile'/`project.el' conventions."
254+
:group 'lsp-mode
255+
:type 'boolean)
256+
248257
(defcustom lsp-restart 'interactive
249258
"Defines how server-exited events must be handled."
250259
:group 'lsp-mode
@@ -8894,7 +8903,8 @@ Select action: "
88948903
(or
88958904
(when lsp-auto-guess-root
88968905
(lsp--suggest-project-root))
8897-
(lsp-find-session-folder session file-name)
8906+
(unless lsp-guess-root-without-session
8907+
(lsp-find-session-folder session file-name))
88988908
(unless lsp-auto-guess-root
88998909
(when-let ((root-folder (lsp--find-root-interactively session)))
89008910
(if (or (not (f-equal? root-folder (expand-file-name "~/")))

0 commit comments

Comments
 (0)