Skip to content

Builtin Plugin to help compiling/debugging "scripts" written with nvim-hs #20

@saep

Description

@saep

Although the dyre library helps with (somewhat) dynamic recompilation, it is still a bit annoying to use. Compile errors are silently dumped into ~/.cache/nvim/errors.log and you do not really notice if something went wrong there. Say you are developing a function for a plugin, the function may fail because you did something wrong logically or because it did not compile. It would be a tremendous improvement to be notified about the latter situation immediately. Also, it is still very inconvenient to restart neovim all the time if you change the configuration. To remedy these problems, we should extend nvim-hs to supply some functions and commands out of the box. This issue is a place to collect ideas and document the stage of its development.

The first steps are:

  • Implement a way to recompile nvim-hs.

    This is probably best done by subscribing to a notification (via vim_subscribe) on startup and implement a handler for it. Currently, notifications are ignored in the SocketReader. The dyre library has some lower level functions for this, so that we do not have to spawn external processes ourselves. The quickfix list should then be filled with the compiler warnings and errors. We can parse the output in Haskell ourselves or steal that code from somewhere else (e.g. syntastic/ghc-mod).

  • Implement a way to restart nvim-hs.

    This should probably be implemented similarly to the previous step. The dyre library has a module for this as well. This leads us to another decision: Do we want to preserve state when restarting? And if so, how should we go about it? XMonad has an extensible state state extension which we could use as inspiration for partially preserving state, but we can simply not care for now and defer this.

Then, we must think about how this is integrated within neovim. I think it is sufficient to provide two commands for the two steps above: :RecompileNvim-hs and :RestartNvim-hs (feel free to suggest better names). If we define them on our side, we don't even have to explicitly call vim_subscribe and can pass it directly to the EventHandler.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions