Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
asivitz opened this issue Oct 31, 2023 · 13 comments
Closed

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

asivitz opened this issue Oct 31, 2023 · 13 comments
Labels
status: needs info Not actionable, because there's missing information type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@asivitz
Copy link

asivitz commented Oct 31, 2023

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 asivitz added status: needs triage type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. labels Oct 31, 2023
@michaelpj
Copy link
Collaborator

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.

@carbolymer
Copy link

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.

@michaelpj
Copy link
Collaborator

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
Copy link
Collaborator

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 michaelpj added status: needs info Not actionable, because there's missing information and removed status: needs triage labels Dec 18, 2023
@keithfancher
Copy link
Contributor

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...

@soulomoon
Copy link
Collaborator

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.

@keithfancher
Copy link
Contributor

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 neovim/neovim#27318, cribbing the logs from @asivitz's original report. Hope that's cool!

keithfancher added a commit to keithfancher/haskell-language-server that referenced this issue Feb 4, 2024
Discovered while investigating issue haskell#3857. Technically, there are only
two required fields in an incoming `Diagnostic` object: `range` and
`message`. However, the HLS was comparing all fields to determine
equality. This caused mismatches when neovim stopped sending the
(optional) `tags` field.
@keithfancher
Copy link
Contributor

Well, I opened a PR that fixes the issue: #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.

@michaelpj
Copy link
Collaborator

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
Copy link
Collaborator

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

@keithfancher
Copy link
Contributor

keithfancher commented Feb 8, 2024

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 added a commit to keithfancher/haskell-language-server that referenced this issue Feb 9, 2024
Rather than doing a full compare with incoming `Diagnostic` objects from
the client. This brings the "remove redundant imports/exports" code
actions more in line with behavior described in haskell#4056, and has the
pleasant side-effect of fixing broken code actions in neovim (haskell#3857).
@keithfancher
Copy link
Contributor

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!

fendor added a commit that referenced this issue Feb 21, 2024
…ions are in scope (#4063)

* Use *only* incoming range to determine which code actions are in scope

Rather than doing a full compare with incoming `Diagnostic` objects from
the client. This brings the "remove redundant imports/exports" code
actions more in line with behavior described in #4056, and has the
pleasant side-effect of fixing broken code actions in neovim (#3857).

* Remove redundant imports ;)

* Rename param for clarity

---------

Co-authored-by: fendor <[email protected]>
soulomoon pushed a commit to soulomoon/haskell-language-server that referenced this issue Feb 23, 2024
…ions are in scope (haskell#4063)

* Use *only* incoming range to determine which code actions are in scope

Rather than doing a full compare with incoming `Diagnostic` objects from
the client. This brings the "remove redundant imports/exports" code
actions more in line with behavior described in haskell#4056, and has the
pleasant side-effect of fixing broken code actions in neovim (haskell#3857).

* Remove redundant imports ;)

* Rename param for clarity

---------

Co-authored-by: fendor <[email protected]>
@keithfancher
Copy link
Contributor

I forgot to mention it here, but now that PR #4063 is merged, I think this bug can be closed out 🎉

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

@fendor fendor closed this as completed Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs info Not actionable, because there's missing information type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants