37 releases (11 breaking)

0.12.0 Oct 13, 2024
0.10.0 Aug 31, 2024
0.9.0 Jul 25, 2024
0.8.3 Mar 25, 2024

#12 in Text editors

Download history 6/week @ 2024-07-18 229/week @ 2024-07-25 13/week @ 2024-08-01 120/week @ 2024-08-08 165/week @ 2024-08-15 22/week @ 2024-08-22 237/week @ 2024-08-29 57/week @ 2024-09-05 233/week @ 2024-09-12 113/week @ 2024-09-19 65/week @ 2024-09-26 45/week @ 2024-10-03 191/week @ 2024-10-10 52/week @ 2024-10-17 21/week @ 2024-10-24 17/week @ 2024-10-31

288 downloads per month

Apache-2.0

330KB
7K SLoC

harper-ls

harper-ls is the Language Server Protocol frontend for Harper. Out of the box, it has built-in support for parsing the comments of most programming languages, as well as any and all markdown files.

Installation

How you choose to install harper-ls depends on your use-case. Right now, we only directly support usage through nvim-lspconfig. Refer to the linked documentation for more information.

If you happen to use mason.nvim, installation will be pretty straightforward. harper-ls is in the official Mason registry, so you can install it the same way you install anything through Mason.

If you don't install your LSPs through Mason, we have binary releases available on GitHub or you can use one of a number of package managers.

Zed

The Zed plugin will automatically download harper-ls to your system if you don't already have it.

Cargo

If you have Rust installed, you're in luck! To install harper-ls, simply run:

cargo install harper-ls --locked

Arch Linux

Harper is available through the extra repo:

sudo pacman -S harper

Dictionaries

harper-ls has three kinds of dictionaries: user, file-local, and static dictionaries.

User Dictionary

Each user of harper-ls has their own dictionary, located in the following directories on each operating system:

Operating System Location
Linux $XDG_CONFIG_HOME/harper-ls/
MacOS $HOME/Library/Application Support/harper-ls/
Windows {FOLDERID_LocalAppData}/harper-ls/

This dictionary is a simple line-separated word list in plain-text. You can add and remove words at will. You can add to the user dictionary with code actions on misspelled words.

Configuration

You don't have to stick with the default locations (listed above). If you use Neovim, you can set the location of the user dictionary with the userDictPath key, and the file dictionary with the fileDictPath key:

lspconfig.harper_ls.setup {
  settings = {
    ["harper-ls"] = {
      userDictPath = "~/dict.txt",
      fileDictPath = "~/.harper/",
    }
  },
}

You can also toggle any particular linter. The default values are shown below:

lspconfig.harper_ls.setup {
  settings = {
    ["harper-ls"] = {
      linters = {
        spell_check = true,
        spelled_numbers = false,
        an_a = true,
        sentence_capitalization = true,
        unclosed_quotes = true,
        wrong_quotes = false,
        long_sentences = true,
        repeated_words = true,
        spaces = true,
        matcher = true,
        correct_number_suffix = true,
        number_suffix_capitalization = true,
        multiple_sequential_pronouns = true,
        linking_verbs = false,
        avoid_curses = true,
        terminating_conjunctions = true
      }
    }
  },
}

By default, harper-ls will mark all diagnostics with HINT. If you want to configure this, refer below:

lspconfig.harper_ls.setup {
  settings = {
    ["harper-ls"] = {
        diagnosticSeverity = "hint" -- Can also be "information", "warning", or "error"
    }
  },
}

You can also configure how harper-ls displays code actions. For example, to make code actions appear in "stable" positions, use the following configuration:

lspconfig.harper_ls.setup {
  settings = {
    ["harper-ls"] = {
      codeActions = {
        forceStable = true
      }
    }
  },
}

This was added in response to issue #89.

File-Local Dictionary

Sometimes, you'll encounter a word (or name) that is only valid within the context of a specific file. In this case, you can use the code action that adds the word to the file-local dictionary. Any words added to this dictionary will, like the name implies, only be included in the dictionary when performing corrections on the file at that specific path.

You can find the file-local dictionaries in the following directories on each operation system:

Operating System Location
Linux $XDG_DATA_HOME/harper-ls/file_dictionaries or $HOME/.local/share/harper-ls/file_dictionaries
MacOS $HOME/Library/Application Support/harper-ls/file_dictionaries
Windows {FOLDERID_LocalAppData}/harper-ls/file_dictionaries

The format of these files is identical to user dictionaries.

Static Dictionary

The static dictionary is built into the binary and is (as of now) immutable. It contains almost all words you could possibly encounter.

I do take pull requests or issues for adding words to the static dictionary. It is composed of two files: harper-core/dictionary.dict and harper-core/affixes.json If you just want to add a proper noun, try running just addnoun <your noun>.

Dependencies

~164MB
~4.5M SLoC