harper_zed icon indicating copy to clipboard operation
harper_zed copied to clipboard

feat: ls settings override.

Open nuIIpointerexception opened this issue 1 year ago • 10 comments

closes #3 and #5

add basic settings support. update readme to show configuration. bump version to 0.0.5

usage:

"lsp": {
  "harper-ls": {
    "binary": {
      "path": "/path/to/harper-ls" # if you wish to override else download automatically.
    },
    "settings": {
      "harper-ls": {
        "userDictPath": "~/dict.txt",
        "fileDictPath": "~/.harper/",
        "diagnosticSeverity": "hint", // hint, warning, error, information
        "linters": {
          "spell_check": true,
          "spelled_numbers": true,
          "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
        },
        codeActions = {
          forceStable = false // Force code actions to appear in "stable" positions
        }
      }
    }
  }
}

nuIIpointerexception avatar Nov 21 '24 21:11 nuIIpointerexception

I'll try to pass a default config if none provided later, so that people won't be getting #5

nuIIpointerexception avatar Nov 21 '24 22:11 nuIIpointerexception

Fixes now #5 too. We will now provide a barebones config if none is provided.

I think so far it looks good and does as much as we can without messing with harper source.

nuIIpointerexception avatar Nov 21 '24 23:11 nuIIpointerexception

@jollywatt and/or @failable can you test this locally to verify it fixes your issues? I find it hard to reproduce the error myself, would prefer to have verification before releasing again.

You can clone this repo/PR and install it as a dev extension: https://zed.dev/docs/extensions/developing-extensions#developing-an-extension-locally

Stef16Robbe avatar Nov 25 '24 15:11 Stef16Robbe

If I choose Install Dev Extension and select the repo directory, absolutely nothing happens. Do I have to build the extension locally first?

Edit: rustc is installed, but Zed emits the log message:

2024-11-25T15:44:23.663865Z [INFO] compiling Rust extension /Users/xxx/Documents/harper_zed
2024-11-25T15:44:23.664423Z [ERROR] failed to compile Rust extension

Caused by:
    0: failed to run rustc
    1: No such file or directory (os error 2)

Jollywatt avatar Nov 25 '24 15:11 Jollywatt

Try to compile it locally First and then you will likely See what the error is. I suspect it might be a faulty or incomplete Installation?

Try to compile it against the wasm Target that zed uses:

cargo build --target wasm32-wasip1

nuIIpointerexception avatar Nov 25 '24 19:11 nuIIpointerexception

@jollywatt and/or @failable can you test this locally to verify it fixes your issues? I find it hard to reproduce the error myself, would prefer to have verification before releasing again.

You can clone this repo/PR and install it as a dev extension: https://zed.dev/docs/extensions/developing-extensions#developing-an-extension-locally

Also, I had this error only similarly. The Harper-ls expects a config but it wasnt provided and it threw the error for me in the lsp logs, but it still worked? For me this made it dissapear,but like i Said it was the same message, but it didnt impact me.

nuIIpointerexception avatar Nov 25 '24 19:11 nuIIpointerexception

harper_zed compiles fine locally, but Zed always gives the log error above. (Zed was freshly installed.)

Jollywatt avatar Nov 25 '24 23:11 Jollywatt

harper_zed compiles fine locally, but Zed always gives the log error above. (Zed was freshly installed.)

Alright, Verify a couple of things for me please:

Rustup with all the necessary stuff has been installed and the appropriate Target works to compile locally even when deleting in the following files: .cargo folder rust-toolchain.toml

Maybe clone it again First. If that works, try to compile it as a dev extension in zed again.

A couple of things: On what Platform are you? What is your Zed Version? Does an older version of this repo work?

Do you start Zed from a menu launcher Like dmenu or rofi? (some guy has path issues there)

Also you might try this: https://stackoverflow.com/a/75676790/22845956

nuIIpointerexception avatar Nov 26 '24 04:11 nuIIpointerexception

Hello, Any news on this? I'm OK to test but some pointer on how to woul be great :)

I'd like to have a "project" file per git repositories so we can make linting on PR also, do you think it would be feasible by configuring something like:

"lsp": {
  "harper-ls": {
    "settings": {
      "harper-ls": {
        "userDictPath": "./harper/accept.txt"
     }
  }

thanks !

sdesbure avatar Feb 06 '25 07:02 sdesbure

I have not been able to get "Add to dictionary" Code Actions to appear using this fork as a dev extension.

I took a brief view of harper's LSP integration and my understanding is that the code action is not triggering based on harper's internal heuristics rather than configuration. This may be incorrect.

Has anyone else been able to configure dictionary additions via Code Actions (cc @nuIIpointerexception)

jryio avatar Feb 28 '25 13:02 jryio

Any update on this? This is a critical feature that is a deal breaker for me as I can't change the dialect to British.

ajvogel avatar Jun 23 '25 09:06 ajvogel

Yeah this would be super handy if it works, I am also :( at it suggesting yank spellings for everything.

radiosilence avatar Jul 07 '25 13:07 radiosilence

closing, fixed in #10

Stef16Robbe avatar Jul 10 '25 17:07 Stef16Robbe