From 9787a86450723c2084d1b92648c0a6a4f64f3f59 Mon Sep 17 00:00:00 2001
From: Marc Jakobi
🦥
- + [![Neovim][neovim-shield]][neovim-url] [![Lua][lua-shield]][lua-url] [![Haskell][haskell-shield]][haskell-url] diff --git a/flake.nix b/flake.nix index 489f5b5..69f116d 100644 --- a/flake.nix +++ b/flake.nix @@ -87,20 +87,20 @@ type-check-nightly = pre-commit-hooks.lib.${system}.run { src = self; hooks = { - lua-ls.enable = true; - }; - settings = { - lua-ls.config = luarc-nightly; + lua-ls = { + enable = true; + settings.configuration = luarc-nightly; + }; }; }; type-check-stable = pre-commit-hooks.lib.${system}.run { src = self; hooks = { - lua-ls.enable = true; - }; - settings = { - lua-ls.config = luarc-stable; + lua-ls = { + enable = true; + settings.configuration = luarc-stable; + }; }; }; diff --git a/lua/haskell-tools/compat.lua b/lua/haskell-tools/compat.lua index 93f2206..4f3a857 100644 --- a/lua/haskell-tools/compat.lua +++ b/lua/haskell-tools/compat.lua @@ -41,4 +41,9 @@ compat.system = vim.system return systemObj end +---@type fun(tbl:table):table +compat.tbl_flatten = vim.iter and function(tbl) + return vim.iter(tbl):flatten():totable() +end or vim.tbl_flatten + return compat diff --git a/lua/haskell-tools/hoogle/local.lua b/lua/haskell-tools/hoogle/local.lua index 9ebc949..0ce363a 100644 --- a/lua/haskell-tools/hoogle/local.lua +++ b/lua/haskell-tools/hoogle/local.lua @@ -9,6 +9,7 @@ local log = require('haskell-tools.log.internal') local deps = require('haskell-tools.deps') +local compat = require('haskell-tools.compat') ---@class LocalHoogleHandler local HoogleLocal = {} @@ -36,7 +37,7 @@ end ---@return string[] hoogle_args local function mk_hoogle_args(search_term, opts) local count = opts.count or 50 - local args = vim.tbl_flatten { '--json', '--count=' .. count, search_term } + local args = compat.tbl_flatten { '--json', '--count=' .. count, search_term } log.debug { 'Hoogle local args', args } return args end @@ -45,7 +46,6 @@ local pickers = deps.require_telescope('telescope.pickers') local finders = deps.require_telescope('telescope.finders') local previewers = deps.require_telescope('telescope.previewers') local HoogleHelpers = require('haskell-tools.hoogle.helpers') -local compat = require('haskell-tools.compat') ---@param search_term string The Hoogle search term ---@param opts LocalHoogleOpts|nil diff --git a/lua/haskell-tools/project/helpers.lua b/lua/haskell-tools/project/helpers.lua index 35ee6a2..e2f75b5 100644 --- a/lua/haskell-tools/project/helpers.lua +++ b/lua/haskell-tools/project/helpers.lua @@ -32,7 +32,7 @@ end ---@param ... string Search patterns (can be globs) ---@return string|nil The first file that matches the globs local function find_file(path, ...) - for _, search_term in ipairs(vim.tbl_flatten { ... }) do + for _, search_term in ipairs(compat.tbl_flatten { ... }) do local results = vim.fn.glob(compat.joinpath(path, search_term), true, true) if #results > 0 then return results[1] @@ -87,7 +87,7 @@ end ---@param ... string Globs to match in the root directory ---@return fun(path:string):(string|nil) local function root_pattern(...) - local args = vim.tbl_flatten { ... } + local args = compat.tbl_flatten { ... } local function matcher(path) return find_file(path, unpack(args)) end diff --git a/lua/haskell-tools/repl/init.lua b/lua/haskell-tools/repl/init.lua index c96362d..c166fe9 100644 --- a/lua/haskell-tools/repl/init.lua +++ b/lua/haskell-tools/repl/init.lua @@ -15,6 +15,7 @@ local log = require('haskell-tools.log.internal') local Types = require('haskell-tools.types.internal') +local compat = require('haskell-tools.compat') ---Extend a repl command for `file`. ---If `file` is `nil`, create a repl the nearest package. @@ -98,7 +99,7 @@ local function mk_repl_cmd(file) return mk_stack_repl_cmd(file) end if vim.fn.executable('ghci') == 1 then - local cmd = vim.tbl_flatten { 'ghci', file and { file } or {} } + local cmd = compat.tbl_flatten { 'ghci', file and { file } or {} } log.debug { 'mk_repl_cmd', cmd } return cmd end