elijah-potter / harper

The Grammar Checker for Developers
https://writewithharper.com
Apache License 2.0
1.93k stars 37 forks source link

Using with Vim #137

Open qsantos opened 2 months ago

qsantos commented 2 months ago

Using regular Vim and https://github.com/prabirshrestha/vim-lsp, I get stuck with harper-ls: starting (LspStatus). I am using the configuration below:

if executable('harper-ls')
    " cargo install harper-ls --locked
    au User lsp_setup call lsp#register_server({
        \ 'name': 'harper-ls',
        \ 'cmd': {server_info->['harper-ls']},
        \ 'allowlist': ['*'],
        \ })
endif

I might be misunderstanding something, either in the usage of vim-lsp, of that of harper.

Also might be useful:

$ cat vim-lsp.log
Thu Sep  5 06:16:41 2024:["s:on_text_document_did_close()",1]
Thu Sep  5 06:16:41 2024:["lsp#register_server","server registered","harper-ls"]
Thu Sep  5 06:16:41 2024:["s:on_text_document_did_open()",1,"markdown","/home/qsantos/src/vihn","file:///home/qsantos/src/vihn/CHANGELOG.md"]
Thu Sep  5 06:16:41 2024:["Starting server","harper-ls",["harper-ls"]]
Thu Sep  5 06:16:41 2024:[{"response":{"data":{"__data__":"vim-lsp","lsp_id":1,"server_name":"harper-ls"},"message":"started lsp server successfully"}}]
Thu Sep  5 06:16:41 2024:[{"response":{"error":{"data":{"lsp_id":1,"__error__":"vim-lsp","server_name":"harper-ls"},"code":0,"message":"ignore initialization lsp server due to empty root_uri"}}}]
Thu Sep  5 06:16:41 2024:["--->",1,"harper-ls",{"method":"initialize","params":{"rootUri":"file:///home/qsantos/src/vihn","capabilities":{"workspace":{"workspaceFolders":false,"configuration":true,"symbol":{"dynamicRegistration":false},"applyEdit":true},"window":{"workDoneProgress":false},"textDocument":{"callHierarchy":{"dynamicRegistration":false},"rename":{"prepareSupport":true,"dynamicRegistration":false,"prepareSupportDefaultBehavior":1},"codeAction":{"isPreferredSupport":true,"disabledSupport":true,"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}},"dynamicRegistration":false},"completion":{"completionItem":{"snippetSupport":false,"resolveSupport":{"properties":["additionalTextEdits"]},"documentationFormat":["markdown","plaintext"]},"dynamicRegistration":false,"completionItemKind":{"valueSet":[10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,1,2,3,4,5,6,7,8,9]}},"formatting":{"dynamicRegistration":false},"codeLens":{"dynamicRegistration":false},"inlayHint":{"dynamicRegistration":false},"hover":{"dynamicRegistration":false,"contentFormat":["markdown","plaintext"]},"rangeFormatting":{"dynamicRegistration":false},"declaration":{"dynamicRegistration":false,"linkSupport":true},"references":{"dynamicRegistration":false},"typeHierarchy":{"dynamicRegistration":false},"foldingRange":{"rangeLimit":5000,"dynamicRegistration":false,"lineFoldingOnly":true},"documentSymbol":{"symbolKind":{"valueSet":[10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,1,2,3,4,5,6,7,8,9]},"dynamicRegistration":false,"labelSupport":false,"hierarchicalDocumentSymbolSupport":false},"publishDiagnostics":{"relatedInformation":true},"synchronization":{"dynamicRegistration":false,"willSaveWaitUntil":false,"willSave":false,"didSave":true},"documentHighlight":{"dynamicRegistration":false},"implementation":{"dynamicRegistration":false,"linkSupport":true},"typeDefinition":{"dynamicRegistration":false,"linkSupport":true},"semanticTokens":{"serverCancelSupport":false,"requests":{"full":false,"range":false},"multilineTokenSupport":false,"dynamicRegistration":false,"overlappingTokenSupport":false,"tokenTypes":["type","class","enum","interface","struct","typeParameter","parameter","variable","property","enumMember","event","function","method","macro","keyword","modifier","comment","string","number","regexp","operator"],"tokenModifiers":[],"formats":["relative"]},"signatureHelp":{"dynamicRegistration":false},"definition":{"dynamicRegistration":false,"linkSupport":true}}},"rootPath":"/home/qsantos/src/vihn","clientInfo":{"name":"vim-lsp"},"processId":33194,"trace":"off"}}]
elijah-potter commented 2 months ago

It looks like you're missing the --stdio flag from your cmd. Add that and let me know if it works then.

qsantos commented 2 months ago

Thanks! That was it. I can now see diagnostics appear in the logs of harper. vim-lsp lets me see their position in the gutter, and I can navigate to the next one using LspNextDiagnostic.

However, I cannot see the diagnostics themselves in Vim. I don't have anything in the location list nor the quicklist either. Any idea where this can be coming from? Sorry, I am not super familiar with vim-lsp either…