Skip to content

Commit 30329d4

Browse files
authored
Merge pull request #76 from MrcJkb/74-fix-mandatory-telescope
fix(hoogle): don't setup hoogle local when telescope is missing
2 parents 9aa1de6 + 77f7e2e commit 30329d4

File tree

8 files changed

+101
-26
lines changed

8 files changed

+101
-26
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
## [1.4.3] - 2022-12-06
10+
### Fixed
11+
- Error message shown if hoogle is installed, but telescope is missing
12+
913
## [1.4.2] - 2022-11-19
1014
### Fixed
1115
- Bug causing hls to always use default settings

flake.lock

Lines changed: 75 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,10 @@
103103
in
104104
{
105105
formatting = pre-commit-check-for system;
106-
inherit (checkPkgs) haskell-tools-test;
106+
inherit (checkPkgs)
107+
haskell-tools-test
108+
haskell-tools-test-no-telescope
109+
haskell-tools-test-no-telescope-with-hoogle;
107110
});
108111
};
109112
}

lua/haskell-tools/deps.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ function M.require_or_err(modname, plugin_name)
2525
return M.if_available(modname, function(mod)
2626
return mod
2727
end, function()
28-
error('haskell-tools: This plugin requires the ' .. plugin_name .. ' plugin.')
28+
vim.notify_once('haskell-tools: This plugin requires the ' .. plugin_name .. ' plugin.', vim.log.levels.ERROR)
2929
end)
3030
end
3131

lua/haskell-tools/hoogle/local.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ local function setup_telescope_search()
6666
end
6767

6868
function M.setup()
69-
if M.has_hoogle() then
69+
if M.has_hoogle() and deps.has_telescope() then
7070
setup_telescope_search()
7171
end
7272
end

nix/test-overlay.nix

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
{ packer-nvim, plenary-nvim, nvim-lspconfig, telescope-nvim }:
22
final: prev:
33
with final.lib;
4+
with final.lib.strings;
45
with final.stdenv;
56

67
let
7-
mkPlenaryTest = { nvim ? final.neovim, name }: mkDerivation {
8+
mkPlenaryTest = { name, nvim ? final.neovim, withTelescope ? true, extraPkgs ? [ ] }: mkDerivation {
89
inherit name;
910

1011
phases = [
@@ -17,22 +18,23 @@ let
1718
buildInputs = with final; [
1819
nvim
1920
makeWrapper
20-
];
21+
] ++ extraPkgs;
2122

2223
buildPhase = ''
2324
mkdir -p $out
2425
mkdir -p $out/.config/nvim/site/pack/packer/start
2526
ln -s ${packer-nvim} $out/.config/nvim/site/pack/packer/start/packer.nvim
2627
ln -s ${plenary-nvim} $out/.config/nvim/site/pack/packer/start/plenary.nvim
2728
ln -s ${nvim-lspconfig} $out/.config/nvim/site/pack/packer/start/nvim-lspconfig
28-
ln -s ${telescope-nvim} $out/.config/nvim/site/pack/packer/start/telescope.nvim
29+
${optionalString withTelescope "ln -s ${telescope-nvim} $out/.config/nvim/site/pack/packer/start/telescope.nvim"}
2930
ln -s ${./..} $out/.config/nvim/site/pack/packer/start/${name}
3031
'';
3132

3233
checkPhase = ''
3334
export NVIM_DATA_MINIMAL=$(realpath $out/.config/nvim)
3435
export HOME=$(realpath .)
3536
cd ${./..}
37+
# TODO: split test directories by environment
3638
nvim --headless --noplugin -u ${../tests/minimal.lua} -c "PlenaryBustedDirectory tests {minimal_init = '${../tests/minimal.lua}'}"
3739
'';
3840
};
@@ -42,4 +44,8 @@ in
4244

4345
haskell-tools-test = mkPlenaryTest { name = "haskell-tools.nvim"; };
4446

47+
haskell-tools-test-no-telescope = mkPlenaryTest { name = "haskell-tools.nvim"; withTelescope = false; };
48+
49+
haskell-tools-test-no-telescope-with-hoogle = mkPlenaryTest { name = "haskell-tools.nvim"; withTelescope = false; extraPkgs = [ final.pkgs.haskellPackages.hoogle ]; };
50+
4551
}

tests/minimal.lua

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ packer.startup(function(use)
5151
requires = {
5252
'neovim/nvim-lspconfig',
5353
'nvim-lua/plenary.nvim',
54-
'nvim-telescope/telescope.nvim',
5554
},
5655
config = function()
5756
-- Paste setup here

tests/setup_spec.lua

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
local ht = require('haskell-tools')
2+
local stub = require('luassert.stub')
23
describe('Can call setup with default configs.', function()
4+
local notify_once = stub(vim, 'notify_once')
5+
local notify = stub(vim, 'notify')
36
ht.setup()
47
it('Public API is available after setup.', function()
58
assert(ht.config ~= nil)
@@ -9,4 +12,8 @@ describe('Can call setup with default configs.', function()
912
assert(ht.project ~= nil)
1013
assert(ht.tags ~= nil)
1114
end)
15+
it('No notifications at startup.', function()
16+
assert.stub(notify_once).was_not_called()
17+
assert.stub(notify).was_not_called()
18+
end)
1219
end)

0 commit comments

Comments
 (0)