mrcjkb / haskell-tools.nvim

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

Would it be possible to implement a LazyVim "compliant" haskell.lua extra.lang plugin? #290

Closed andreacfromtheapp closed 12 months ago

andreacfromtheapp commented 12 months ago

Feature description

Hi :)

Premise: long time no see! I had to begrudgingly abandon the idea of finding a junior job with Haskell but I still love the language. It won't be my main focus, but still would love to learn in "my spare time" (sure, spare time!). I've used your tools with LunarVim so far and no issues whatsoever. However, I'm trying out LazyVim and I like it very much. It is easy to start with but customizing seems more convoluted. Anything I tried so far (but what I propose here) just seems to crash LazyVim.

Feature Request: I was wondering if you could come up with a native haskell.lua file to use with LazyVim and perhaps submit for their extra lang native plugins. Given the similarities one could base it off their rust.lua?

Please and thank you :)

mrcjkb commented 12 months ago

Hey :wave:

It's a shame to hear it didn't work out with finding a Haskell job for you. But glad to hear you're still dabbling in Haskell. I'm sure you'll end up working with it professionally one day :smile:

I don't have the capacity to officially support Neovim distros (as I only use plain nvim myself). But I'll gladly open a PR contributing a Haskell language pack for LazyVim, if you can test and help maintain it. We could probably get some inspiration from the AstroNvim/astrocommunity haskell language pack, too.

andreacfromtheapp commented 12 months ago

Hi!

that was fast! I opened the issue and went for dinner. I just finished dinner and boom. Of course I'm willing to test it. Hopefully maintining it won't be too much. I guess it really depends on folke's vision of stability :P

andreacfromtheapp commented 12 months ago

Hey @mrcjkb

my apologies for the trouble. this is very weird.

once the haskell files open, checkhealth is all OK.

Screen Shot 2023-11-23 at 5 19 25 PM

the issue with that blank screen may lie somewhere else on my system?

as a test I implemented elm.lua (here) similarly to your haskell.lua (here) and no "bug" at all with elm.

I have the same issue with minimal tho!

mkdir -p /tmp/minimal/ && NVIM_DATA_MINIMAL=/tmp/minimal NVIM_APP_NAME=nvim-ht-minimal nvim -u ~/Downloads/minimal.lua -- ~/ProjectsandIdeas/Programming/Haskell/programmingInHaskell/ch07\ -\ Higher-order\ functions/ch07.exercises.hs

When I run the minimal with a file, lazy does its sync/install but then it act as the blank screen. Like it's freezed for a while, until I either hit CTRL+C or wait long enough for the haskell file to appear.

when I open an hs file, the ui freezes, the logs show nothing until the file is loaded/shown. then the log have these lines only:

[START][2023-11-23 17:40:33] haskell-tools.nvim logging initiated
ERROR | 2023-11-23 17:41:02 | .../nvim/lazy/haskell-tools.nvim/lua/haskell-tools/tags.lua:41 | { "Error running fast-tags on project root", 1 }
WARN | 2023-11-23 17:41:02 | ...e/nvim/lazy/haskell-tools.nvim/lua/haskell-tools/dap.lua:128 | dap: Unable to detect project root for file /Users/andreacfromtheapp/ProjectsandIdeas/Programming/Haskell/programmingInHaskell/ch05 - List comprehensions/caesarCipher.hs

I tried adding fast-tags to deps but it doesn't help:

  {
    "mrcjkb/haskell-tools.nvim",
    version = "^3",
    ft = { "haskell", "lhaskell", "cabal", "cabalproject" },
    dependencies = {
      { "nvim-telescope/telescope.nvim", optional = true },
      { "elaforge/fast-tags", optional = true },
    },
    tools = { -- haskell-tools options
      log = {
        level = vim.log.levels.DEBUG,
      },
    },
    config = function()
      local ok, telescope = pcall(require, "telescope")
      if ok then
        telescope.load_extension("ht")
      end
    end,
  },

I hope this helps.

andreacfromtheapp commented 12 months ago

ps: if you want to call it a day and "won't fix it works on my system" I'm fine with it, don't worry :) I will look into my system for issues. as it seems local.

mrcjkb commented 12 months ago

Ah, the log output might be helpful.

I think it's one of these two issues:

I tried adding fast-tags to deps but it doesn't help

fast-tags isn't a neovim plugin. It's a CLI app that generates ctags but for Haskell.

You could try disabling fast-tags by either uninstalling it or by setting

vim.g.haskell_tools = {
  tools = {
    tags = {
      enable = false,
    },
  },
}

to see if it improves. I'm out right now, but I'll have another look when I get home.

andreacfromtheapp commented 12 months ago

I think it's one of these two issues:

  • Either the spaces in your ch05 - List comprehension directory may be causing either haskell-tools or fast-tags to choke (many apps written for Linux don't handle that well).
  • Or the module that tries to find the project root can't handle the MacOS directory structure (I'd find this surprising).

If I cd to the directory and open the file "locallly" it works fine! no freeze :)

fast-tags isn't a neovim plugin. It's a CLI app that generates ctags but for Haskell.

oohps... I have now installed it with cabal. I tested enable/disable -- with a local load no issue!!

not sure which one of the two it is tho, but we have narrowed it down :)

andreacfromtheapp commented 12 months ago

ok so, out of curiosity I added a space to an Elm path and I don't get the freeze issue when loading an .elm file from such path. It may be something to do with they way you construct the path or something?

I also added some more to the haskell.lua but it's incomplete :P would you have time to properly configure the snippet bit?

thank you so much indeed for this and all you do <3

andreacfromtheapp commented 12 months ago

nevermind..... I just noticed it's already there.... d'oh!

mrcjkb commented 12 months ago

@gacallea I've just published a new release with a fix so that the plugin doesn't attempt to generate project tags if no project root can be detected. Could you please update to version 3.0.1 and see if that fixes the issue?

I tried creating your directory and opening a Haskell file in there, but I still couldn't reproduce the behaviour you're describing.

andreacfromtheapp commented 12 months ago

hi @mrcjkb !

from lazy-lock.json I have this update installed "haskell-tools.nvim": { "branch": "master", "commit": "ea1ab0d19d10d514dc0740b5255405d9ac1a3a3f" }, and the issue.....

. . . . . . . . .

is gone!!!!! 🥳

one last change would be to remove the lsp bit to install hls from there and keep the mason config instead. this way it always work, at least here with lazyvim.

thank you so very much indeed!!!!

andreacfromtheapp commented 12 months ago

excerpt from my Haskell lua file:

[...]

  {
    "williamboman/mason.nvim",
    opts = function(_, opts)
      vim.list_extend(opts.ensure_installed, {
        "haskell-language-server",
      })
    end,
  },

[...]

  -- defer actually starting hls to our configuration of haskell-tools.nvim.
  {
    "neovim/nvim-lspconfig",
    opts = {
      setup = {
        hls = function()
          return true -- avoid duplicate servers
        end,
      },
    },
  },
}
andreacfromtheapp commented 12 months ago

I tried creating your directory and opening a Haskell file in there, but I still couldn't reproduce the behaviour you're describing.

this may be because on Linux it works differently? I'm not sure but I suspect that macOS may present some differences here that would inficiate this?

mrcjkb commented 12 months ago

one last change would be to remove the lsp bit to install hls from there and keep the mason config instead. this way it always work, at least here with lazyvim.

Done.

this may be because on Linux it works differently?

It turns out the bug was that the function for generating project tags queried the project root, and if it couldn't find it, returned the string "UNDEFINED", to prevent nil errors. On Linux, fast-tags -R UNDEFINED immediately errors and dies, without any noticeable delay. On MacOS, it may get hung up for a bit, before dying. The solution was to leave the project root as nil and to not attempt to call fast-tags -R <project-root> if it is.

andreacfromtheapp commented 12 months ago

@mrcjkb thank you so very much indeed again! I'd close it, but I leave the choice to you :)

andreacfromtheapp commented 12 months ago

hi @mrcjkb

two things:

1 - thank you so much again for this and apologies for all the trouble. 2 - I gave Astrovim a try and I LOVE IT.

LazyVim was too cumbersome and folke is not so receptive to contributions apparently. LV issues queue seems both long and ignored. I don't blame him. LV really seems only a very opinionated personal project made public more than an editor for everyone.

After a long time with LunarVim and a very short one with LazyVim I may have finally found the perfect (for me) Neovim distribution!

Sorry if I made you sweat on this for nothing. I hope folke will integrate it, apply the changes he see fit to make it idiomatic and maintain it.

andreacfromtheapp commented 10 months ago

@mrcjkb I was wrong. LazyVim is amazing. Using it now. I guess I needed to understand it. I owe an aplogy to folke. Still, AstroNvim is great and I'm glad I contributed haskell (and other plugins) to it. Thank you again for your support!

kellybrower commented 10 months ago

@gacallea I'm hoping to get haskell-tools to work properly in my instance of LazyVim. Care to share the file you used to get it going?

andreacfromtheapp commented 10 months ago

@gacallea I'm hoping to get haskell-tools to work properly in my instance of LazyVim. Care to share the file you used to get it going?

Hi @kellybrower, sure thing.

premise: I'm not a haskell dev, I had to abandone learning. Thus I'm not using this anymore.

as you can see I split concerns in my lazyvim config. I hope this can help.