Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fallback default-directory when project and projectile return nil #2112

Conversation

KaratasFurkan
Copy link
Contributor

@KaratasFurkan KaratasFurkan commented Aug 25, 2020

When using lsp-auto-guess-root, this helps a lot when jumping source code of third party python packages and also when working on a small, dummy project with no git repository in it.

AFAIK, eglot use the same approach, too.

@yyoncho yyoncho merged commit 6fb2fd9 into emacs-lsp:master Aug 25, 2020
@yyoncho
Copy link
Member

yyoncho commented Aug 25, 2020

Thank you. I think that we had that in the past, seems like it was deleted by mistake.

ia0 added a commit to ia0/lsp-mode that referenced this pull request Feb 25, 2023
… nil (emacs-lsp#2112)"

This reverts commit 6fb2fd9.

The intent of `lsp--suggest-project-root` is not to always return non-nil but
instead return nil when no good suggestion is found and let the caller decide
what to do in such case. This can be seen in 2 different ways:

1. All calls except in `lsp--calculate-root` (see 2 below) use the following
form which demonstrates that the function should sometimes return nil.

    ```
    (or (lsp--suggest-project-root) default-directory)
    ```

2. We find the following snippet in `lsp--calculate-root` which demonstrates
that the function should sometimes return nil (otherwise `unless
lsp-auto-guess-root` could be removed since always true).

    ```
    (or
     (when lsp-auto-guess-root
       (lsp--suggest-project-root))
     (lsp-find-session-folder session file-name)
     (unless lsp-auto-guess-root
    ```
ia0 added a commit to ia0/lsp-mode that referenced this pull request Feb 25, 2023
This reverts emacs-lsp#2112.

The intent of `lsp--suggest-project-root` is not to always return non-nil but
instead return nil when no good suggestion is found and let the caller decide
what to do in such case. This can be seen in 2 different ways:

1. All calls except in `lsp--calculate-root` (see 2 below) use the following
form which demonstrates that the function should sometimes return nil.

    ```
    (or (lsp--suggest-project-root) default-directory)
    ```

2. We find the following snippet in `lsp--calculate-root` which demonstrates
that the function should sometimes return nil (otherwise `unless
lsp-auto-guess-root` could be removed since always true).

    ```
    (or
     (when lsp-auto-guess-root
       (lsp--suggest-project-root))
     (lsp-find-session-folder session file-name)
     (unless lsp-auto-guess-root
    ```
ia0 added a commit to ia0/lsp-mode that referenced this pull request Feb 25, 2023
This reverts emacs-lsp#2112.

The intent of `lsp--suggest-project-root` is not to always return non-nil but
instead return nil when no good suggestion is found and let the caller decide
what to do in such case. This can be seen in 2 different ways:

1. All calls except in `lsp--calculate-root` (see 2 below) use the following
form which demonstrates that the function should sometimes return nil.

    ```
    (or (lsp--suggest-project-root) default-directory)
    ```

2. We find the following snippet in `lsp--calculate-root` which demonstrates
that the function should sometimes return nil (otherwise `unless
lsp-auto-guess-root` could be removed since always true).

    ```
    (or
     (when lsp-auto-guess-root
       (lsp--suggest-project-root))
     (lsp-find-session-folder session file-name)
     (unless lsp-auto-guess-root
    ```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants