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

Stale data lookups in completions #269

Open
Nitrodist opened this issue May 28, 2020 · 2 comments
Open

Stale data lookups in completions #269

Nitrodist opened this issue May 28, 2020 · 2 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@Nitrodist
Copy link

Nitrodist commented May 28, 2020

Hello, I am a vim+coc.nvim user and I use this project (elixir-ls) to provide code-completion etc.

I want to discuss the idea of using the stale analysis data during the various compilation steps so that code completion continues to work instead of returning nothing.

In my large project, it takes 12 seconds for code-completion to work again. I'm editing a test written in a .exs file in this example - maybe I'm doing something wrong (I am new!), but during those 12 seconds I know that I haven't made a functional change to anything, so I'd be fine with old lookups were to still be returned after I happen to use :w to save my work in progress. Even if it's 5 seconds, I'd rather have those 5 seconds of my life back, you know!

Let's say that I write to the file and it has compilation errors. This may be common because I'll return to my work after I've saved my work to disk before having lunch. I've now returned to fix my code and I don't have access to the basic information and advantages provided by code-completion with elixir-ls.

Stale data lookups fix these issues and it would improve the utility of elixir-ls considerably.

Environment

  • Elixir & Erlang versions (elixir --version):
elixir --version
Erlang/OTP 22 [erts-10.7.1] [source] [64-bit] [smp:12:12] [ds:12:12:10] [async-threads:1] [hipe] [dtrace]

Elixir 1.10.3 (compiled with Erlang/OTP 21)
  • Operating system: macOS Catalina 10.15.4
  • Editor or IDE name vim + coc.nvim
  • LSP Client name:
    • coc.nvim

Logs

Compiling with Mix env test
[Info  - 11:41:05 a.m.] Compile took 402 milliseconds
[Info  - 11:41:05 a.m.] [ElixirLS Dialyzer] Checking for stale beam files
[Info  - 11:41:05 a.m.] [ElixirLS Dialyzer] Found 0 changed files in 76 milliseconds
[Info  - 11:41:08 a.m.] [ElixirLS Dialyzer] Analyzing 2 modules: [:metrics_exometer, :metrics_folsom]
[Info  - 11:41:08 a.m.] [ElixirLS Dialyzer] Analysis finished in 2775 milliseconds
[Info  - 11:41:10 a.m.] [ElixirLS Dialyzer] Writing manifest...
[Info  - 11:41:11 a.m.] [ElixirLS Dialyzer] Done writing manifest in 2304 milliseconds.
[Info  - 11:41:14 a.m.] Dialyzer analysis is up to date
[Info  - 11:41:21 a.m.] [ElixirLS WorkspaceSymbols] Indexing...
[Info  - 11:41:26 a.m.] [ElixirLS WorkspaceSymbols] Module discovery complete
[Info  - 11:41:26 a.m.] [ElixirLS WorkspaceSymbols] 480 callbacks added to index
[Info  - 11:41:30 a.m.] [ElixirLS WorkspaceSymbols] 2591 modules added to index
[Info  - 11:41:30 a.m.] [ElixirLS WorkspaceSymbols] 1712 types added to index
[Info  - 11:41:49 a.m.] [ElixirLS WorkspaceSymbols] 34255 functions added to index

Compiling with Mix env test
[Info  - 12:19:02 p.m.] Compile took 388 milliseconds
[Info  - 12:19:02 p.m.] [ElixirLS Dialyzer] Checking for stale beam files
[Info  - 12:19:03 p.m.] [ElixirLS Dialyzer] Found 0 changed files in 136 milliseconds
[Info  - 12:19:06 p.m.] [ElixirLS Dialyzer] Analyzing 2 modules: [:metrics_exometer, :metrics_folsom]
[Info  - 12:19:06 p.m.] [ElixirLS Dialyzer] Analysis finished in 3152 milliseconds
[Info  - 12:19:08 p.m.] [ElixirLS Dialyzer] Writing manifest...
[Info  - 12:19:09 p.m.] [ElixirLS Dialyzer] Done writing manifest in 2069 milliseconds.
[Info  - 12:19:14 p.m.] Dialyzer analysis is up to date
[Info  - 12:19:14 p.m.] [ElixirLS WorkspaceSymbols] Updating index...
[Info  - 12:19:19 p.m.] [ElixirLS WorkspaceSymbols] 0 modules need reindexing
[Info  - 12:19:19 p.m.] [ElixirLS WorkspaceSymbols] 0 modules added to index
[Info  - 12:19:19 p.m.] [ElixirLS WorkspaceSymbols] 0 types added to index
[Info  - 12:19:19 p.m.] [ElixirLS WorkspaceSymbols] 0 functions added to index
[Info  - 12:19:19 p.m.] [ElixirLS WorkspaceSymbols] 0 callbacks added to index
@lukaszsamson
Copy link
Collaborator

It shouldn't be very difficult to implement. elixir_sense library does most of the work and it should rather work fine (I'd expect some occasional crashes as it analyses modules on the fly). A PR would definitely be welcome

@lukaszsamson lukaszsamson changed the title Stale data lookups Stale data lookups in completions Nov 28, 2020
@lukaszsamson lukaszsamson added enhancement New feature or request help wanted Extra attention is needed labels Nov 28, 2020
@lukaszsamson
Copy link
Collaborator

It's not a full solution but elixir-lsp/elixir_sense@6b378da is a step in the direction of building cache of completion symbols

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

No branches or pull requests

2 participants