Skip to content

Commit

Permalink
feat(pack): add haskell language pack (#165)
Browse files Browse the repository at this point in the history
* added haskell tools

* add on_attach and extra print

* add empty input in autocmd callback

* added ddebug messages and require telescope

* add filetype loading

* remove debug messages

* add check for server_capabilities

* add astronvim.lsp.on_attach to attach lsp keymap

* cleanup and finalize readme
  • Loading branch information
sjcobb2022 committed Apr 26, 2023
1 parent b983cd0 commit bceb4c4
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
18 changes: 18 additions & 0 deletions lua/astrocommunity/pack/haskell/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Haskell Language Pack

Requires:

- plenary.nvim

Optionally:

- A local hoogle installation
- [fast-tags](https://github.com/elaforge/fast-tags) (reccomended by haskell-tools)

This plugin pack does the following:

- Adds `haskell` treesitter parsers
- Adds `haskell-language-server` language server
- Adds [haskell-tools.nvim](https://github.com/mrcjkb/haskell-tools.nvim)
- Adds `yaml` language pack
- Adds `json` language pack
56 changes: 56 additions & 0 deletions lua/astrocommunity/pack/haskell/haskell.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
local utils = require "astrocommunity.utils"
return {
{ import = "astrocommunity.pack.yaml" }, -- stack.yaml
{ import = "astrocommunity.pack.json" }, -- hls.json
{
"nvim-treesitter/nvim-treesitter",
opts = function(_, opts)
-- Ensure that opts.ensure_installed exists and is a table or string "all".
if not opts.ensure_installed then
opts.ensure_installed = {}
elseif opts.ensure_installed == "all" then
return
end
-- ensure haskell treesitter installed
utils.list_insert_unique(opts.ensure_installed, "haskell")
end,
},
{
"mrcjkb/haskell-tools.nvim",
ft = { "haskell" },
branch = "1.x.x", -- reccomended by haskell-tools
init = function() utils.list_insert_unique(astronvim.lsp.skip_setup, "hls") end,
opts = {
hls = {
on_attach = function(client, bufnr) require("astronvim.utils.lsp").on_attach(client, bufnr) end,
},
},
config = function(_, opts)
vim.api.nvim_create_autocmd("Filetype", {
pattern = "haskell", -- autocmd to start haskell-tools
callback = function(_) require("haskell-tools").start_or_attach(opts) end,
})
end,
dependencies = {
"nvim-lua/plenary.nvim",
"nvim-telescope/telescope.nvim", -- optional
-- TODO: Need haskell to be pulled into mason-nvim-dap (haskell hopefully coming soon)
-- {
-- "jay-babu/mason-nvim-dap.nvim",
-- opts = function(_, opts)
-- -- Ensure that opts.ensure_installed exists and is a table.
-- if not opts.ensure_installed then opts.ensure_installed = {} end
-- utils.list_insert_unique(opts.ensure_installed, "haskell-dap")
-- end,
-- },
},
},
{
"williamboman/mason-lspconfig.nvim",
opts = function(_, opts)
-- Ensure that opts.ensure_installed exists and is a table.
if not opts.ensure_installed then opts.ensure_installed = {} end
utils.list_insert_unique(opts.ensure_installed, "hls")
end,
},
}

0 comments on commit bceb4c4

Please sign in to comment.