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

completion #45

Closed
13 tasks done
mhanberg opened this issue Jun 26, 2023 · 0 comments · Fixed by #405
Closed
13 tasks done

completion #45

mhanberg opened this issue Jun 26, 2023 · 0 comments · Fixed by #405
Labels
enhancement New feature or request

Comments

@mhanberg
Copy link
Collaborator

mhanberg commented Jun 26, 2023

Features

Non exhaustive list of completion candiates

  • Modules
  • remote functions
  • local functions
  • private functions
  • variables/parameters
  • module attributes
  • structs
  • struct fields
  • bitstring modifiers
  • special forms
  • kernel functions
  • imported functions (eg, import Foo)
  • aliased modules (eg, alias Foo.Bar or alias Foo.Bar, as: Baz)

More features will be unlocked and made more robust as we work through elixir-lang/elixir#12645

@mhanberg mhanberg added the enhancement New feature or request label Jun 26, 2023
@mhanberg mhanberg mentioned this issue Oct 19, 2023
3 tasks
mhanberg added a commit that referenced this issue Oct 19, 2023
## Description

Implements basic autocompletion.

Current completion candidates supported

- Global modules
- Global Structs
- Struct fields
- Remote functions (w/ documentation)
- Special Forms
- Bitstring modifiers
- filesystem paths in strings

More features, particularly features that rely on contextual information about the code itself (meaning, which identifiers, aliases, imports are available) will come in subsequent patches.

Partially addresses #45 

## Experimental

This patch also introduces a new initialization option, `experimental`.

This feature will be gated as an experimental feature as it's built out. The purpose of this is so that early-early adopters can try it out and report bugs, but folks who would rather wait for something more stable won't have it affect their workflows.

To enable this feature, toggle the completions experiment in your editor.

### Nvim (elixir-tools.nvim)

```lua
require("elixir").setup({
    nextls = {
        enable = true,
        init_options = {
            experimental = {
                completions = {
                    enable = true
                }
            }
        }
    },
    elixirls = {enable = false}
})
```

### Visual Studio Code (elixir-tools.vscode)

```json
{
  "elixir-tools.nextLS.experimental.completions.enable": true
}
```

### Other editors

Not sure 😅

## Demos

TODO: record them my guy

## TODO

- [x] integration tests
- [ ] update elixir-tools.dev with instructions
- [x] update README with instructions

## Acknowedgements

This feature is initially based on `IEx.Autocomplete`. Huge thanks to the Elixir core team's efforts to help kickstart this feature. More deviations will likely occur as we gain more contextual parsing for things like imports, aliases and variables.
mhanberg added a commit that referenced this issue Mar 10, 2024
mhanberg added a commit that referenced this issue Apr 12, 2024
This patch adds support for completion candidates for functions/macros
imported via `import`, modules aliases via `alias`, module attributes,
and any of the above when injected via a macro such as `use`.

However, this is powered by new APIs and compiler changes that will be
available in Elixir 1.17, so when completions are enabled, we will use a
bundled 1.17 runtime of Elixir, instead of the Elixir in the user's
path.

This is a tradeoff, but I think one that is worthwhile in the name of
progress and improving the language and ecosystem.

Once completions exit experimental status, this means that Next LS will
always run with a bundled copy of Elixir of Elixir unless the user's
local copy is sufficiently new. This can be controlled via a setting.

Related #45
Closes #360
Closes #334
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment