haskell-language-server icon indicating copy to clipboard operation
haskell-language-server copied to clipboard

'Remove redundant imports' code action not showing in neovim 0.9

Open asivitz opened this issue 1 year ago • 12 comments

Your environment

Which OS do you use? MacOS

Which version of GHC do you use and how did you install it? 9.4.7 from ghcup

How is your project built (alternative: link to the project)? stack

Which LSP client (editor/plugin) do you use? nvim + lspconfig (the neovim native lsp)

Which version of HLS do you use and how did you install it? 2.4.0.0 from ghcup

Have you configured HLS in any way (especially: a hie.yaml file)? Yes, a hie.yaml

Steps to reproduce

Open a file using neovim 0.9. Add a redundant import. Ask for code actions on this line.

Expected behaviour

There is a code action to 'Remove import' and 'Remove all redundant imports', as well as 'Disable 'unused-imports' warnings'

Actual behaviour

There is only a code action to disable the warnings

Debug information

The code actions do appear under neovim 0.7. Here are RPC logs for the two versions. Looks like the request data changed a bit between 0.7 and 0.9.

NEOVIM 0.7 REQUEST

[DEBUG][2023-10-31 14:31:44] .../vim/lsp/rpc.lua:347	"rpc.send"	{  id = 2,  jsonrpc = "2.0",  method = "textDocument/codeAction",  params = {    context = {      diagnostics = { {          code = "-Wunused-imports",          message = "The import of ‘generateDebugUI’\nfrom module ‘DebugInfoScreen’ is redundant",          range = {            end = {              character = 53,              line = 8            },            start = {              character = 38,              line = 8            }          },          severity = 2,          source = "typecheck",          tags = { 1 }        } }    },    range = {      end = <1>{        character = 0,        line = 8      },      start = <table 1>    },    textDocument = {      uri = "file:///Users/axis/dev/ultimate/src/Program/IODriver.hs"    }  }}

NEOVIM 0.9 REQUEST

[DEBUG][2023-10-31 14:45:44] .../vim/lsp/rpc.lua:284	"rpc.send"	{  id = 9,  jsonrpc = "2.0",  method = "textDocument/codeAction",  params = {    context = {      diagnostics = { {          code = "-Wunused-imports",          message = "The import of ‘generateDebugUI’\nfrom module ‘DebugInfoScreen’ is redundant",          range = {            ["end"] = {              character = 53,              line = 8            },            start = {              character = 38,              line = 8            }          },          severity = 2,          source = "typecheck"        } },      triggerKind = 1    },    range = {      ["end"] = <1>{        character = 5,        line = 8      },      start = <table 1>    },    textDocument = {      uri = "file:///Users/axis/dev/ultimate/src/Program/IODriver.hs"    }  }}

NEOVIM 0.7 RESPONSE LOGS (INCLUDING DEBUG INFO)

[ERROR][2023-10-31 14:31:44] .../vim/lsp/rpc.lua:420	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:31:44.889420Z | Debug | Finished: GhcideCodeActions.GetFileContents Took: 0.00s\n2023-10-31T18:31:44.889431Z | Debug | Finished: Pragmas.GhcSession Took: 0.00s\n2023-10-31T18:31:44.889635Z | Debug | Finished: retrie Took: 0.00s\n"
[ERROR][2023-10-31 14:31:44] .../vim/lsp/rpc.lua:420	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:31:44.889822Z | Debug | Finished: GhcideCodeActions.GetParsedModuleWithComments Took: 0.00s\n2023-10-31T18:31:44.889914Z | Debug | Finished:  Took: 0.00s\n"
[ERROR][2023-10-31 14:31:44] .../vim/lsp/rpc.lua:420	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:31:44.890167Z | Debug | Finished: Pragmas.GetFileContents Took: 0.00s\n"
[ERROR][2023-10-31 14:31:44] .../vim/lsp/rpc.lua:420	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:31:44.890569Z | Debug | Finished: QualifyImportedNames.TypeCheck Took: 0.00s\n2023-10-31T18:31:44.890638Z | Debug | Finished: changeTypeSignature.GetParsedModule Took: 0.00s\n2023-10-31T18:31:44.890676Z | Debug | Finished: splice.codeAction.GitHieAst Took: 0.00s\n"
[ERROR][2023-10-31 14:31:44] .../vim/lsp/rpc.lua:420	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:31:44.890787Z | Debug | Finished: GhcideCodeActions.getIdeOptions Took: 0.00s\n"
[ERROR][2023-10-31 14:31:44] .../vim/lsp/rpc.lua:420	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:31:44.891140Z | Debug | Finished: GhcideCodeActions.GetFileContents Took: 0.00s\n2023-10-31T18:31:44.891219Z | Debug | Finished: GADT.GetParsedModuleWithComments Took: 0.00s\n"
[ERROR][2023-10-31 14:31:44] .../vim/lsp/rpc.lua:420	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:31:44.891272Z | Debug | Finished: Pragmas.GetParsedModule Took: 0.00s\n2023-10-31T18:31:44.891357Z | Debug | Finished: Pragmas.GhcSession Took: 0.00s\n"
[ERROR][2023-10-31 14:31:44] .../vim/lsp/rpc.lua:420	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:31:44.894152Z | Debug | overloaded-record-dot: Collected record selectors: []\n"
[ERROR][2023-10-31 14:31:44] .../vim/lsp/rpc.lua:420	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:31:44.894290Z | Debug | Finished: GhcideCodeActions.GetParsedModuleWithComments Took: 0.00s\n"
[ERROR][2023-10-31 14:31:44] .../vim/lsp/rpc.lua:420	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:31:44.894500Z | Debug | Finished: overloadedRecordDot.collectRecordSelectors Took: 0.00s\n"
[ERROR][2023-10-31 14:31:44] .../vim/lsp/rpc.lua:420	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:31:44.894782Z | Debug | Finished: GhcideCodeActions.GhcSession Took: 0.00s\n"
[ERROR][2023-10-31 14:31:44] .../vim/lsp/rpc.lua:420	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:31:44.894882Z | Debug | Finished: alternateNumberFormat.CollectLiterals Took: 0.01s\n"
[ERROR][2023-10-31 14:31:44] .../vim/lsp/rpc.lua:420	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:31:44.894980Z | Debug | Finished: Pragmas.GetFileContents Took: 0.00s\n"
[ERROR][2023-10-31 14:31:44] .../vim/lsp/rpc.lua:420	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:31:44.895356Z | Debug | Finished: Pragmas.GetParsedModule Took: 0.00s\n"
[ERROR][2023-10-31 14:31:44] .../vim/lsp/rpc.lua:420	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:31:44.895887Z | Debug | Finished: GhcideCodeActions.GetGlobalBindingTypeSigs Took: 0.01s\n"
[ERROR][2023-10-31 14:31:44] .../vim/lsp/rpc.lua:420	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:31:44.896648Z | Debug | Finished: ImportActions Took: 0.01s\n"
[ERROR][2023-10-31 14:31:44] .../vim/lsp/rpc.lua:420	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:31:44.896962Z | Debug | Finished: GhcideCodeActions.GetFileContents Took: 0.00s\n"
[ERROR][2023-10-31 14:31:44] .../vim/lsp/rpc.lua:420	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:31:44.897010Z | Debug | Finished: alternateNumberFormat.GhcSession Took: 0.00s\n"
[ERROR][2023-10-31 14:31:44] .../vim/lsp/rpc.lua:420	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:31:44.897041Z | Debug | Finished: QualifyImportedNames.GetHieAst Took: 0.00s\n"
[ERROR][2023-10-31 14:31:44] .../vim/lsp/rpc.lua:420	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:31:44.897091Z | Debug | Finished: QualifyImportedNames.GetFileContents Took: 0.00s\n"
[ERROR][2023-10-31 14:31:44] .../vim/lsp/rpc.lua:420	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:31:44.897749Z | Debug | Finished: alternateNumberFormat.GetFileContents Took: 0.00s\n"
[ERROR][2023-10-31 14:31:44] .../vim/lsp/rpc.lua:420	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:31:44.898919Z | Debug | explicit-fields: Collected records with wildcards: [ /Users/axis/dev/ultimate/src/Program/IODriver.hs:134:21-32: AppData {..}\n                                                   , /Users/axis/dev/ultimate/src/Program/IODriver.hs:284:15-26: AppData {..}\n                                                   , /Users/axis/dev/ultimate/src/Program/IODriver.hs:208:13-24: AppData {..}\n                                                   , /Users/axis/dev/ultimate/src/Program/IODriver.hs:178:17-28: AppData {..}\n                                                   , /Users/axis/dev/ultimate/src/Program/IODriver.hs:258:17-28: AppData {..}\n                                                   , /Users/axis/dev/ultimate/src/Program/IODriver.hs:126:8-19: AppData {..} ]\n"
[ERROR][2023-10-31 14:31:44] .../vim/lsp/rpc.lua:420	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:31:44.900524Z | Debug | Finished: GhcideCodeActions.GetParsedModuleWithComments Took: 0.00s\n"
[ERROR][2023-10-31 14:31:44] .../vim/lsp/rpc.lua:420	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:31:44.902009Z | Debug | Finished: ExplicitFields.CollectRecords Took: 0.01s\n"
[ERROR][2023-10-31 14:31:46] .../vim/lsp/rpc.lua:420	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:31:46.276401Z | Debug | Finished: GhcideCodeActions.GetAnnotatedParsedSource Took: 0.00s\n"
[ERROR][2023-10-31 14:31:46] .../vim/lsp/rpc.lua:420	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:31:46.276665Z | Debug | Finished: GhcideCodeActions.TypeCheck Took: 0.00s\n"
[ERROR][2023-10-31 14:31:46] .../vim/lsp/rpc.lua:420	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:31:46.276710Z | Debug | Finished: GhcideCodeActions.GetHieAst Took: 0.00s\n"
[ERROR][2023-10-31 14:31:46] .../vim/lsp/rpc.lua:420	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:31:46.277755Z | Debug | Finished: GhcideCodeActions.getParsedModule Took: 0.00s\n"
[DEBUG][2023-10-31 14:31:46] .../vim/lsp/rpc.lua:454	"rpc.receive"	{  id = 2,  jsonrpc = "2.0",  result = { {      edit = {        changes = {          ["file:///Users/axis/dev/ultimate/src/Program/IODriver.hs"] = { {              newText = "DebugInfoScreen.buildParamUI",              range = {                end = {                  character = 56,                  line = 92                },                start = {                  character = 44,                  line = 92                }              }            } }        }      },      kind = "quickfix",      title = "Qualify imported names"    }, {      diagnostics = { {          code = "-Wunused-imports",          message = "The import of ‘generateDebugUI’\nfrom module ‘DebugInfoScreen’ is redundant",          range = {            end = {              character = 53,              line = 8            },            start = {              character = 38,              line = 8            }          },          severity = 2,          source = "typecheck",          tags = { 1 }        } },      edit = {        changes = {          ["file:///Users/axis/dev/ultimate/src/Program/IODriver.hs"] = { {              newText = "",              range = {                end = {                  character = 53,                  line = 8                },                start = {                  character = 36,                  line = 8                }              }            } }        }      },      kind = "quickfix",      title = "Remove generateDebugUI from import"    }, {      edit = {        changes = {          ["file:///Users/axis/dev/ultimate/src/Program/IODriver.hs"] = { {              newText = "",              range = {                end = {                  character = 59,                  line = 7                },                start = {                  character = 45,                  line = 7                }              }            }, {              newText = "",              range = {                end = {                  character = 53,                  line = 8                },                start = {                  character = 36,                  line = 8                }              }            }, {              newText = "",              range = {                end = {                  character = 0,                  line = 10                },                start = {                  character = 0,                  line = 9                }              }            }, {              newText = "",              range = {                end = {                  character = 58,                  line = 10                },                start = {                  character = 44,                  line = 10                }              }            }, {              newText = "",              range = {                end = {                  character = 78,                  line = 12                },                start = {                  character = 66,                  line = 12                }              }            }, {              newText = "",              range = {                end = {                  character = 89,                  line = 12                },                start = {                  character = 78,                  line = 12                }              }            }, {              newText = "",              range = {                end = {                  character = 77,                  line = 14                },                start = {                  character = 64,                  line = 14                }              }            }, {              newText = "",              range = {                end = {                  character = 105,                  line = 14                },                start = {                  character = 89,                  line = 14                }              }            }, {              newText = "",              range = {                end = {                  character = 38,                  line = 15                },                start = {                  character = 32,                  line = 15                }              }            }, {              newText = "",              range = {                end = {                  character = 44,                  line = 15                },                start = {                  character = 38,                  line = 15                }              }            }, {              newText = "",              range = {                end = {                  character = 51,                  line = 15                },                start = {                  character = 44,                  line = 15                }              }            }, {              newText = "",              range = {                end = {                  character = 61,                  line = 15                },                start = {                  character = 51,                  line = 15                }              }            }, {              newText = "",              range = {                end = {                  character = 66,                  line = 15                },                start = {                  character = 61,                  line = 15                }              }            }, {              newText = "",              range = {                end = {                  character = 59,                  line = 16                },                start = {                  character = 49,                  line = 16                }              }            }, {              newText = "",              range = {                end = {                  character = 0,                  line = 18                },                start = {                  character = 0,                  line = 17                }              }            }, {              newText = "",              range = {                end = {                  character = 33,                  line = 19                },                start = {                  character = 18,                  line = 19                }              }            }, {              newText = "",              range = {                end = {                  character = 45,                  line = 19                },                start = {                  character = 33,                  line = 19                }              }            }, {              newText = "",              range = {                end = {                  character = 77,                  line = 19                },                start = {                  character = 59,                  line = 19                }              }            }, {              newText = "",              range = {                end = {                  character = 0,                  line = 21                },                start = {                  character = 0,                  line = 20                }              }            }, {              newText = "",              range = {                end = {                  character = 43,                  line = 22                },                start = {                  character = 29,                  line = 22                }              }            }, {              newText = "",              range = {                end = {                  character = 50,                  line = 23                },                start = {                  character = 41,                  line = 23                }              }            }, {              newText = "",              range = {                end = {                  character = 43,                  line = 25                },                start = {                  character = 30,                  line = 25                }              }            }, {              newText = "",              range = {                end = {                  character = 60,                  line = 25                },                start = {                  character = 43,                  line = 25                }              }            }, {              newText = "",              range = {                end = {                  character = 96,                  line = 25                },                start = {                  character = 75,                  line = 25                }              }            }, {              newText = "",              range = {                end = {                  character = 117,                  line = 25                },                start = {                  character = 96,                  line = 25                }              }            }, {              newText = "",              range = {                end = {                  character = 29,                  line = 26                },                start = {                  character = 22,                  line = 26                }              }            }, {              newText = "",              range = {                end = {                  character = 39,                  line = 26                },                start = {                  character = 34,                  line = 26                }              }            }, {              newText = "",              range = {                end = {                  character = 0,                  line = 32                },                start = {                  character = 0,                  line = 31                }              }            }, {              newText = "",              range = {                end = {                  character = 0,                  line = 33                },                start = {                  character = 0,                  line = 32                }              }            }, {              newText = "",              range = {                end = {                  character = 0,                  line = 34                },                start = {                  character = 0,                  line = 33                }              }            }, {              newText = "",              range = {                end = {                  character = 26,                  line = 34                },                start = {                  character = 18,                  line = 34                }              }            }, {              newText = "",              range = {                end = {                  character = 48,                  line = 36                },                start = {                  character = 33,                  line = 36                }              }            }, {              newText = "",              range = {                end = {                  character = 62,                  line = 36                },                start = {                  character = 48,                  line = 36                }              }            }, {              newText = "",              range = {                end = {                  character = 81,                  line = 36                },                start = {                  character = 62,                  line = 36                }              }            }, {              newText = "",              range = {                end = {                  character = 97,                  line = 36                },                start = {                  character = 81,                  line = 36                }              }            }, {              newText = "",              range = {                end = {                  character = 108,                  line = 36                },                start = {                  character = 97,                  line = 36                }              }            }, {              newText = "",              range = {                end = {                  character = 125,                  line = 36                },                start = {                  character = 108,                  line = 36                }              }            }, {              newText = "",              range = {                end = {                  character = 143,                  line = 36                },                start = {                  character = 125,                  line = 36                }              }            }, {              newText = "",              range = {                end = {                  character = 166,                  line = 36                },                start = {                  character = 154,                  line = 36                }              }            }, {              newText = "",              range = {                end = {                  character = 192,                  line = 36                },                start = {                  character = 166,                  line = 36                }              }            }, {              newText = "",              range = {                end = {                  character = 198,                  line = 36                },                start = {                  character = 192,                  line = 36                }              }            }, {              newText = "",              range = {                end = {                  character = 208,                  line = 36                },                start = {                  character = 198,                  line = 36                }              }            }, {              newText = "",              range = {                end = {                  character = 226,                  line = 36                },                start = {                  character = 208,                  line = 36                }              }            }, {              newText = "",              range = {                end = {                  character = 239,                  line = 36                },                start = {                  character = 226,                  line = 36                }              }            }, {              newText = "",              range = {                end = {                  character = 253,                  line = 36                },                start = {                  character = 239,                  line = 36                }              }            }, {              newText = "",              range = {                end = {                  character = 264,                  line = 36                },                start = {                  character = 253,                  line = 36                }              }            }, {              newText = "",              range = {                end = {                  character = 274,                  line = 36                },                start = {                  character = 264,                  line = 36                }              }            }, {              newText = "",              range = {                end = {                  character = 284,                  line = 36                },                start = {                  character = 274,                  line = 36                }              }            }, {              newText = "",              range = {                end = {                  character = 27,                  line = 37                },                start = {                  character = 21,                  line = 37                }              }            }, {              newText = "",              range = {                end = {                  character = 43,                  line = 37                },                start = {                  character = 32,                  line = 37                }              }            }, {              newText = "",              range = {                end = {                  character = 47,                  line = 37                },                start = {                  character = 43,                  line = 37                }              }            }, {              newText = "",              range = {                end = {                  character = 0,                  line = 39                },                start = {                  character = 0,                  line = 38                }              }            }, {              newText = "",              range = {                end = {                  character = 38,                  line = 39                },                start = {                  character = 28,                  line = 39                }              }            }, {              newText = "",              range = {                end = {                  character = 0,                  line = 42                },                start = {                  character = 0,                  line = 41                }              }            }, {              newText = "",              range = {                end = {                  character = 0,                  line = 44                },                start = {                  character = 0,                  line = 43                }              }            }, {              newText = "",              range = {                end = {                  character = 0,                  line = 45                },                start = {                  character = 0,                  line = 44                }              }            }, {              newText = "",              range = {                end = {                  character = 52,                  line = 45                },                start = {                  character = 35,                  line = 45                }              }            }, {              newText = "",              range = {                end = {                  character = 50,                  line = 49                },                start = {                  character = 38,                  line = 49                }              }            }, {              newText = "",              range = {                end = {                  character = 70,                  line = 49                },                start = {                  character = 50,                  line = 49                }              }            }, {              newText = "",              range = {                end = {                  character = 91,                  line = 49                },                start = {                  character = 84,                  line = 49                }              }            }, {              newText = "",              range = {                end = {                  character = 0,                  line = 51                },                start = {                  character = 0,                  line = 50                }              }            }, {              newText = "",              range = {                end = {                  character = 0,                  line = 52                },                start = {                  character = 0,                  line = 51                }              }            }, {              newText = "",              range = {                end = {                  character = 0,                  line = 53                },                start = {                  character = 0,                  line = 52                }              }            }, {              newText = "",              range = {                end = {                  character = 0,                  line = 54                },                start = {                  character = 0,                  line = 53                }              }            }, {              newText = "",              range = {                end = {                  character = 0,                  line = 55                },                start = {                  character = 0,                  line = 54                }              }            }, {              newText = "",              range = {                end = {                  character = 0,                  line = 57                },                start = {                  character = 0,                  line = 56                }              }            }, {              newText = "",              range = {                end = {                  character = 0,                  line = 58                },                start = {                  character = 0,                  line = 57                }              }            }, {              newText = "",              range = {                end = {                  character = 0,                  line = 59                },                start = {                  character = 0,                  line = 58                }              }            }, {              newText = "",              range = {                end = {                  character = 33,                  line = 60                },                start = {                  character = 27,                  line = 60                }              }            }, {              newText = "",              range = {                end = {                  character = 41,                  line = 60                },                start = {                  character = 33,                  line = 60                }              }            }, {              newText = "",              range = {                end = {                  character = 36,                  line = 62                },                start = {                  character = 27,                  line = 62                }              }            }, {              newText = "",              range = {                end = {                  character = 43,                  line = 62                },                start = {                  character = 36,                  line = 62                }              }            }, {              newText = "",              range = {                end = {                  character = 0,                  line = 64                },                start = {                  character = 0,                  line = 63                }              }            }, {              newText = "",              range = {                end = {                  character = 0,                  line = 65                },                start = {                  character = 0,                  line = 64                }              }            }, {              newText = "",              range = {                end = {                  character = 0,                  line = 66                },                start = {                  character = 0,                  line = 65                }              }            }, {              newText = "",              range = {                end = {                  character = 0,                  line = 67                },                start = {                  character = 0,                  line = 66                }              }            }, {              newText = "",              range = {                end = {                  character = 0,                  line = 68                },                start = {                  character = 0,                  line = 67                }              }            }, {              newText = "",              range = {                end = {                  character = 0,                  line = 69                },                start = {                  character = 0,                  line = 68                }              }            }, {              newText = "",              range = {                end = {                  character = 0,                  line = 70                },                start = {                  character = 0,                  line = 69                }              }            }, {              newText = "",              range = {                end = {                  character = 0,                  line = 71                },                start = {                  character = 0,                  line = 70                }              }            }, {              newText = "",              range = {                end = {                  character = 0,                  line = 72                },                start = {                  character = 0,                  line = 71                }              }            }, {              newText = "",              range = {                end = {                  character = 0,                  line = 73                },                start = {                  character = 0,                  line = 72                }              }            }, {              newText = "",              range = {                end = {                  character = 0,                  line = 74                },                start = {                  character = 0,                  line = 73                }              }            }, {              newText = "",              range = {                end = {                  character = 0,                  line = 75                },                start = {                  character = 0,                  line = 74                }              }            }, {              newText = "",              range = {                end = {                  character = 61,                  line = 75                },                start = {                  character = 39,                  line = 75                }              }            } }        }      },      isPreferred = true,      kind = "quickfix",      title = "Remove all redundant imports"    }, {      diagnostics = {},      edit = {        changes = {          ["file:///Users/axis/dev/ultimate/src/Program/IODriver.hs"] = { {              newText = "{-# OPTIONS_GHC -Wno-unused-imports #-}\n",              range = {                end = {                  character = 0,                  line = 2                },                start = {                  character = 0,                  line = 2                }              }            } }        }      },      kind = "quickfix",      title = 'Disable "unused-imports" warnings'    } }}

NEOVIM 0.9 RESPONSE LOGS (INCLUDING DEBUG INFO)

[ERROR][2023-10-31 14:45:44] .../vim/lsp/rpc.lua:734	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:45:44.447051Z | Debug | Finished: GhcideCodeActions.GetFileContents Took: 0.00s\n"
[ERROR][2023-10-31 14:45:44] .../vim/lsp/rpc.lua:734	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:45:44.447368Z | Debug | Finished: Pragmas.GhcSession Took: 0.00s\n"
[ERROR][2023-10-31 14:45:44] .../vim/lsp/rpc.lua:734	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:45:44.447510Z | Debug | Finished: GhcideCodeActions.GetParsedModuleWithComments Took: 0.00s\n"
[ERROR][2023-10-31 14:45:44] .../vim/lsp/rpc.lua:734	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:45:44.447516Z | Debug | Finished: QualifyImportedNames.TypeCheck Took: 0.00s\n"
[ERROR][2023-10-31 14:45:44] .../vim/lsp/rpc.lua:734	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:45:44.447536Z | Debug | Finished: changeTypeSignature.GetParsedModule Took: 0.00s\n"
[ERROR][2023-10-31 14:45:44] .../vim/lsp/rpc.lua:734	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:45:44.447545Z | Debug | Finished: splice.codeAction.GitHieAst Took: 0.00s\n"
[ERROR][2023-10-31 14:45:44] .../vim/lsp/rpc.lua:734	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:45:44.447610Z | Debug | Finished: retrie Took: 0.00s\n2023-10-31T18:45:44.447620Z | Debug | Finished: GADT.GetParsedModuleWithComments Took: 0.00s\n"
[ERROR][2023-10-31 14:45:44] .../vim/lsp/rpc.lua:734	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:45:44.447685Z | Debug | Finished:  Took: 0.00s\n"
[ERROR][2023-10-31 14:45:44] .../vim/lsp/rpc.lua:734	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:45:44.447692Z | Debug | Finished: GhcideCodeActions.GetFileContents Took: 0.00s\n"
[ERROR][2023-10-31 14:45:44] .../vim/lsp/rpc.lua:734	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:45:44.447740Z | Debug | Finished: GhcideCodeActions.getIdeOptions Took: 0.00s\n"
[ERROR][2023-10-31 14:45:44] .../vim/lsp/rpc.lua:734	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:45:44.448700Z | Debug | Finished: QualifyImportedNames.GetHieAst Took: 0.00s\n"
[ERROR][2023-10-31 14:45:44] .../vim/lsp/rpc.lua:734	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:45:44.448714Z | Debug | Finished: Pragmas.GhcSession Took: 0.00s\n"
[ERROR][2023-10-31 14:45:44] .../vim/lsp/rpc.lua:734	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:45:44.448737Z | Debug | Finished: Pragmas.GetFileContents Took: 0.00s\n2023-10-31T18:45:44.448752Z | Debug | Finished: GhcideCodeActions.GetParsedModuleWithComments Took: 0.00s\n"
[ERROR][2023-10-31 14:45:44] .../vim/lsp/rpc.lua:734	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:45:44.448780Z | Debug | Finished: QualifyImportedNames.GetFileContents Took: 0.00s\n"
[ERROR][2023-10-31 14:45:44] .../vim/lsp/rpc.lua:734	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:45:44.448848Z | Debug | Finished: Pragmas.GetFileContents Took: 0.00s\n"
[ERROR][2023-10-31 14:45:44] .../vim/lsp/rpc.lua:734	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:45:44.448853Z | Debug | Finished: Pragmas.GetParsedModule Took: 0.00s\n2023-10-31T18:45:44.449051Z | Debug | Finished: GhcideCodeActions.GetGlobalBindingTypeSigs Took: 0.00s\n"
[ERROR][2023-10-31 14:45:44] .../vim/lsp/rpc.lua:734	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:45:44.451481Z | Debug | overloaded-record-dot: Collected record selectors: []\n"
[ERROR][2023-10-31 14:45:44] .../vim/lsp/rpc.lua:734	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:45:44.451865Z | Debug | Finished: overloadedRecordDot.collectRecordSelectors Took: 0.00s\n"
[ERROR][2023-10-31 14:45:44] .../vim/lsp/rpc.lua:734	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:45:44.452223Z | Debug | explicit-fields: Collected records with wildcards: [ /Users/axis/dev/ultimate/src/Program/IODriver.hs:134:21-32: AppData {..}\n                                                   , /Users/axis/dev/ultimate/src/Program/IODriver.hs:284:15-26: AppData {..}\n                                                   , /Users/axis/dev/ultimate/src/Program/IODriver.hs:208:13-24: AppData {..}\n                                                   , /Users/axis/dev/ultimate/src/Program/IODriver.hs:178:17-28: AppData {..}\n                                                   , /Users/axis/dev/ultimate/src/Program/IODriver.hs:258:17-28: AppData {..}\n"
[ERROR][2023-10-31 14:45:44] .../vim/lsp/rpc.lua:734	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"                                                   , /Users/axis/dev/ultimate/src/Program/IODriver.hs:126:8-19: AppData {..} ]\n"
[ERROR][2023-10-31 14:45:44] .../vim/lsp/rpc.lua:734	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:45:44.452339Z | Debug | Finished: alternateNumberFormat.CollectLiterals Took: 0.01s\n"
[ERROR][2023-10-31 14:45:44] .../vim/lsp/rpc.lua:734	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:45:44.452402Z | Debug | Finished: Pragmas.GetParsedModule Took: 0.00s\n"
[ERROR][2023-10-31 14:45:44] .../vim/lsp/rpc.lua:734	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:45:44.452536Z | Debug | Finished: GhcideCodeActions.GetFileContents Took: 0.00s\n2023-10-31T18:45:44.453466Z | Debug | Finished: GhcideCodeActions.GhcSession Took: 0.00s\n"
[ERROR][2023-10-31 14:45:44] .../vim/lsp/rpc.lua:734	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:45:44.453479Z | Debug | Finished: alternateNumberFormat.GhcSession Took: 0.00s\n"
[ERROR][2023-10-31 14:45:44] .../vim/lsp/rpc.lua:734	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:45:44.455039Z | Debug | Finished: ExplicitFields.CollectRecords Took: 0.01s\n"
[ERROR][2023-10-31 14:45:44] .../vim/lsp/rpc.lua:734	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:45:44.455188Z | Debug | Finished: GhcideCodeActions.GetParsedModuleWithComments Took: 0.00s\n"
[ERROR][2023-10-31 14:45:44] .../vim/lsp/rpc.lua:734	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:45:44.456566Z | Debug | Finished: ImportActions Took: 0.01s\n"
[ERROR][2023-10-31 14:45:44] .../vim/lsp/rpc.lua:734	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:45:44.459151Z | Debug | Finished: alternateNumberFormat.GetFileContents Took: 0.00s\n"
[ERROR][2023-10-31 14:45:45] .../vim/lsp/rpc.lua:734	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:45:45.850227Z | Debug | Finished: GhcideCodeActions.GetAnnotatedParsedSource Took: 0.00s\n"
[ERROR][2023-10-31 14:45:45] .../vim/lsp/rpc.lua:734	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:45:45.850578Z | Debug | Finished: GhcideCodeActions.TypeCheck Took: 0.00s\n"
[ERROR][2023-10-31 14:45:45] .../vim/lsp/rpc.lua:734	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:45:45.850680Z | Debug | Finished: GhcideCodeActions.GetHieAst Took: 0.00s\n"
[ERROR][2023-10-31 14:45:45] .../vim/lsp/rpc.lua:734	"rpc"	"/Users/axis/.ghcup/bin/haskell-language-server-wrapper"	"stderr"	"2023-10-31T18:45:45.851821Z | Debug | Finished: GhcideCodeActions.getParsedModule Took: 0.00s\n"
[DEBUG][2023-10-31 14:45:45] .../vim/lsp/rpc.lua:387	"rpc.receive"	{  id = 9,  jsonrpc = "2.0",  result = { {      edit = {        changes = {          ["file:///Users/axis/dev/ultimate/src/Program/IODriver.hs"] = { {              newText = "DebugInfoScreen.buildParamUI",              range = {                ["end"] = {                  character = 56,                  line = 92                },                start = {                  character = 44,                  line = 92                }              }            } }        }      },      kind = "quickfix",      title = "Qualify imported names"    }, {      diagnostics = {},      edit = {        changes = {          ["file:///Users/axis/dev/ultimate/src/Program/IODriver.hs"] = { {              newText = "{-# OPTIONS_GHC -Wno-unused-imports #-}\n",              range = {                ["end"] = {                  character = 0,                  line = 2                },                start = {                  character = 0,                  line = 2                }              }            } }        }      },      kind = "quickfix",      title = 'Disable "unused-imports" warnings'    } }}

Thanks!

asivitz avatar Oct 31 '23 18:10 asivitz

Is it possible to get the request as correctly-formatted JSON? I don't know what the thing being printed by neovim is, but it isn't correct JSON.

It's not at all obvious to me what's going wrong. Can you run HLS with debug logging on? I think someone will just need to debug a bit.

michaelpj avatar Nov 09 '23 11:11 michaelpj

I'm affected by this too. From what @asivitz posted it seems that neovim is sending a different range information? Here's the diff between 0.7 and 0.9 requests: https://www.diffchecker.com/BE84YWxl/ The difference in range: 0.7:

range = {      end = <1>{        character = 0,        line = 8      },      start = <table 1>   }

0.9:

range = {      ["end"] = <1>{        character = 5,        line = 8      },      start = <table 1>    }

I'll try to reproduce this on my machine later.

carbolymer avatar Dec 07 '23 10:12 carbolymer

Like I said, it's really not obvious to me what's happening here. It would help to get some proper JSON for the problematic request, and then I think someone just needs to take a look at the code and see if it's doing something silly. Debug logging may help.

michaelpj avatar Dec 12 '23 14:12 michaelpj

For example, what on earth does ["end"] = ... mean in this context? JSON keys can't be arrays? I have no idea what this actually corresponds to. I do think there's a decent chance that neovim is sending malformed LSP requests or something.

michaelpj avatar Dec 18 '23 13:12 michaelpj

Just popping in to say I'm still seeing this behavior on neovim 0.9.5, HLS 2.5.0.

Is this reproducible on (e.g.) VS Code? Might be the quickest way to narrow down whether it's a HLS or neovim issue...

keithfancher avatar Jan 27 '24 20:01 keithfancher

Just popping in to say I'm still seeing this behavior on neovim 0.9.5, HLS 2.5.0.

Is this reproducible on (e.g.) VS Code? Might be the quickest way to narrow down whether it's a HLS or neovim issue...

Removing redundant import works for me in vscode.

soulomoon avatar Jan 27 '24 21:01 soulomoon

Removing redundant import works for me in vscode.

Yup, me too. (Now that I've installed it again, heh.) Which definitely suggests it's a problem with neovim! I filed https://github.com/neovim/neovim/issues/27318, cribbing the logs from @asivitz's original report. Hope that's cool!

keithfancher avatar Feb 03 '24 04:02 keithfancher

Well, I opened a PR that fixes the issue: https://github.com/haskell/haskell-language-server/pull/4051

...but I'm not sure if it's the "right" thing to do! Meanwhile though, if you're affected by this, building HLS from the above branch should get you going again.

keithfancher avatar Feb 04 '24 19:02 keithfancher

Good sleuthing! I commented on the PR. I do think neovim is behaving unhelpfully here, but the spec doesn't tell people what to do and anyway I think we probably shouldn't rely on what they're doing anyway.

michaelpj avatar Feb 04 '24 20:02 michaelpj

They did in fact fix this on the neovim side. Could someone verify if that has in fact fixed this issue?

michaelpj avatar Feb 07 '24 10:02 michaelpj

Could someone verify if that has in fact fixed this issue?

I just tried with the nightly build of neovim from Feb 7 (which appears to contain the fix) and HLS 2.6.0.0 and the issue does not seem fixed for me. Note, code actions when on a redundant import:

hls-2 6 0 0-nvim-nightly

And here are the code actions for the same line with my patched HLS (and same version of neovim):

hls-custom-nvim-nightly

Haven't done any debugging or anything yet...

EDIT: Looks like the tags still aren't coming through... I commented on the nvim issue.

keithfancher avatar Feb 08 '24 23:02 keithfancher

While we wait on the neovim fix, I figured I'd take a crack at fixing it the right way on the HLS side. PR here!

keithfancher avatar Feb 09 '24 20:02 keithfancher

I forgot to mention it here, but now that PR https://github.com/haskell/haskell-language-server/pull/4063 is merged, I think this bug can be closed out :tada:

nvim-hls-redundant-imports-Screenshot from 2024-02-29 16-20-21

keithfancher avatar Mar 01 '24 00:03 keithfancher