-
-
Save shinzui/44166a2e0f2a6400a6c790e2a0693f76 to your computer and use it in GitHub Desktop.
neovim + haskell-language-server setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# nix-env --install --file ./default.nix | |
let | |
nixpkgs = builtins.fetchTarball { | |
url = "https://github.com/NixOS/nixpkgs/archive/c473cc8714710179df205b153f4e9fa007107ff9.tar.gz"; | |
sha256 = "0q7rnlp1djxc9ikj89c0ifzihl4wfvri3q1bvi75d2wrz844b4lq"; | |
}; | |
config = { | |
allowUnfree = true; | |
}; | |
ghcVersion = "8107"; | |
overlay = pkgsNew: pkgsOld: { | |
haskell-language-server = pkgsOld.haskell-language-server.override { | |
supportedGhcVersions = [ ghcVersion ]; | |
}; | |
haskell = pkgsOld.haskell // { | |
packages = pkgsOld.haskell.packages // { | |
"ghc${ghcVersion}" = pkgsOld.haskell.packages."ghc${ghcVersion}".override (old: { | |
overrides = | |
pkgsNew.lib.composeExtensions (old.overrides or (_: _: { })) | |
(haskellPackagesNew: haskellPackagesOld: { | |
ormolu = | |
if pkgsNew.system == "aarch64-darwin" | |
then | |
pkgsNew.haskell.lib.overrideCabal | |
haskellPackagesOld.ormolu | |
(_: { enableSeparateBinOutput = false; }) | |
else | |
haskellPackagesOld.ormolu; | |
}); | |
}); | |
}; | |
}; | |
}; | |
pkgs = import nixpkgs { inherit config; overlays = [ overlay ];}; | |
in | |
{ inherit (pkgs) | |
cabal-install | |
cabal2nix | |
git | |
haskell-language-server | |
neovim | |
stylish-haskell | |
; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
call plug#begin() | |
Plug 'neovim/nvim-lspconfig' | |
Plug 'kyazdani42/nvim-web-devicons' | |
Plug 'folke/trouble.nvim' | |
call plug#end() | |
lua << EOF | |
local lspconfig = require('lspconfig') | |
local on_attach = function(client) | |
vim.api.nvim_buf_set_keymap(0, 'n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', {noremap = true}) | |
vim.api.nvim_buf_set_keymap(0, 'n', '<C-n>', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', {noremap = true}) | |
vim.api.nvim_buf_set_keymap(0, 'n', '<C-p>', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', {noremap = true}) | |
vim.api.nvim_buf_set_option(0, 'omnifunc', 'v:lua.vim.lsp.omnifunc') | |
vim.api.nvim_buf_set_option(0, 'tagfunc', 'v:lua.vim.lsp.tagfunc') | |
vim.opt.signcolumn = 'yes' | |
end | |
lspconfig.hls.setup { | |
settings = { | |
haskell = { | |
formattingProvider = 'stylish-haskell', | |
}, | |
}, | |
on_attach = on_attach, | |
} | |
local trouble = require("trouble") | |
trouble.setup { | |
} | |
vim.api.nvim_set_keymap("n", "<leader>e", "<cmd>Trouble workspace_diagnostics<cr>", {silent = true, noremap = true}) | |
vim.api.nvim_set_keymap("n", "<leader>r", "<cmd>Trouble lsp_references<cr>", {silent = true, noremap = true}) | |
EOF | |
:set nohlsearch | |
:set expandtab |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment