tekumara / typos-lsp

Source code spell checker for Visual Studio Code, Neovim and other LSP clients
https://marketplace.visualstudio.com/items?itemName=tekumara.typos-vscode
MIT License
162 stars 4 forks source link

WIP: feat: code action to add a misspelling to the config file #72

Open mikavilpas opened 4 weeks ago

mikavilpas commented 4 weeks ago

Here's a draft on what could become the solution for https://github.com/tekumara/typos-lsp/issues/12

This adds a code action like this:

image

Selecting the code action will make the lsp server to edit the configuration file. Here's what the edits look like in this repository:

image

Requesting feedback

Some things are a bit open right now, and I'd like to discuss how they should be worked on:

  1. Do you think this general idea is valid? Or should another idea be attempted?
  2. The typos configuration can be overridden on each directory level, so I started a scheme that would allow choosing the configuration file to add the misspelling to. The starting directory (typically the project root, I guess?) is always suggested - the others should be suggested only if they exist. Do you think this is a good idea?
  3. Tests obviously need to be added - I think this could be tested quite thoroughly as the existing tests looked really good.
  4. Error handling is not as clean as I would like. I have worked in some OS rust projects that use anyhow, but I couldn't find a way to use it since the tower lsp crate requires a certain error type 😓 Maybe some trait implementations could be added that could automatically handle this?
  5. Reloading the configuration has not been implemented in the project yet, as far as I can tell. I think this needs to be solved as currently the misspellings are ignored only after the LSP server has been restarted.