Skip to content

Commit

Permalink
LS reference
Browse files Browse the repository at this point in the history
  • Loading branch information
lpil committed Jul 19, 2024
1 parent 1830fdb commit 3efce3e
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 4 deletions.
8 changes: 5 additions & 3 deletions documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ layout: page

## Gleam references

- [The Command line reference](/writing-gleam/command-line-reference)
- [The Gleam Language Server reference](/language-server)
- [The gleam.toml config file reference](/writing-gleam/gleam-toml)
- [The Gleam Package Index](https://packages.gleam.run)
- [Gleam's standard library documentation](https://hexdocs.pm/gleam_stdlib/)
- [The standard library documentation](https://hexdocs.pm/gleam_stdlib/)
- [The "Awesome Gleam" resource list](https://github.com/gleam-lang/awesome-gleam)
- [gleam.toml config file reference](/writing-gleam/gleam-toml)
- [Command line reference](/writing-gleam/command-line-reference)


## Cheatsheets

Expand Down
78 changes: 77 additions & 1 deletion language-server.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
layout: page
title: The Gleam Language Server Manual
title: The Gleam Language Server reference
subtitle: Gleam IDE features for all editors
---

Expand Down Expand Up @@ -121,16 +121,92 @@ want to configure your code to run this automatically when you save a file.

## Hover

The language server will show documentation, types, and other information when
hovering on:

- Constants.
- Import statements, including unqualified values and types.
- Module functions.
- Patterns.
- The `..` used to ignore additional fields in record pattern.
- Type annotations.
- Values.

## Go-to definition

The language server supports go-to definition for:

- Constants.
- Functions.
- Import statements, including unqualified values and types.
- Type annotations.
- Variables.

## Code completion

The language server support completion of:

- Modules in import statements.
- Unqualified types and values in import statements.
- Type constructors in type annotations.
- Record fields.
- Functions and constants defined in the same module.
- Functions and constants defined in other modules, automatically adding import
statements if the module has not yet been imported.

## Code Actions

### Remove unused imports

This code action can be used to delete unused import statements from a module.

Given this code:

```gleam
import gleam/io
import gleam/list
pub fn main() {
io.println("Hello, Joe!")
}
```

If your cursor is within the unused `import gleam/list` import the code action
will be suggested, and if run the module will be updated to this:

```gleam
import gleam/io
pub fn main() {
io.println("Hello, Joe!")
}
```

### Remove redundant tuples

This code action removes redundant tuples from case expression subjects and
patterns.

Given this code:

```gleam
case #(a, b) {
#(1, 2) -> todo
_ -> todo
}
```

If your cursor is within the case expression the code action will be suggested,
and if run the module will be updated to this:

```gleam
case a, b {
1, 2 -> todo
_, _ -> todo
}
```


# Security

The language server does not perform code generation or compile Erlang or Elixir
Expand Down

0 comments on commit 3efce3e

Please sign in to comment.