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

Suggestion: start LSP client in BufEnter #407

Closed
lbiaggi opened this issue May 24, 2024 · 7 comments · Fixed by #409
Closed

Suggestion: start LSP client in BufEnter #407

lbiaggi opened this issue May 24, 2024 · 7 comments · Fixed by #409
Labels
enhancement New feature or request

Comments

@lbiaggi
Copy link

lbiaggi commented May 24, 2024

Feature description

Moving the LSP start to BufEnter event reduces ~ 20-30% of the startup, which is really helpful when opening in an RPI.

IMO, moving to BufEnterfelt more smoothly

I achieve it through by disabling auto-attach and running the original command.

...
auto_attach = function(bufnr)
            local augroup = _G.custom.commands.augroup
            augroup("RUST_LSP", {
                {
                    event = "BufEnter",
                    pattern = "*.rs",
                    command = function()
                        require("rustaceanvim.lsp").start()
                    end,
                    once = true,
                },
            })

            return false
        end,
...

I wonder if this would be beneficial for other users / more powerful environment

@mrcjkb
Copy link
Owner

mrcjkb commented May 24, 2024

Sounds reasonable 😄

I've pushed the change to master, but I'll wait a bit before publishing a release, to see if someone complains.

@mrcjkb
Copy link
Owner

mrcjkb commented May 25, 2024

@lbiaggi I've had to revert this because it led to problems with the LSP client starting at all, and I don't know if it has any other side effects.

@mrcjkb mrcjkb closed this as not planned Won't fix, can't repro, duplicate, stale May 25, 2024
@lbiaggi
Copy link
Author

lbiaggi commented May 26, 2024

@lbiaggi I've had to revert this because it led to problems with the LSP client starting at all, and I don't know if it has any other side effects.

Yeek, seriously? Could you give me an example?

@mrcjkb
Copy link
Owner

mrcjkb commented May 26, 2024

Yeek, seriously? Could you give me an example?

I don't have a repro myself.
#408 (comment)

In any case, the uncertainty is enough reason to revert it. You seem to have a workaround that works for you, and this is an edge case.

@lbiaggi
Copy link
Author

lbiaggi commented May 26, 2024 via email

@mrcjkb
Copy link
Owner

mrcjkb commented May 26, 2024

The official recommendation is for vim.lsp.start to be called on a FileType event.
I fear that deferring to BufEnter could have unexpected side effects. So even if we were to fix this particular case, I won't include this in rustaceanvim.

@lbiaggi
Copy link
Author

lbiaggi commented May 26, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants