mrcjkb / haskell-tools.nvim

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

telescope hoogle_signature open in browser with <C-b> with wrong url #336

Closed Pcrab closed 8 months ago

Pcrab commented 8 months ago

Neovim version (nvim -v)

v0.10.0-dev-2085+g310fb2efc-Homebrew

Operating system/version

macOS 14.2.1

Output of :checkhealth haskell-tools

==============================================================================
haskell-tools: require("haskell-tools.health").check()

Checking for Lua dependencies ~
- OK [nvim-telescope/telescope.nvim](https://github.com/nvim-telescope/telescope.nvim) installed.

Checking external dependencies ~
- OK haskell-language-server: found haskell-language-server version: 2.5.0.0 (GHC: 9.2.8) (PATH: /Users/pangxw/.local/share/ghcup/hls/2.5.0.0/lib/haskell-language-server-2.5.0.0/bin/haskell-language-server-wrapper)
- OK hoogle: found Hoogle 5.0.18.4, https://hoogle.haskell.org/
- OK fast-tags: found fast-tags, version 2.0.2
- OK curl: found curl 8.4.0 (x86_64-apple-darwin23.0) libcurl/8.4.0 (SecureTransport) LibreSSL/3.3.6 zlib/1.2.12 nghttp2/1.55.1
- OK haskell-debug-adapter: found haskell-debug-adapter-0.0.39.0
- OK ghci-dap: found The Glorious Glasgow Haskell Compilation System, version 9.4.8

Checking config ~
- OK No errors found in config.

Checking for conflicting plugins ~
- OK No conflicting plugins detected.

How to reproduce the issue

Open telescope with <CMD>lua require('haskell-tools').hoogle.hoogle_signature()<CR>, select any item, and press <C-b> to open doc in browser.

The browser will open a tab with url like https://hackage.haskell.org/package/base-4.19.0.0/docs/Prelude.html%5C#v:putStrLn, which is wrong. There shouldn't be a %5C between pathname and the hash.

Expected behaviour

open browser with correct url

Actual behaviour

with additional escape character \ (%5C)

Log files

No response

The minimal config used to reproduce this issue.

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

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

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

-- bootstrap lazy.nvim
data_path = assert(os.getenv("NVIM_DATA_MINIMAL"), "$NVIM_DATA_MINIMAL environment variable not set!")
local lazypath = data_path .. "/lazy/lazy.nvim"
local uv = vim.uv
    ---@diagnostic disable-next-line: deprecated
    or vim.loop
if not uv.fs_stat(lazypath) then
    vim.fn.system({
        "git",
        "clone",
        "--filter=blob:none",
        "git@github.com:folke/lazy.nvim.git",
        "--branch=stable",
        lazypath,
    })
end
vim.opt.rtp:prepend(lazypath)

local lazy = require("lazy")

lazy.setup({
    {
        "mrcjkb/haskell-tools.nvim",
        version = "^3", -- Recommended
        init = function()
            -- Configure haskell-tools.nvim here
            vim.g.haskell_tools = {}
        end,
        dependencies = {
            -- Uncomment or add any optional dependencies needed to reproduce the issue
            "nvim-lua/plenary.nvim",
            "nvim-telescope/telescope.nvim",
            -- 'akinsho/toggleterm.nvim',
        },
        ft = { "haskell", "lhaskell", "cabal", "cabalproject" },
        keys = {
            {
                "<leader>hs",
                "<CMD>lua require('haskell-tools').hoogle.hoogle_signature()<CR>",
                desc = "Hoogle signature",
                ft = { "haskell" },
            },
            {
                "<leader>rr",
                "<CMD>lua require('haskell-tools').repl.toggle()<CR>",
                desc = "Toggle GHCi repl",
                ft = { "haskell", "lhaskell" },
            },
            {
                "<leader>rq",
                "<CMD>lua require('haskell-tools').repl.toggle()<CR>",
                desc = "Close GHCi repl",
                ft = { "haskell", "lhaskell" },
            },
        },
    },
    -- Add any other plugins needed to reproduce the issue.
    -- see https://github.com/folke/lazy.nvim#-lazynvim for details.
}, { root = data_path, state = data_path .. "/lazy-state.json", lockfile = data_path .. "/lazy-lock.json" })
Pcrab commented 8 months ago

https://github.com/mrcjkb/haskell-tools.nvim/blob/64613cc69876524ac59f5ca3ff63ecdd04a98796/lua/haskell-tools/hoogle/helpers.lua#L37

If I change it to OS.open_browser(entry.url), then everything works fine.

mrcjkb commented 8 months ago

Hey :wave:

Thanks for reporting! Fixed with https://github.com/mrcjkb/haskell-tools.nvim/commit/2faa2c879c82652f1df3974c185901cf93c6367c.