Skip to content
This repository was archived by the owner on Jan 3, 2024. It is now read-only.

Add on_initialized hook #139

Merged
merged 2 commits into from
Feb 22, 2022
Merged

Add on_initialized hook #139

merged 2 commits into from
Feb 22, 2022

Conversation

m-lima
Copy link
Contributor

@m-lima m-lima commented Feb 8, 2022

Addresses a common issue with large workspaces that take longer to load and cause errors such as:
rust-lang/rust-analyzer#10910
https://www.reddit.com/r/neovim/comments/qwlheb/delay_vimlspcodelensrefresh_until_rustanalyzer_is/

This works by allowing passing a callback to be run once serverStatus with quiescent is sent (similar to inlayHints)

An example configuration:

tools = {
  on_initialized = function()
    vim.cmd([[
      augroup SuperDuperAus
        autocmd CursorHold                      *.rs silent! lua vim.lsp.buf.document_highlight()
        autocmd CursorMoved,InsertEnter         *.rs silent! lua vim.lsp.buf.clear_references()
        autocmd BufEnter,CursorHold,InsertLeave *.rs silent! lua vim.lsp.codelens.refresh()
        autocmd BufWritePre                     *.rs silent! lua vim.lsp.buf.formatting_sync()
      augroup END
    ]])
  end,
}

@simrat39
Copy link
Owner

Could you please add this to the readme as well?

@simrat39 simrat39 merged commit 892004f into simrat39:master Feb 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants