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

docs: add a contributing guide for typos-lsp #70

Merged
merged 2 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Contributing to `typos-lsp`

This document contains information on how to contribute to the `typos-lsp` crate, which is the implementation of the Language Server Protocol (LSP) server.

The source code of `typos-lsp` can be found in the [crates/typos-lsp/](./crates/typos-lsp/) directory.

Make sure you have installed the rust toolchain with [rustup](https://rust-lang.github.io/rustup/index.html).

## Setting up your development environment

### How to run tests

```sh
cargo test
```

### How to run the LSP server locally for development

First, compile the LSP server:

```sh
cargo build
```

Next, configure your editor to launch the LSP server.

#### Running locally in Neovim

For example, in Neovim, you can use the [sample neovim LSP config](docs/neovim-lsp-config.md) in the following way:

```lua
-- Set the path of the LSP server to the compiled binary on your disk
require('lspconfig').typos_lsp.setup({
-- ... other settings from the example
cmd = { "/Users/me/git/typos-lsp/target/debug/typos-lsp" },
})
```

To test your configuration, you can use the following methods:

- open e.g. [crates/typos-lsp/tools/test.txt](crates/typos-lsp/tools/test.txt). You should see errors when opening the file.
- you can also run `:LspInfo` in Neovim to see the status of the LSP server.
- you can run `cargo clean` in the root directory of the project. After this, you can make sure Neovim displays errors when opening a file. Once finished, run `cargo build` to fix this

<!-- markdownlint-disable-file line-length -->
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,7 @@ Config files will be read from the workspace folder or its parents. If there is
## Why aren't my misspellings being corrected?

To minimise false-positives `typos` only suggests corrections for known misspellings, rather than unknown words like a traditional spell-checker. For more info see [Why was ... not corrected?](https://github.com/crate-ci/typos?tab=readme-ov-file#why-was--not-corrected).

## Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md) to get started.