mrcjkb / haskell-tools.nvim

🦥 Supercharge your Haskell experience in neovim!
GNU General Public License v2.0
483 stars 20 forks source link

REPL toggleterm stopped working #92

Closed andreacfromtheapp closed 1 year ago

andreacfromtheapp commented 1 year ago

Neovim version (nvim -v)

v0.8.2

Operating system/version

macOS 12.6.2

Output of haskell-language-server --version

haskell-language-server version: 1.9.0.0 (GHC: 9.4.4) (PATH: /Users/gacallea/.ghcup/hls/1.9.0.0/lib/haskell-language-server-1.9.0.0/bin/haskell-language-server-wrapper)

How to reproduce the issue

1 - set the REPL to toggleterm:

    repl = {
      -- 'builtin': Use the simple builtin repl
      -- 'toggleterm': Use akinsho/toggleterm.nvim
      handler = 'toggleterm',
    },

2 - launch the REPL with:

 :lua require('haskell-tools').repl.toggle(vim.api.nvim_buf_get_name(0))

Expected behaviour

Actual behaviour

This used to work just fine until a couple of days ago, when I packer synced my extensions. It may be an issue with one of the latest toggleterm update, not sure.

Log file

No response

mrcjkb commented 1 year ago

Hi, thanks for reporting this.

I have not been able to reproduce this with the steps and the minimal config below. If this is also the case for you, could you please extend the config with any additional plugins or setup needed to reproduce it?

Does it happen in a standalone Haskell file, or in a cabal or stack project?

Steps

mkdir -p /tmp/minimal
NVIM_DATA_MINIMAL=/tmp/minimal -u minimal.lua
:q
NVIM_DATA_MINIMAL=/tmp/minimal -u minimal.lua
:edit foo.hs
:lua require('haskell-tools').repl.toggle(vim.api.nvim_buf_get_name(0))

Minimal config

-- Ignore default config
local fn = vim.fn
local config_path = fn.stdpath('config')
vim.opt.runtimepath:remove(config_path)

-- Ignore default plugins
local data_path = fn.stdpath('data')
local pack_path = data_path .. '/site'
vim.opt.packpath:remove(pack_path)

--append temporary config and pack dir
data_path = os.getenv('NVIM_DATA_MINIMAL')
if not data_path then
  error('$NVIM_DATA_MINIMAL environment variable not set!')
end
vim.opt.runtimepath:append('.')
vim.opt.runtimepath:append(data_path)
vim.opt.runtimepath:append(data_path .. '/site/pack/packer/start/plenary.nvim')
vim.opt.packpath:append(data_path .. '/site')

-- bootstrap packer
local packer_install_path = data_path .. '/site/pack/packer/start/packer.nvim'
local install_plugins = false

if vim.fn.empty(vim.fn.glob(packer_install_path)) > 0 then
  vim.cmd('!git clone git@github.com:wbthomason/packer.nvim ' .. packer_install_path)
  vim.cmd('packadd packer.nvim')
  install_plugins = true
else
  vim.cmd('packadd packer.nvim')
end

local packer = require('packer')

packer.init {
  package_root = data_path .. '/site/pack',
  compile_path = data_path .. '/plugin/packer_compiled.lua',
}

packer.startup(function(use)
  use('wbthomason/packer.nvim')
  use {
    'MrcJkb/haskell-tools.nvim',
    requires = {
      'neovim/nvim-lspconfig',
      'nvim-lua/plenary.nvim',
      'akinsho/toggleterm.nvim',
    },
    config = function()
      local ht = require('haskell-tools')
      ht.setup {
        repl = {
          handler = 'toggleterm',
        },
      }
    end,
  }

  if install_plugins then
    packer.sync()
  end
end)
andreacfromtheapp commented 1 year ago

Hi @MrcJkb , thank you for your amazing toolingS :)

If you can't reproduce, I'm fairly sure it could be an issue with my setup. I use LunarVim, not vanilla Neovim, and I hope the minimal setup works as intended.

Besides the obvious mkdir, where should I set NVIM_DATA_MINIMAL=/tmp/minimal -u minimal.lua variable? Is that a shell environment variable? (I use zsh).

Please and thank you

ps: should interest you/make it easier, I could make my config repo temporarily public or give you access to it.

andreacfromtheapp commented 1 year ago

ps: I forgot to answer your question: it's just a simple chapter06.exercises.hs file, no stack.yaml. I'm currently learning Haskell with Graham Hutton's book.

mrcjkb commented 1 year ago

Besides the obvious mkdir, where should I set NVIM_DATA_MINIMAL=/tmp/minimal -u minimal.lua variable? Is that a shell environment variable? (I use zsh).

In zsh, you can prefix commands with environment variables, for example

❯ FOO="bar" echo "$FOO"
bar

passes the environment variable FOO="bar" to the echo command.

So by calling

❯ NVIM_DATA_MINIMAL=/tmp/minimal nvim -u minimal.lua

you are passing NVIM_DATA_MINIMAL=/tmp/minimal to the nvim command.

Here are some more commands you could try:

:lua require'toggleterm.terminal'.Terminal:new({hidden=true, close_on_exit=true}):toggle()

:lua require'toggleterm.terminal'.Terminal:new({hidden=true, close_on_exit=true, cmd = 'ghci chapter06.exercises.hs'}):toggle()

:lua require'toggleterm.terminal'.Terminal:new({hidden=true, close_on_exit=true, cmd = 'ghci'}):toggle()

These are the toggleterm functions that haskell-tools.nvim should be calling under the hood. If they don't work for you, it's probably a toggleterm or LunarVim/config issue. If they do work for you, I might be able to help by looking at your config and the file you are working with.

With the Haskell file open, what is the output of

:lua vim.pretty_print(require'haskell-tools'.repl.mk_repl_cmd(vim.api.nvim_buf_get_name(0)))

?

andreacfromtheapp commented 1 year ago

hi :)

Thanks for offering to look into my config/files :) I appreciate. I'll give you access as I don't want to make the books content/exercises public.

mrcjkb commented 1 year ago

ok about NVIM_DATA_MINIMAL=/tmp/minimal nvim -u minimal.lua , you had forgot the nvim command in the first reply.

oops :man_facepalming:

  • I successfully run the minimal config and steps from the first reply as well. No issues whatsoever.
  • pretty print result is {"ghci", "/Users/dada/foo.hs"}
  • all toggleterm commands also run without issues

:thinking: so it must be a LunarVim config.

I just installed LunarVim into a docker image

> docker run -w /root -it --rm alpine:edge sh -uelic 'apk add git neovim ripgrep alpine-sdk bash zsh ghc github-cli --update && LV_BRANCH='release-1.2/neovim-0.8' bash <(curl -s https://raw.githubusercontent.com/lunarvim/lunarvim/master/utils/installer/install.sh) && zsh -i'

and cloned your repo into /.config/lvim + enabled the repl.handler = 'toggleterm' config.

In the docker image, it worked fine with your config.

I did notice one thing though:

When opening a file, LunarVim opens a file tree (I guess NeoTree.nvim) and places the cursor in it. So when you call vim.api.nvim_buf_get_name(0) while the cursor is in the file tree, it will return the name of the NeoTree buffer , and not the name of the Haskell file (you find out which buffer you are in by calling :lua print(vim.api.nvim_buf_get_name(0))). As a result, haskell-tools won't be able to construct a command to start the repl. To start a repl, you have to place the cursor in the Haskell file.

andreacfromtheapp commented 1 year ago

Hi @MrcJkb :)

thanks for doing this, I appreciate. I can't understand why then. The only things left would be macOS and iTerm but I can try a different one on my linux box.

Regarding neo-tree opening by default, it's a setting I made (see lua/user/autocmds.lua) cause I like that particular layout. In the autocmd it should leverage CTRL+W CTRL+W but at times it's stuck in the file explorer. No biggie tho, I just hit the keys manually.

I guess there's no more you could do. You went already 5 extra miles and I appreciate ;)

I'll try to reset stuff, try the docker "version", try it on linux, and see if I can fix this. In the mean time I'm using repl.handler = 'builtin' even if it's not ideal, as it doesn't automatically focus the repl, and I need to hit CTRL+W. One more thing I could try is using iron. It does work with my tidal setup, and it may be worth trying again with haskell.

mrcjkb commented 1 year ago

I have just added logging to the plugin. If you update, you can call

:lua require('haskell-tools').log.set_level(vim.log.levels.DEBUG)

Then reproduce the bug and afterwards, call

:lua require('haskell-tools').log.nvim_open_logfile()

and copy/paste the contents of the log file to this issue.

Maybe the logs will help figure this out :)

andreacfromtheapp commented 1 year ago

debug is being problematic here:

Screenshot 2023-01-08 at 9 46 44 PM

sorry about the screenshot, I don't know how to copy :messages

EDIT: it only happens when I enable togglterm. nevermind.

andreacfromtheapp commented 1 year ago
[START][2023-01-08 21:42:44] haskell-tools.nvim logging initiated
[START][2023-01-08 21:42:49] haskell-tools.nvim logging initiated
[START][2023-01-08 21:42:56] haskell-tools.nvim logging initiated
[START][2023-01-08 21:42:58] haskell-tools.nvim logging initiated
[START][2023-01-08 21:43:10] haskell-tools.nvim logging initiated
[START][2023-01-08 21:43:58] haskell-tools.nvim logging initiated
[START][2023-01-08 21:44:35] haskell-tools.nvim logging initiated
[START][2023-01-08 21:45:04] haskell-tools.nvim logging initiated
[START][2023-01-08 21:45:09] haskell-tools.nvim logging initiated
DEBUG | 2023-01-08 21:45:55 | ...acker/start/haskell-tools.nvim/lua/haskell-tools/lsp.lua:14 | Stopping LSP client...
[START][2023-01-08 21:46:22] haskell-tools.nvim logging initiated
[START][2023-01-08 21:47:23] haskell-tools.nvim logging initiated
[START][2023-01-08 21:47:36] haskell-tools.nvim logging initiated
[START][2023-01-08 21:47:39] haskell-tools.nvim logging initiated
DEBUG | 2023-01-08 21:48:30 | ...cker/start/haskell-tools.nvim/lua/haskell-tools/repl.lua:87 | { "mk_repl_cmd", { "ghci", "/Users/gacallea/ProjectsandIdeas/Programming/Haskell/programmingInHaskell/ch05 - List comprehensions/caesarCipher.hs" } }
DEBUG | 2023-01-08 21:48:30 | ...rt/haskell-tools.nvim/lua/haskell-tools/repl/builtin.lua:111 | repl.builtin: is not loaded
DEBUG | 2023-01-08 21:48:30 | ...rt/haskell-tools.nvim/lua/haskell-tools/repl/builtin.lua:117 | repl.builtin: Created window 1012
DEBUG | 2023-01-08 21:48:30 | ...rt/haskell-tools.nvim/lua/haskell-tools/repl/builtin.lua:42 | { "repl.builtin: Opening terminal", { "ghci", "/Users/gacallea/ProjectsandIdeas/Programming/Haskell/programmingInHaskell/ch05 - List comprehensions/caesarCipher.hs" }, {    size = 22,    <metatable> = {      __tostring = <function 1>    }  } }
DEBUG | 2023-01-08 21:48:30 | ...rt/haskell-tools.nvim/lua/haskell-tools/repl/builtin.lua:49 | { "repl.builtin: Created repl.", {    bufnr = 15,    cmd = { "ghci", "/Users/gacallea/ProjectsandIdeas/Programming/Haskell/programmingInHaskell/ch05 - List comprehensions/caesarCipher.hs" },    job_id = 5  } }
mrcjkb commented 1 year ago

Sorry, it looks like I had a typo in there. I just fixed it, so you should be able to debug log with toggleterm as the handler.

andreacfromtheapp commented 1 year ago
DEBUG | 2023-01-08 21:53:24 | ...acker/start/haskell-tools.nvim/lua/haskell-tools/lsp.lua:14 | Stopping LSP client...
DEBUG | 2023-01-08 21:54:27 | ...cker/start/haskell-tools.nvim/lua/haskell-tools/repl.lua:87 | { "mk_repl_cmd", { "ghci", "/Users/gacallea/ProjectsandIdeas/Programming/Haskell/programmingInHaskell/ch05 - List comprehensions/caesarCipher.hs" } }
DEBUG | 2023-01-08 21:54:27 | ...haskell-tools.nvim/lua/haskell-tools/repl/toggleterm.lua:36 | { "repl.toggleterm: New command", "ghci /Users/gacallea/ProjectsandIdeas/Programming/Haskell/programmingInHaskell/ch05 - List comprehensions/caesarCipher.hs" }
andreacfromtheapp commented 1 year ago

one more run with two different files:

[START][2023-01-08 21:56:22] haskell-tools.nvim logging initiated
DEBUG | 2023-01-08 21:56:48 | ...cker/start/haskell-tools.nvim/lua/haskell-tools/repl.lua:87 | { "mk_repl_cmd", { "ghci", "/Users/gacallea/ProjectsandIdeas/Programming/Haskell/programmingInHaskell/ch05 - List comprehensions/caesarCipher.hs" } }
DEBUG | 2023-01-08 21:56:48 | ...haskell-tools.nvim/lua/haskell-tools/repl/toggleterm.lua:36 | { "repl.toggleterm: New command", "ghci /Users/gacallea/ProjectsandIdeas/Programming/Haskell/programmingInHaskell/ch05 - List comprehensions/caesarCipher.hs" }
DEBUG | 2023-01-08 21:56:53 | ...acker/start/haskell-tools.nvim/lua/haskell-tools/lsp.lua:41 | LSP attach
DEBUG | 2023-01-08 21:56:56 | ...cker/start/haskell-tools.nvim/lua/haskell-tools/repl.lua:87 | { "mk_repl_cmd", { "ghci", "/Users/gacallea/ProjectsandIdeas/Programming/Haskell/programmingInHaskell/ch05 - List comprehensions/ch05.exercises.hs" } }
DEBUG | 2023-01-08 21:56:56 | ...haskell-tools.nvim/lua/haskell-tools/repl/toggleterm.lua:36 | { "repl.toggleterm: New command", "ghci /Users/gacallea/ProjectsandIdeas/Programming/Haskell/programmingInHaskell/ch05 - List comprehensions/ch05.exercises.hs" }

ch05.exercises also thows this:

Screenshot 2023-01-08 at 9 58 32 PM
andreacfromtheapp commented 1 year ago

sorry about the spam, I just noticed this new error after resetting the cache and launching lvim:

Screenshot 2023-01-08 at 10 00 58 PM

it goes away if I close/reopen lvim and ofc toggleterm is installed.

mrcjkb commented 1 year ago

:thinking: I have just added some more logging and fixed the got nil error. Could you please update and attach them again?

sorry about the spam, I just noticed this new error after resetting the cache and launching lvim:

No problem. haskell-tools will print an error message if it is configured to use toggleterm, but toggleterm isn't installed.

andreacfromtheapp commented 1 year ago
[START][2023-01-08 22:27:32] haskell-tools.nvim logging initiated
DEBUG | 2023-01-08 22:28:01 | ...cker/start/haskell-tools.nvim/lua/haskell-tools/repl.lua:87 | { "mk_repl_cmd", { "ghci", "/Users/gacallea/ProjectsandIdeas/Programming/Haskell/programmingInHaskell/ch04 - Defining functions/ch04.exercises.hs" } }
DEBUG | 2023-01-08 22:28:01 | ...haskell-tools.nvim/lua/haskell-tools/repl/toggleterm.lua:42 | { "repl.toggleterm: New command", "ghci /Users/gacallea/ProjectsandIdeas/Programming/Haskell/programmingInHaskell/ch04 - Defining functions/ch04.exercises.hs" }
DEBUG | 2023-01-08 22:28:01 | ...haskell-tools.nvim/lua/haskell-tools/repl/toggleterm.lua:22 | { "Creating new terminal", {    close_on_exit = true,    cmd = "ghci /Users/gacallea/ProjectsandIdeas/Programming/Haskell/programmingInHaskell/ch04 - Defining functions/ch04.exercises.hs",    hidden = true  } }
andreacfromtheapp commented 1 year ago

I believe that hidden = true comes from Lunarvim. Even if that's weird, cause it's a setting for lazygit terminal?

andreacfromtheapp commented 1 year ago

ps: I also believe that's relevant. Cause toogleterm "tries to open" but closes immediately.

mrcjkb commented 1 year ago

Okay, this is really strange. According to the logs, everything should be working fine. The only thing that could be failing is the call to toggleterm.

What happens if you call :lua require('haskell-tools.repl.toggleterm').terminal:toggle() after calling :lua require('haskell-tools').repl.toggle(vim.api.nvim_buf_get_name(0))?

hidden=true is fine. It's set when creating the terminal so that it doesn't show up until it's needed.

ps: I also believe that's relevant. Cause toogleterm "tries to open" but closes immediately.

Thats interesting. It could be that the ghci command is failing, and then toggleterm exits immediately because of close_on_exit=true. I should probably configure it to only close on exit if the command it is trying to run is doesn't fail.

andreacfromtheapp commented 1 year ago

What happens if you call :lua require('haskell-tools.repl.toggleterm').terminal:toggle() after calling :lua require('haskell-tools').repl.toggle(vim.api.nvim_buf_get_name(0))?

same behaviour: it opens/closes immediately. logs:

[START][2023-01-08 22:42:35] haskell-tools.nvim logging initiated
[START][2023-01-08 22:42:42] haskell-tools.nvim logging initiated
[START][2023-01-08 22:42:47] haskell-tools.nvim logging initiated
[START][2023-01-08 22:42:48] haskell-tools.nvim logging initiated
DEBUG | 2023-01-08 22:43:08 | ...cker/start/haskell-tools.nvim/lua/haskell-tools/repl.lua:87 | { "mk_repl_cmd", { "ghci", "/Users/gacallea/ProjectsandIdeas/Programming/Haskell/programmingInHaskell/ch05 - List comprehensions/caesarCipher.hs" } }
DEBUG | 2023-01-08 22:43:08 | ...haskell-tools.nvim/lua/haskell-tools/repl/toggleterm.lua:42 | { "repl.toggleterm: New command", "ghci /Users/gacallea/ProjectsandIdeas/Programming/Haskell/programmingInHaskell/ch05 - List comprehensions/caesarCipher.hs" }
DEBUG | 2023-01-08 22:43:08 | ...haskell-tools.nvim/lua/haskell-tools/repl/toggleterm.lua:22 | { "Creating new terminal", {    close_on_exit = true,    cmd = "ghci /Users/gacallea/ProjectsandIdeas/Programming/Haskell/programmingInHaskell/ch05 - List comprehensions/caesarCipher.hs",    hidden = true  } }
andreacfromtheapp commented 1 year ago

Thats interesting. It could be that the ghci command is failing, and then toggleterm exits immediately because of close_on_exit=true. I should probably configure it to only close on exit if the command it is trying to run is doesn't fail.

that is as interesting as it's weird tho. ghci works with builtin (or if I open toggleterm manually, then run ghci)

mrcjkb commented 1 year ago

I just added some logs that should hopefully give some insight into what is happening in toggleterm. Sorry for this back and forth with the logs :sweat_smile:

andreacfromtheapp commented 1 year ago

also, I tried with lua require('haskell-tools').repl.load_file(vim.api.nvim_buf_get_name(0)) and get:

Screenshot 2023-01-08 at 10 50 04 PM
andreacfromtheapp commented 1 year ago

I just added some logs that should hopefully give some insight into what is happening in toggleterm. Sorry for this back and forth with the logs 😅

no need to be sorry! I thank you for this!!!

trying

andreacfromtheapp commented 1 year ago
[START][2023-01-08 22:51:53] haskell-tools.nvim logging initiated
DEBUG | 2023-01-08 22:52:14 | ...cker/start/haskell-tools.nvim/lua/haskell-tools/repl.lua:87 | { "mk_repl_cmd", { "ghci", "/Users/gacallea/ProjectsandIdeas/Programming/Haskell/programmingInHaskell/ch05 - List comprehensions/caesarCipher.hs" } }
DEBUG | 2023-01-08 22:52:14 | ...haskell-tools.nvim/lua/haskell-tools/repl/toggleterm.lua:55 | { "repl.toggleterm: New command", "ghci /Users/gacallea/ProjectsandIdeas/Programming/Haskell/programmingInHaskell/ch05 - List comprehensions/caesarCipher.hs" }
DEBUG | 2023-01-08 22:52:14 | ...haskell-tools.nvim/lua/haskell-tools/repl/toggleterm.lua:35 | { "Creating new terminal", {    close_on_exit = true,    cmd = "ghci /Users/gacallea/ProjectsandIdeas/Programming/Haskell/programmingInHaskell/ch05 - List comprehensions/caesarCipher.hs",    hidden = true,    on_exit = <function 1>,    on_stderr = <function 2>,    on_stdout = <function 3>  } }
DEBUG | 2023-01-08 22:52:14 | ...haskell-tools.nvim/lua/haskell-tools/repl/toggleterm.lua:26 | { "Job 4 - stdout", { "GHCi, version 9.2.5: https://www.haskell.org/ghc/  :? for help\r", "" }, "stdout" }
DEBUG | 2023-01-08 22:52:14 | ...haskell-tools.nvim/lua/haskell-tools/repl/toggleterm.lua:26 | { "Job 4 - stdout", { "ghc-9.2.5: unrecognised flag: -\r", "" }, "stdout" }
DEBUG | 2023-01-08 22:52:14 | ...haskell-tools.nvim/lua/haskell-tools/repl/toggleterm.lua:26 | { "Job 4 - stdout", { "\r", "Usage: For basic information, try the `--help' option.\r", "" }, "stdout" }
DEBUG | 2023-01-08 22:52:14 | ...haskell-tools.nvim/lua/haskell-tools/repl/toggleterm.lua:26 | { "Job 4 - stdout", { "" }, "stdout" }
DEBUG | 2023-01-08 22:52:14 | ...haskell-tools.nvim/lua/haskell-tools/repl/toggleterm.lua:32 | { "Job 4 - exit code 1", "exit" }
andreacfromtheapp commented 1 year ago

ah!

mrcjkb commented 1 year ago

Finally something useful :partying_face:

andreacfromtheapp commented 1 year ago

trying another ghci

mrcjkb commented 1 year ago

DEBUG | 2023-01-08 22:52:14 | ...haskell-tools.nvim/lua/haskell-tools/repl/toggleterm.lua:26 | { "Job 4 - stdout", { "ghc-9.2.5: unrecognised flag: -\r", "" }, "stdout" }

\r is a line break on MacOS. On Linux, line breaks are represented with \n. That would explain why it's not reproducible on Linux.

andreacfromtheapp commented 1 year ago

I tried 9.0.2, same result. I thought it was -r as an option to ghci. but eh :P

DEBUG | 2023-01-08 23:00:08 | ...cker/start/haskell-tools.nvim/lua/haskell-tools/repl.lua:87 | { "mk_repl_cmd", { "ghci", "/Users/gacallea/ProjectsandIdeas/Programming/Haskell/programmingInHaskell/ch05 - List comprehensions/caesarCipher.hs" } }
DEBUG | 2023-01-08 23:00:08 | ...haskell-tools.nvim/lua/haskell-tools/repl/toggleterm.lua:26 | { "Job 7 - stdout", { "GHCi, version 9.0.2: https://www.haskell.org/ghc/  :? for help\r", "" }, "stdout" }
DEBUG | 2023-01-08 23:00:08 | ...haskell-tools.nvim/lua/haskell-tools/repl/toggleterm.lua:26 | { "Job 7 - stdout", { "ghc-9.0.2: unrecognised flag: -\r", "" }, "stdout" }
DEBUG | 2023-01-08 23:00:08 | ...haskell-tools.nvim/lua/haskell-tools/repl/toggleterm.lua:26 | { "Job 7 - stdout", { "\r", "Usage: For basic information, try the `--help' option.\r", "" }, "stdout" }
DEBUG | 2023-01-08 23:00:08 | ...haskell-tools.nvim/lua/haskell-tools/repl/toggleterm.lua:26 | { "Job 7 - stdout", { "" }, "stdout" }
DEBUG | 2023-01-08 23:00:08 | ...haskell-tools.nvim/lua/haskell-tools/repl/toggleterm.lua:32 | { "Job 7 - exit code 1", "exit" }
DEBUG | 2023-01-08 23:00:13 | ...cker/start/haskell-tools.nvim/lua/haskell-tools/repl.lua:87 | { "mk_repl_cmd", { "ghci", "/Users/gacallea/ProjectsandIdeas/Programming/Haskell/programmingInHaskell/ch05 - List comprehensions/caesarCipher.hs" } }
DEBUG | 2023-01-08 23:00:13 | ...haskell-tools.nvim/lua/haskell-tools/repl/toggleterm.lua:26 | { "Job 8 - stdout", { "GHCi, version 9.0.2: https://www.haskell.org/ghc/  :? for help\r", "" }, "stdout" }
DEBUG | 2023-01-08 23:00:13 | ...haskell-tools.nvim/lua/haskell-tools/repl/toggleterm.lua:26 | { "Job 8 - stdout", { "ghc-9.0.2: unrecognised flag: -\r", "" }, "stdout" }
DEBUG | 2023-01-08 23:00:13 | ...haskell-tools.nvim/lua/haskell-tools/repl/toggleterm.lua:26 | { "Job 8 - stdout", { "\r", "Usage: For basic information, try the `--help' option.\r", "" }, "stdout" }
DEBUG | 2023-01-08 23:00:14 | ...haskell-tools.nvim/lua/haskell-tools/repl/toggleterm.lua:26 | { "Job 8 - stdout", { "" }, "stdout" }
DEBUG | 2023-01-08 23:00:14 | ...haskell-tools.nvim/lua/haskell-tools/repl/toggleterm.lua:32 | { "Job 8 - exit code 1", "exit" }
DEBUG | 2023-01-08 23:00:18 | ...haskell-tools.nvim/lua/haskell-tools/repl/toggleterm.lua:26 | { "Job 9 - stdout", { "GHCi, version 9.0.2: https://www.haskell.org/ghc/  :? for help\r", "" }, "stdout" }
DEBUG | 2023-01-08 23:00:18 | ...haskell-tools.nvim/lua/haskell-tools/repl/toggleterm.lua:26 | { "Job 9 - stdout", { "ghc-9.0.2: unrecognised flag: -\r", "" }, "stdout" }
DEBUG | 2023-01-08 23:00:18 | ...haskell-tools.nvim/lua/haskell-tools/repl/toggleterm.lua:26 | { "Job 9 - stdout", { "\r", "Usage: For basic information, try the `--help' option.\r", "" }, "stdout" }
DEBUG | 2023-01-08 23:00:18 | ...haskell-tools.nvim/lua/haskell-tools/repl/toggleterm.lua:26 | { "Job 9 - stdout", { "" }, "stdout" }
DEBUG | 2023-01-08 23:00:18 | ...haskell-tools.nvim/lua/haskell-tools/repl/toggleterm.lua:32 | { "Job 9 - exit code 1", "exit" }
andreacfromtheapp commented 1 year ago

DEBUG | 2023-01-08 22:52:14 | ...haskell-tools.nvim/lua/haskell-tools/repl/toggleterm.lua:26 | { "Job 4 - stdout", { "ghc-9.2.5: unrecognised flag: -\r", "" }, "stdout" }

\r is a line break on MacOS. On Linux, line breaks are represented with \n. That would explain why it's not reproducible on Linux.

that is weird tho. it used to work just fine.

mrcjkb commented 1 year ago

that is weird tho. it used to work just fine.

My guess is that since a recent update, toggleterm adds a \t character to the command (not sure yet).

andreacfromtheapp commented 1 year ago

well, we got somewhere at least :) thank you so very much indeed! good night for now.

mrcjkb commented 1 year ago

I think I just figured it out!

:lua require'toggleterm.terminal'.Terminal:new({hidden=false, close_on_exit=false, cmd = 'ghci /Users/gacallea/ProjectsandIdeas/Programming/Haskell/programmingInHaskell/ch05 - List comprehensions/caesarCipher.hs'}):toggle()

fails with unrecognized flag -

But

:lua require'toggleterm.terminal'.Terminal:new({hidden=false, close_on_exit=false, cmd = 'ghci /Users/gacallea/ProjectsandIdeas/Programming/Haskell/programmingInHaskell/ch05 List comprehensions/caesarCipher.hs'}):toggle()

doesn't.

Because the file path is passed to ghci without quotes, it fails on the '-'

mrcjkb commented 1 year ago

Should be fixed now :)

Please re-open if it isn't.

andreacfromtheapp commented 1 year ago

hi @MrcJkb :)

thank you so much! the two luad toggleterm commands above behave the same here too :)

however, haskell tools commands still fail. you may want to check those too?

These are the keymaps I use:

lvim.builtin.which_key.mappings["h"] = {
[...]
  g = {
    name = "GHCi REPL",
    p = { "<cmd>lua require('haskell-tools').repl.toggle()<cr>", "Toggle GHCi for Package" },
    **f = { "<cmd>lua require('haskell-tools').repl.toggle(vim.api.nvim_buf_get_name(0))<cr>", "Toggle GHCi File" },**
    F = { "<cmd>lua require('haskell-tools').repl.load_file(vim.api.nvim_buf_get_name(0))<cr>", "Load File in REPL" },
    c = { "<cmd>lua require('haskell-tools').repl.paste(reg)<cr>", "Command to GHCi" },
    t = { "<cmd>lua require('haskell-tools').repl.paste_type(reg)<cr>", "Type to GHCi" },
    r = { "<cmd>lua require('haskell-tools').repl.reload()<cr>", "Reload GHCi" },
    q = { "<cmd>lua require('haskell-tools').repl.quit()<cr>", "Quit GHCi" },
  },
[...]
}

the f in bold is the one using the underlying toggleterm cmd we've been testing in this issue, you may want to review the others too. let me know if need me testing some more.

andreacfromtheapp commented 1 year ago

ps: can't reopen the issue, apprently.

mrcjkb commented 1 year ago

Have you updated the haskell-tools plugin today and tried again? The issue should be fixed with #98.

andreacfromtheapp commented 1 year ago

yes, I did run :PackerSync and :LvimCacheReset but still. How do I check the haskell-tools --version/revision?

mrcjkb commented 1 year ago

Ah, I accidentally only applied the fix for cabal and stack projects. Should be fixed now.

haskell-tools doesn't provide a command to check the version/revision.

andreacfromtheapp commented 1 year ago

YAS!!! "we" did it :)

Yuo are the best! thank you so much for your dedicated help and fantastic tools <3

I'll remove access from my repo now.

mrcjkb commented 1 year ago

Thanks for helping me fix it :smile:

mrcjkb commented 1 year ago

@all-contributors please add @gacallea for bug.

allcontributors[bot] commented 1 year ago

@mrcjkb

I've put up a pull request to add @gacallea! :tada:

mrcjkb commented 1 year ago

@all-contributors please add @gacallea for userTesting

allcontributors[bot] commented 1 year ago

@mrcjkb

I've put up a pull request to add @gacallea! :tada: