Skip to content

Eval not working (code action disappears) when a certain function exists in buffer #221

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

Closed
leana8959 opened this issue Jul 24, 2023 · 1 comment

Comments

@leana8959
Copy link

Neovim version (nvim -v)

v0.9.1

Operating system/version

macOS 13.4.1

Output of haskell-language-server-wrapper --version

2.0.0.1 (GHC: 9.4.4)

How to reproduce the issue

I made a repr project repo here. Please go to Q1to10.hs

Here's a snippet of the problematic code:

-- Recursive method
-- We can only match on the left side of the list
-- which means we can only construct the list from the right (reversed).
-- This is less efficient because Haskell's lists are linked lists.
myReverse :: [a] -> [a]
myReverse [] = []
myReverse (x : xs) = myReverse xs ++ [x]

-- 8
-- >>> head [1,2,3]
compress :: (Eq a) => [a] -> [a]
compress [] = []
compress (x : xs) = x : compress (dropWhile (== x) xs)

If I keep the paragraph of code above --8, the codeaction button would disappear and the command to evaluate would not run.

I also tried to add another eval line above "myReverse". It the line above "myReverse" would work and the one below wouldn't.

Expected behaviour

Evaluate lines starting with -- >>>.

Actual behaviour

Code action button disappears, command / keybind doesn't actuate the evaluation.

Log files

https://gist.github.com/leana8959/5e417d4c36e84f8b14f1a1b33bd5d9e1

The minimal config used to reproduce this issue.

-- Minimal nvim config with packer
-- Assumes a directory in $NVIM_DATA_MINIMAL
-- Start with $NVIM_DATA_MINIMAL=$(mktemp -d) nvim -u minimal.lua
-- Then exit out of neovim and start again.

-- 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 [email protected]: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',
}

vim.cmd('runtime! plugin/plenary.vim')

packer.startup(function(use)
    use('wbthomason/packer.nvim')
    use {
        'mrcjkb/haskell-tools.nvim',
        requires = {
            'nvim-lua/plenary.nvim',
        },
        branch = '1.x.x',
    }
end)


-- haskell-tools config
local on_attach = function(_, bufnr)
    vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')

    vim.keymap.set('n', '<space>hs', require("haskell-tools").hoogle.hoogle_signature,
        { desc = "Hoogle signature", buffer = bufnr })
    vim.keymap.set('n', '<space>he', require("haskell-tools").lsp.buf_eval_all, { desc = "Evaluate all", buffer = bufnr })
end

local setup_ht = function()
    require("haskell-tools").start_or_attach {
        tools = {
            hover = {
                stylize_markdown = true,
            }
        },
        hls = {
            on_attach = on_attach,
            default_settings = {
                haskell = {
                    formattingProvider = "ormolu"
                }
            }
        }
    }
end
vim.api.nvim_create_autocmd("FileType", {
    pattern = { "haskell", "lhaskell", "cabal" },
    callback = setup_ht,
})
@leana8959 leana8959 added the bug Something isn't working label Jul 24, 2023
@mrcjkb
Copy link
Owner

mrcjkb commented Jul 24, 2023

@mrcjkb mrcjkb closed this as completed Jul 24, 2023
@mrcjkb mrcjkb added upstream (hls) and removed bug Something isn't working labels Jul 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants