neovim / nvim-lspconfig

Quickstart configs for Nvim LSP
Apache License 2.0
10.64k stars 2.08k forks source link

Can't reformat file with hls. #734

Closed Kazimazi closed 3 years ago

Kazimazi commented 3 years ago

Nothing happens when I use vim.lsp.buf.formatting()

LSP log

Log file [ ERROR ] 2021-02-15T09:52:44+0100 ] ...im-nightly-master/share/nvim/runtime/lua/vim/lsp/rpc.lua:455 ] "rpc" "haskell-language-server-wrapper" "stderr" 'Module "/home/kazimazi/dev/haskell/a" is loaded by Cradl' [ ERROR ] 2021-02-15T09:52:44+0100 ] ...im-nightly-master/share/nvim/runtime/lua/vim/lsp/rpc.lua:455 ] "rpc" "haskell-language-server-wrapper" "stderr" 'e: Cradle {cradleRootDir = "/home/kazimazi/dev/haskell", cradleOptsProg = C' [ ERROR ] 2021-02-15T09:52:44+0100 ] ...im-nightly-master/share/nvim/runtime/lua/vim/lsp/rpc.lua:455 ] "rpc" "haskell-language-server-wrapper" "stderr" "radleAction: Default}\nRun entered for haskell-language-server-wrapper(haskell-language-se" [ ERROR ] 2021-02-15T09:52:44+0100 ] ...im-nightly-master/share/nvim/runtime/lua/vim/lsp/rpc.lua:455 ] "rpc" "haskell-language-server-wrapper" "stderr" "rver-wrapper) Version 0.9.0.0 x86_64 ghc-8.10.4\nCurrent directory: /home/kazimazi/" [ ERROR ] 2021-02-15T09:52:44+0100 ] ...im-nightly-master/share/nvim/runtime/lua/vim/lsp/rpc.lua:455 ] "rpc" "haskell-language-server-wrapper" "stderr" 'dev/haskell\nOperating system: linux\nArguments: ["--lsp"]\nCradle directory: /hom' [ ERROR ] 2021-02-15T09:52:44+0100 ] ...im-nightly-master/share/nvim/runtime/lua/vim/lsp/rpc.lua:455 ] "rpc" "haskell-language-server-wrapper" "stderr" "e/kazimazi/dev/haskell\nCradle type: Default\n" [ ERROR ] 2021-02-15T09:52:44+0100 ] ...im-nightly-master/share/nvim/runtime/lua/vim/lsp/rpc.lua:455 ] "rpc" "haskell-language-server-wrapper" "stderr" "\nTool versions found on the $PATH\ncabal:\t\tNot found\nstack:\t\tNot found\nghc:\t\t" [ ERROR ] 2021-02-15T09:52:44+0100 ] ...im-nightly-master/share/nvim/runtime/lua/vim/lsp/rpc.lua:455 ] "rpc" "haskell-language-server-wrapper" "stderr" "8.10.4\n\n\nConsulting the cradle to get project GHC version...\n" [ ERROR ] 2021-02-15T09:52:44+0100 ] ...im-nightly-master/share/nvim/runtime/lua/vim/lsp/rpc.lua:455 ] "rpc" "haskell-language-server-wrapper" "stderr" 'Project GHC version: 8.10.4\nhaskell-language-server exe candidates: ["haskell-language-server-8.' [ ERROR ] 2021-02-15T09:52:44+0100 ] ...im-nightly-master/share/nvim/runtime/lua/vim/lsp/rpc.lua:455 ] "rpc" "haskell-language-server-wrapper" "stderr" '10.4","haskell-language-server-8.10","haskell-language-server"]\nLaunching haskell-language-server' [ ERROR ] 2021-02-15T09:52:44+0100 ] ...im-nightly-master/share/nvim/runtime/lua/vim/lsp/rpc.lua:455 ] "rpc" "haskell-language-server-wrapper" "stderr" " exe at:/etc/profiles/per-user/kazimazi/bin/haskell-language-server-8.10.4\n" [ ERROR ] 2021-02-15T09:52:44+0100 ] ...im-nightly-master/share/nvim/runtime/lua/vim/lsp/rpc.lua:455 ] "rpc" "haskell-language-server-wrapper" "stderr" "haskell-language-server version: 0.9.0.0 (GHC: 8.10.4) (PATH: /nix/store/5np6b0symsk0pxk61if5ah00pwcj3mm8-haskell-lan" [ ERROR ] 2021-02-15T09:52:44+0100 ] ...im-nightly-master/share/nvim/runtime/lua/vim/lsp/rpc.lua:455 ] "rpc" "haskell-language-server-wrapper" "stderr" "guage-server-0.9.0.0/bin/haskell-language-server)\n" [ ERROR ] 2021-02-15T09:52:44+0100 ] ...im-nightly-master/share/nvim/runtime/lua/vim/lsp/rpc.lua:455 ] "rpc" "haskell-language-server-wrapper" "stderr" "Starting (haskell" [ ERROR ] 2021-02-15T09:52:44+0100 ] ...im-nightly-master/share/nvim/runtime/lua/vim/lsp/rpc.lua:455 ] "rpc" "haskell-language-server-wrapper" "stderr" "-language-server)LSP server...\n with arguments: " [ ERROR ] 2021-02-15T09:52:44+0100 ] ...im-nightly-master/share/nvim/runtime/lua/vim/lsp/rpc.lua:455 ] "rpc" "haskell-language-server-wrapper" "stderr" "LspArguments {argLSP = True, argsCwd = Nothing, " [ ERROR ] 2021-02-15T09:52:44+0100 ] ...im-nightly-master/share/nvim/runtime/lua/vim/lsp/rpc.lua:455 ] "rpc" "haskell-language-server-wrapper" "stderr" "argFiles = [], argsShakeProfiling = Not" [ ERROR ] 2021-02-15T09:52:44+0100 ] ...im-nightly-master/share/nvim/runtime/lua/vim/lsp/rpc.lua:455 ] "rpc" "haskell-language-server-wrapper" "stderr" "hing, argsTesting = False, argsExamplePlu" [ ERROR ] 2021-02-15T09:52:44+0100 ] ...im-nightly-master/share/nvim/runtime/lua/vim/lsp/rpc.lua:455 ] "rpc" "haskell-language-server-wrapper" "stderr" "gin = False, argsDebugOn = False, argsLogFile = Nothing, argsThreads = 0, argsProjectGhcVersion = " [ ERROR ] 2021-02-15T09:52:44+0100 ] ...im-nightly-master/share/nvim/runtime/lua/vim/lsp/rpc.lua:455 ] "rpc" "haskell-language-server-wrapper" "stderr" "False}\n with plugins: " [ ERROR ] 2021-02-15T09:52:44+0100 ] ...im-nightly-master/share/nvim/runtime/lua/vim/lsp/rpc.lua:455 ] "rpc" "haskell-language-server-wrapper" "stderr" '[PluginId "brittany",PluginId "class",PluginId "eval",PluginId "floskell"' [ ERROR ] 2021-02-15T09:52:44+0100 ] ...im-nightly-master/share/nvim/runtime/lua/vim/lsp/rpc.lua:455 ] "rpc" "haskell-language-server-wrapper" "stderr" ',PluginId "fourmolu",PluginId "ghcide-code-actions",PluginId "ghcide-completions",PluginId "ghcide-hov' [ ERROR ] 2021-02-15T09:52:44+0100 ] ...im-nightly-master/share/nvim/runtime/lua/vim/lsp/rpc.lua:455 ] "rpc" "haskell-language-server-wrapper" "stderr" 'er-and-symbols",PluginId "ghcide-type-lenses",PluginId "haddockComments",PluginId "hlint",PluginId "impor' [ ERROR ] 2021-02-15T09:52:44+0100 ] ...im-nightly-master/share/nvim/runtime/lua/vim/lsp/rpc.lua:455 ] "rpc" "haskell-language-server-wrapper" "stderr" 'tLens",PluginId "moduleName",PluginId "ormolu",Plugi' [ ERROR ] 2021-02-15T09:52:44+0100 ] ...im-nightly-master/share/nvim/runtime/lua/vim/lsp/rpc.lua:455 ] "rpc" "haskell-language-server-wrapper" "stderr" 'nId "pragmas",PluginId "retrie",PluginId "splice",PluginId "stylish-haskell",PluginId "tactic"]\n in' [ ERROR ] 2021-02-15T09:52:44+0100 ] ...im-nightly-master/share/nvim/runtime/lua/vim/lsp/rpc.lua:455 ] "rpc" "haskell-language-server-wrapper" "stderr" " directory: /home/kazimazi/dev/haskell\nIf you are see" [ ERROR ] 2021-02-15T09:52:44+0100 ] ...im-nightly-master/share/nvim/runtime/lua/vim/lsp/rpc.lua:455 ] "rpc" "haskell-language-server-wrapper" "stderr" "ing this in a terminal, you probably should have run g" [ ERROR ] 2021-02-15T09:52:44+0100 ] ...im-nightly-master/share/nvim/runtime/lua/vim/lsp/rpc.lua:455 ] "rpc" "haskell-language-server-wrapper" "stderr" "hcide WITHOUT the --lsp option!\n" [ ERROR ] 2021-02-15T09:52:44+0100 ] ...im-nightly-master/share/nvim/runtime/lua/vim/lsp/rpc.lua:455 ] "rpc" "haskell-language-server-wrapper" "stderr" " " [ ERROR ] 2021-02-15T09:52:44+0100 ] ...im-nightly-master/share/nvim/runtime/lua/vim/lsp/rpc.lua:455 ] "rpc" "haskell-language-server-wrapper" "stderr" "Started LSP server in 0.00s\n" [ ERROR ] 2021-02-15T09:52:44+0100 ] ...ghtly-master/share/nvim/runtime/lua/vim/lsp/handlers.lua:375 ] 'haskell-lsp:configuration parse error. RequestMessage {_jsonrpc = "2.0", _id = IdInt 1, _method = Initialize, _params = InitializeParams {_processId = Just 1745, _rootPath = Just "/home/kazimazi/dev/haskell", _rootUri = Just (Uri {getUri = "file:///home/kazimazi/dev/haskell"}), _initializationOptions = Just (Object (fromList [])), _capabilities = ClientCapabilities {_workspace = Just (WorkspaceClientCapabilities {_applyEdit = Just True, _workspaceEdit = Nothing, _didChangeConfiguration = Nothing, _didChangeWatchedFiles = Nothing, _symbol = Just (SymbolClientCapabilities {_dynamicRegistration = Just False, _symbolKind = Just (SymbolKindClientCapabilities {_valueSet = Just (List [SkFile,SkModule,SkNamespace,SkPackage,SkClass,SkMethod,SkProperty,SkField,SkConstructor,SkEnum,SkInterface,SkFunction,SkVariable,SkConstant,SkString,SkNumber,SkBoolean,SkArray,SkObject,SkKey,SkNull,SkEnumMember,SkStruct,SkEvent,SkOperator,SkTypeParameter])})}), _executeCommand = Nothing, _workspaceFolders = Just True, _configuration = Just True}), _textDocument = Just (TextDocumentClientCapabilities {_synchronization = Just (SynchronizationTextDocumentClientCapabilities {_dynamicRegistration = Just False, _willSave = Just False, _willSaveWaitUntil = Just False, _didSave = Just True}), _completion = Just (CompletionClientCapabilities {_dynamicRegistration = Just False, _completionItem = Just (CompletionItemClientCapabilities {_snippetSupport = Just False, _commitCharactersSupport = Just False, _documentationFormat = Just (List [MkMarkdown,MkPlainText]), _deprecatedSupport = Just False, _preselectSupport = Just False, _tagSupport = Nothing}), _completionItemKind = Just (CompletionItemKindClientCapabilities {_valueSet = Just (List [CiText,CiMethod,CiFunction,CiConstructor,CiField,CiVariable,CiClass,CiInterface,CiModule,CiProperty,CiUnit,CiValue,CiEnum,CiKeyword,CiSnippet,CiColor,CiFile,CiReference,CiFolder,CiEnumMember,CiConstant,CiStruct,CiEvent,CiOperator,CiTypeParameter])}), _contextSupport = Just False}), _hover = Just (HoverClientCapabilities {_dynamicRegistration = Just False, _contentFormat = Just (List [MkMarkdown,MkPlainText])}), _signatureHelp = Just (SignatureHelpClientCapabilities {_dynamicRegistration = Just False, _signatureInformation = Just (SignatureInformationClientCapabilities {documentationFormat = Nothing})}), _references = Just (ReferencesClientCapabilities {_dynamicRegistration = Just False}), _documentHighlight = Just (DocumentHighlightClientCapabilities {_dynamicRegistration = Just False}), _documentSymbol = Just (DocumentSymbolClientCapabilities {_dynamicRegistration = Just False, _symbolKind = Just (DocumentSymbolKindClientCapabilities {_valueSet = Just (List [SkFile,SkModule,SkNamespace,SkPackage,SkClass,SkMethod,SkProperty,SkField,SkConstructor,SkEnum,SkInterface,SkFunction,SkVariable,SkConstant,SkString,SkNumber,SkBoolean,SkArray,SkObject,SkKey,SkNull,SkEnumMember,SkStruct,SkEvent,SkOperator,SkTypeParameter])}), _hierarchicalDocumentSymbolSupport = Just True}), _formatting = Nothing, _rangeFormatting = Nothing, _onTypeFormatting = Nothing, _definition = Just (DefinitionClientCapabilities {_dynamicRegistration = Nothing}), _typeDefinition = Just (TypeDefinitionClientCapabilities {_dynamicRegistration = Nothing}), _implementation = Just (ImplementationClientCapabilities {_dynamicRegistration = Nothing}), _codeAction = Just (CodeActionClientCapabilities {_dynamicRegistration = Just False, _codeActionLiteralSupport = Just (CodeActionLiteralSupport {_codeActionKind = CodeActionKindClientCapabilities {_valueSet = List [CodeActionUnknown "",CodeActionUnknown "Empty",CodeActionUnknown "QuickFix",CodeActionUnknown "Refactor",CodeActionUnknown "RefactorExtract",CodeActionUnknown "RefactorInline",CodeActionUnknown "RefactorRewrite",CodeActionUnknown "Source",CodeActionUnknown "SourceOrganizeImports",CodeActionQuickFix,CodeActionRefactor,CodeActionRefactorExtract,CodeActionRefactorInline,CodeActionRefactorRewrite,CodeActionSource,CodeActionSourceOrganizeImports]}})}), _codeLens = Nothing, _documentLink = Nothing, _colorProvider = Nothing, _rename = Just (RenameClientCapabilities {_dynamicRegistration = Just False, _prepareSupport = Just True}), _publishDiagnostics = Just (PublishDiagnosticsClientCapabilities {_relatedInformation = Just True, _tagSupport = Just (PublishDiagnosticsTagsClientCapabilities {_valueSet = List [DtUnnecessary,DtDeprecated]})}), _foldingRange = Nothing}), _window = Just (WindowClientCapabilities {_workDoneProgress = Just True}), _experimental = Nothing}, _trace = Just TraceOff, _workspaceFolders = Just (List [WorkspaceFolder {_uri = "file:///home/kazimazi/dev/haskell", _name = "/home/kazimazi/dev/haskell"}])}} "key \\"languageServerHaskell\\" not found"' [ ERROR ] 2021-02-15T09:52:44+0100 ] ...im-nightly-master/share/nvim/runtime/lua/vim/lsp/rpc.lua:455 ] "rpc" "haskell-language-server-wrapper" "stderr" '2021-02-15 09:52:44.497571472 [ThreadId 29] - Registering ide configuration: IdeConfiguration {workspaceFolders = fromList [NormalizedUri (-3350774379779606858) "file:///home/kazimazi/dev/haskell"], clientSettings = hashed (Just (Object (fromList [])))}\n' [ ERROR ] 2021-02-15T09:52:44+0100 ] ...im-nightly-master/share/nvim/runtime/lua/vim/lsp/rpc.lua:455 ] "rpc" "haskell-language-server-wrapper" "stderr" '2021-02-15 09:52:44.49872884 [ThreadId 29] - Opened text document: file:///home/kazimazi/dev/haskell/5.hs\n2021-02-15 09:52:44.499186579 [ThreadId 87] - hlint:getIdeas:file:NormalizedFilePath "/home/kazimazi/dev/haskell/5.hs"\n2021-02-15 09:52:44.499514111 [ThreadId 92] - Consulting the cradle for "5.hs"\n' [ ERROR ] 2021-02-15T09:52:44+0100 ] ...im-nightly-master/share/nvim/runtime/lua/vim/lsp/rpc.lua:455 ] "rpc" "haskell-language-server-wrapper" "stderr" 'Output from setting up the cradle Cradle {cradleRootDir = "/home/kazimazi/dev/haskell", cradleOptsProg = CradleAction: Default}\n' [ ERROR ] 2021-02-15T09:52:44+0100 ] ...im-nightly-master/share/nvim/runtime/lua/vim/lsp/rpc.lua:455 ] "rpc" "haskell-language-server-wrapper" "stderr" "2021-02-15 09:52:44.593226701 [ThreadId 92] - Using interface files cache dir: ghcide\n2021-02-15 09:52:44.593332872 [ThreadId 92] - Making new HscEnv[main]\n" [ ERROR ] 2021-02-15T09:52:44+0100 ] ...im-nightly-master/share/nvim/runtime/lua/vim/lsp/rpc.lua:455 ] "rpc" "haskell-language-server-wrapper" "stderr" '2021-02-15 09:52:44.606785695 [ThreadId 147] - hlint:getIdeas:file:NormalizedFilePath "/home/kazimazi/dev/haskell/5.hs"\n' [ ERROR ] 2021-02-15T09:52:48+0100 ] ...im-nightly-master/share/nvim/runtime/lua/vim/lsp/rpc.lua:455 ] "rpc" "haskell-language-server-wrapper" "stderr" "2021-02-15 09:52:48.311748559 [ThreadId 222] - finish: Formatter (took 0.00s)\n"
mjlbach commented 3 years ago

This belongs in discussions, is ormolu installed?

Kazimazi commented 3 years ago

I think ormolu installs with hls, it works with emacs lsp-mode and vscode, but I don't have it on PATH.

mjlbach commented 3 years ago

I would try adding it to your path and see if that resolves anything

Kazimazi commented 3 years ago

I installed it separately, but nothing changed.

sandersantema commented 3 years ago

hls indeed installs a copy of ormolu of it's own, no separate install should be needed as far as I know.

mjlbach commented 3 years ago

I have no idea what the issue would be, the last line of your log file indicates we're sending the correct command

[ThreadId 147] - hlint:getIdeas:file:NormalizedFilePath "/home/kazimazi/dev/haskell/5.hs"\n' [ ERROR ] 2021-02-15T09:52:48+0100 ] ...im-nightly-master/share/nvim/runtime/lua/vim/lsp/rpc.lua:455 ] "rpc" "haskell-language-server-wrapper" "stderr" "2021-02-15 09:52:48.311748559 [ThreadId 222] - finish: Formatter (took 0.00s)\n"

This isn't implemented in this repo btw. All we do in this repo, is send the initialization options to HLS, so I doubt the problem is here.

mjlbach commented 3 years ago

The issue was we needed to send the setting to set ormulu as default, I've done this in #739, you can override to whatever you want, but it should work by default now.