ZIm/crates/languages/src
Nathan Sobo 7abb63cfda
Improve the ergonomics of creating local buffers (#10347)
This PR renames `language::Buffer::new` to `language::Buffer::local` and
simplifies its interface. Instead of taking a replica id (which should
always be 0 for the local case) and a `BufferId`, which was awkward and
verbose to construct, it simply takes text and a `cx`.

It uses the `cx` to derive a `BufferId` from the `EntityId` associated
with the `cx`, which should always be positive based on the following
analysis...

We convert the entity id to a u64 using this method on `EntityId`, which
is defined by macros in the `slotmap` crate:

```rust
    pub fn as_ffi(self) -> u64 {
        (u64::from(self.version.get()) << 32) | u64::from(self.idx)
    }
```

If you look at the type of `version` in `KeyData`, it is non-zero:

```rust
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct KeyData {
    idx: u32,
    version: NonZeroU32,
}
```

This commit also adds `Context::reserve_model` and
`Context::insert_model` to determine a model's entity ID before it is
created, which we need in order to assign a `BufferId` in the background
when loading a buffer asynchronously.

Release Notes:

- N/A

---------

Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com>
2024-04-10 08:32:51 -06:00
..
bash File context for assistant panel (#9712) 2024-03-29 13:55:01 -07:00
c chore: Extract languages from zed crate (#8270) 2024-02-23 15:56:08 +01:00
cpp More C++ path suffixes (#9761) 2024-03-25 15:23:09 -04:00
css Add outlines for CSS (#8706) 2024-03-14 20:31:52 -04:00
elixir Add the ability for extensions to provide language settings (#10296) 2024-04-08 19:17:12 -04:00
elm chore: Extract languages from zed crate (#8270) 2024-02-23 15:56:08 +01:00
erb chore: Extract languages from zed crate (#8270) 2024-02-23 15:56:08 +01:00
glsl chore: Extract languages from zed crate (#8270) 2024-02-23 15:56:08 +01:00
go Add the ability for extensions to provide language settings (#10296) 2024-04-08 19:17:12 -04:00
gomod File context for assistant panel (#9712) 2024-03-29 13:55:01 -07:00
gowork File context for assistant panel (#9712) 2024-03-29 13:55:01 -07:00
hcl chore: Extract languages from zed crate (#8270) 2024-02-23 15:56:08 +01:00
heex chore: Extract languages from zed crate (#8270) 2024-02-23 15:56:08 +01:00
javascript Add the ability for extensions to provide language settings (#10296) 2024-04-08 19:17:12 -04:00
jsdoc Add JSDoc syntax highlighting support (#7826) 2024-03-15 15:17:06 -06:00
json Add the ability for extensions to provide language settings (#10296) 2024-04-08 19:17:12 -04:00
lua Update Lua config.toml (#9260) 2024-03-13 00:32:45 -04:00
markdown Add the ability for extensions to provide language settings (#10296) 2024-04-08 19:17:12 -04:00
nix chore: Extract languages from zed crate (#8270) 2024-02-23 15:56:08 +01:00
nu chore: Extract languages from zed crate (#8270) 2024-02-23 15:56:08 +01:00
ocaml Add the ability for extensions to provide language settings (#10296) 2024-04-08 19:17:12 -04:00
ocaml-interface Add the ability for extensions to provide language settings (#10296) 2024-04-08 19:17:12 -04:00
proto chore: Extract languages from zed crate (#8270) 2024-02-23 15:56:08 +01:00
python chore: Extract languages from zed crate (#8270) 2024-02-23 15:56:08 +01:00
racket chore: Extract languages from zed crate (#8270) 2024-02-23 15:56:08 +01:00
regex Add regex syntax highlighting for JS and TS (#7851) 2024-03-18 09:49:01 -06:00
ruby Improve Ruby Syntax (#10255) 2024-04-08 13:12:24 +02:00
rust Use first line comment prefix when toggling comments (#10335) 2024-04-09 17:22:47 -04:00
scheme chore: Extract languages from zed crate (#8270) 2024-02-23 15:56:08 +01:00
terraform Add the ability for extensions to provide language settings (#10296) 2024-04-08 19:17:12 -04:00
terraform-vars chore: Extract languages from zed crate (#8270) 2024-02-23 15:56:08 +01:00
tsx Add the ability for extensions to provide language settings (#10296) 2024-04-08 19:17:12 -04:00
typescript Add the ability for extensions to provide language settings (#10296) 2024-04-08 19:17:12 -04:00
vue Add Tailwind autocomplete for Vue (#10078) 2024-04-02 10:34:41 -04:00
yaml Add the ability for extensions to provide language settings (#10296) 2024-04-08 19:17:12 -04:00
c.rs Improve the ergonomics of creating local buffers (#10347) 2024-04-10 08:32:51 -06:00
css.rs Improve the ergonomics of creating local buffers (#10347) 2024-04-10 08:32:51 -06:00
deno.rs Add the ability for extensions to provide language settings (#10296) 2024-04-08 19:17:12 -04:00
elixir.rs Add the ability for extensions to provide language settings (#10296) 2024-04-08 19:17:12 -04:00
elm.rs Add language_server_workspace_configuration to extension API (#10212) 2024-04-05 17:04:07 -04:00
go.rs Add ability to specify binary path/args for gopls (#9803) 2024-03-26 07:09:06 +01:00
json.rs Add language_server_workspace_configuration to extension API (#10212) 2024-04-05 17:04:07 -04:00
lib.rs Add the ability for extensions to provide language settings (#10296) 2024-04-08 19:17:12 -04:00
lua.rs Fix issues with extension API that come up when moving Svelte into an extension (#9611) 2024-03-22 17:29:06 -07:00
nu.rs Add ability to specify binary path/args for rust-analyzer (#9293) 2024-03-13 18:42:03 +01:00
ocaml.rs Add ability to specify binary path/args for rust-analyzer (#9293) 2024-03-13 18:42:03 +01:00
python.rs Improve the ergonomics of creating local buffers (#10347) 2024-04-10 08:32:51 -06:00
ruby.rs Add ability to specify binary path/args for rust-analyzer (#9293) 2024-03-13 18:42:03 +01:00
rust.rs Improve the ergonomics of creating local buffers (#10347) 2024-04-10 08:32:51 -06:00
tailwind.rs Add language_server_workspace_configuration to extension API (#10212) 2024-04-05 17:04:07 -04:00
terraform.rs Fix issues with extension API that come up when moving Svelte into an extension (#9611) 2024-03-22 17:29:06 -07:00
typescript.rs Improve the ergonomics of creating local buffers (#10347) 2024-04-10 08:32:51 -06:00
vue.rs Pin Vue language server to 1.8 (#9846) 2024-03-27 14:23:10 +01:00
yaml.rs Add language_server_workspace_configuration to extension API (#10212) 2024-04-05 17:04:07 -04:00