mirror of
https://github.com/NotAShelf/neovim-flake.git
synced 2025-01-09 16:39:51 +01:00
Compare commits
5 commits
8fdaa2bff2
...
74e58229f0
Author | SHA1 | Date | |
---|---|---|---|
74e58229f0 | |||
5ce1d90e95 | |||
|
99a4eafa34 | ||
|
e715463257 | ||
7324474ef8 |
9 changed files with 314 additions and 4 deletions
172
.github/workflows/docs-preview.yml
vendored
Normal file
172
.github/workflows/docs-preview.yml
vendored
Normal file
|
@ -0,0 +1,172 @@
|
|||
name: Build and Preview Manual
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
pull_request:
|
||||
types: [opened, synchronize, reopened, closed]
|
||||
paths:
|
||||
- ".github/workflows/docs-preview.yml"
|
||||
- "modules/**"
|
||||
- "docs/**"
|
||||
|
||||
# Defining permissions here passes it to all workflows.
|
||||
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/controlling-permissions-for-github_token
|
||||
permissions:
|
||||
contents: write
|
||||
pull-requests: write
|
||||
issues: write
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build-preview:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Install Nix
|
||||
uses: DeterminateSystems/nix-installer-action@main
|
||||
- uses: DeterminateSystems/magic-nix-cache-action@main
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set default git branch (to reduce log spam)
|
||||
run: git config --global init.defaultBranch main
|
||||
|
||||
- name: Build documentation packages
|
||||
run: nix build .#docs-html --print-build-logs
|
||||
|
||||
- name: Deploy to GitHub Pages preview
|
||||
run: |
|
||||
PR_NUMBER=${{ github.event.pull_request.number }}
|
||||
BRANCH_NAME="gh-pages"
|
||||
PREVIEW_DIR="docs-preview-${PR_NUMBER}"
|
||||
|
||||
# Clone the gh-pages branch and move to the preview subdirectory
|
||||
git clone --single-branch --branch $BRANCH_NAME https://github.com/${{ github.repository }} gh-pages
|
||||
cd gh-pages
|
||||
|
||||
mkdir -p $PREVIEW_DIR
|
||||
|
||||
# Copy the build files to the preview subdirectory
|
||||
cp -rvf ../result/share/doc/nvf/* ./$PREVIEW_DIR
|
||||
|
||||
# Configure git to use the GitHub Actions token for authentication
|
||||
git config --global user.name "GitHub Actions"
|
||||
git config --global user.email "actions@github.com"
|
||||
|
||||
# Set the GitHub token for authentication
|
||||
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
|
||||
|
||||
# Add and commit the changes
|
||||
git add --all
|
||||
git commit -m "Deploy PR #${PR_NUMBER} preview" || echo "No changes to commit"
|
||||
git push --force origin $BRANCH_NAME
|
||||
|
||||
comment-url:
|
||||
needs: build-preview
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Prepare Environment
|
||||
id: prelude
|
||||
run: |
|
||||
PR_NUMBER=${{ github.event.pull_request.number }}
|
||||
URL="https://${{ github.repository_owner }}.github.io/nvf/docs-preview-${PR_NUMBER}/"
|
||||
|
||||
# Propagate non-interpolatable environment vars
|
||||
echo "URL=$URL" >> "$GITHUB_OUTPUT"
|
||||
echo "REV=$GITHUB_SHA" >> "$GITHUB_OUTPUT"
|
||||
echo "ACTOR=$GITHUB_ACTOR" >> "$GITHUB_OUTPUT"
|
||||
echo "REF=$GITHUB_HEAD_REF" >> "$GITHUB_OUTPUT"
|
||||
echo "RUNS=$GITHUB_RUN_NUMBER" >> "$GITHUB_OUTPUT"
|
||||
|
||||
echo "Live Preview URL: $URL"
|
||||
echo "Rev: $GITHUB_SHA"
|
||||
echo "Actor: $GITHUB_ACTOR"
|
||||
echo "Ref: "$GITHUB_HEAD_REF"
|
||||
echo "Reruns: "$GITHUB_RUN_NUMBER"
|
||||
|
||||
echo "### :rocket: Live Preview Deployed " >> "$GITHUB_STEP_SUMMARY"
|
||||
echo "Preview can be found at ${URL}" >> "$GITHUB_STEP_SUMMARY"
|
||||
|
||||
- name: Find Comment
|
||||
uses: peter-evans/find-comment@v3
|
||||
id: fc
|
||||
with:
|
||||
comment-author: "github-actions[bot]"
|
||||
issue-number: ${{ github.event.pull_request.number }}
|
||||
body-includes: "Live preview deployed"
|
||||
|
||||
- name: Post live preview comment
|
||||
uses: peter-evans/create-or-update-comment@v4
|
||||
env:
|
||||
COMMENT_ID: ${{ steps.fc.outputs.comment-id }}
|
||||
URL: ${{ steps.prelude.outputs.URL }}
|
||||
GITHUB_SHA: ${{ steps.prelude.outputs.REV }}
|
||||
ACTOR: ${{ steps.prelude.outputs.ACTOR }}
|
||||
REF: ${{ steps.prelude.outputs.REF }}
|
||||
RUNS: ${{ steps.prelude.outputs.RUNS }}
|
||||
with:
|
||||
comment-id: ${{ env.COMMENT_ID }}
|
||||
issue-number: ${{ github.event.pull_request.number }} # issue number also applies to pull requests
|
||||
edit-mode: replace # replace previous body
|
||||
body: |
|
||||
### :rocket: Live preview deployed from ${{ env.GITHUB_SHA }}
|
||||
|
||||
View it [here](${{ env.URL }}):
|
||||
|
||||
<details>
|
||||
<summary><strong>Debug Information</strong></summary>
|
||||
<p>Triggered by: ${{ env.ACTOR }}</p>
|
||||
<p><code>HEAD</code> at: ${{ env.REF }}</p>
|
||||
<p>Reruns: ${{ env.RUNS }}</p>
|
||||
</details>
|
||||
|
||||
cleanup:
|
||||
if: ${{ github.event.pull_request.merged == true || github.event.pull_request.state == 'closed' }}
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Delete preview for closed/merged PR
|
||||
run: |
|
||||
PR_NUMBER=${{ github.event.pull_request.number }}
|
||||
BRANCH_NAME="gh-pages"
|
||||
PREVIEW_DIR="docs-preview-${PR_NUMBER}"
|
||||
|
||||
# Clone the gh-pages branch
|
||||
git clone --single-branch --branch $BRANCH_NAME https://github.com/${{ github.repository }} gh-pages
|
||||
cd gh-pages
|
||||
|
||||
# Check if the preview directory exists, and delete it if it does
|
||||
if [ -d "$PREVIEW_DIR" ]; then
|
||||
echo "Deleting preview directory $PREVIEW_DIR"
|
||||
rm -rf $PREVIEW_DIR
|
||||
else
|
||||
echo "Preview directory $PREVIEW_DIR does not exist. Skipping deletion."
|
||||
fi
|
||||
|
||||
# Configure git to use the GitHub Actions token for authentication
|
||||
git config --global user.name "GitHub Actions"
|
||||
git config --global user.email "actions@github.com"
|
||||
|
||||
# Set the GitHub token for authentication
|
||||
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
|
||||
|
||||
# Add and commit the changes (only if there's something to delete)
|
||||
git add .
|
||||
git diff --quiet || git commit -m "Remove preview for PR #${PR_NUMBER}"
|
||||
git push origin $BRANCH_NAME
|
||||
|
||||
cleanup-comment:
|
||||
needs: cleanup
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Post cleanup verification
|
||||
uses: peter-evans/create-or-update-comment@v4
|
||||
with:
|
||||
issue-number: ${{ github.event.pull_request.number }}
|
||||
body: |
|
||||
✅ Preview has been deleted successfully!
|
|
@ -79,6 +79,7 @@ isMaximal: {
|
|||
dart.enable = false;
|
||||
ocaml.enable = false;
|
||||
elixir.enable = false;
|
||||
haskell.enable = false;
|
||||
|
||||
tailwind.enable = false;
|
||||
svelte.enable = false;
|
||||
|
|
|
@ -8,3 +8,9 @@
|
|||
`languages.typst.extensions.typst-preview-nvim`.
|
||||
|
||||
- Add a search widget to the options page in the nvf manual.
|
||||
|
||||
[amadaluzia](https://github.com/amadaluzia):
|
||||
|
||||
[haskell-tools.nvim]: https://github.com/MrcJkb/haskell-tools.nvim
|
||||
|
||||
- Add Haskell support under `vim.languages.haskell` using [haskell-tools.nvim]
|
||||
|
|
17
flake.lock
17
flake.lock
|
@ -684,6 +684,22 @@
|
|||
"type": "github"
|
||||
}
|
||||
},
|
||||
"plugin-haskell-tools-nvim": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1734222260,
|
||||
"narHash": "sha256-gZVN9ADPO5wFOaf19FydCneb7aKTT9K1vcLoBURPEjk=",
|
||||
"owner": "mrcjkb",
|
||||
"repo": "haskell-tools.nvim",
|
||||
"rev": "943b77b68a79d3991523ba4d373063c9355c6f55",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "mrcjkb",
|
||||
"repo": "haskell-tools.nvim",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"plugin-highlight-undo": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
|
@ -2091,6 +2107,7 @@
|
|||
"plugin-gitsigns-nvim": "plugin-gitsigns-nvim",
|
||||
"plugin-glow-nvim": "plugin-glow-nvim",
|
||||
"plugin-gruvbox": "plugin-gruvbox",
|
||||
"plugin-haskell-tools-nvim": "plugin-haskell-tools-nvim",
|
||||
"plugin-highlight-undo": "plugin-highlight-undo",
|
||||
"plugin-hop-nvim": "plugin-hop-nvim",
|
||||
"plugin-icon-picker-nvim": "plugin-icon-picker-nvim",
|
||||
|
|
|
@ -720,5 +720,10 @@
|
|||
url = "github:otavioschwanck/new-file-template.nvim";
|
||||
flake = false;
|
||||
};
|
||||
|
||||
plugin-haskell-tools-nvim = {
|
||||
url = "github:mrcjkb/haskell-tools.nvim";
|
||||
flake = false;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ in {
|
|||
./hcl.nix
|
||||
./kotlin.nix
|
||||
./html.nix
|
||||
./haskell.nix
|
||||
./java.nix
|
||||
./lua.nix
|
||||
./markdown.nix
|
||||
|
|
104
modules/plugins/languages/haskell.nix
Normal file
104
modules/plugins/languages/haskell.nix
Normal file
|
@ -0,0 +1,104 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
inherit (builtins) isList;
|
||||
inherit (lib.types) either package listOf str;
|
||||
inherit (lib.options) mkEnableOption mkOption;
|
||||
inherit (lib.strings) optionalString;
|
||||
inherit (lib.modules) mkIf mkMerge;
|
||||
inherit (lib.nvim.types) mkGrammarOption;
|
||||
inherit (lib.nvim.dag) entryAfter;
|
||||
inherit (lib.nvim.lua) expToLua;
|
||||
inherit (pkgs) haskellPackages;
|
||||
|
||||
cfg = config.vim.languages.haskell;
|
||||
in {
|
||||
options.vim.languages.haskell = {
|
||||
enable = mkEnableOption "Haskell support";
|
||||
|
||||
treesitter = {
|
||||
enable = mkEnableOption "Treesitter support for Haskell" // {default = config.vim.languages.enableTreesitter;};
|
||||
package = mkGrammarOption pkgs "haskell";
|
||||
};
|
||||
|
||||
lsp = {
|
||||
enable = mkEnableOption "LSP support for Haskell" // {default = config.vim.languages.enableLSP;};
|
||||
package = mkOption {
|
||||
description = "Haskell LSP package or command to run the Haskell LSP";
|
||||
example = ''[ (lib.getExe pkgs.haskellPackages.haskell-language-server) "--debug" ]'';
|
||||
default = haskellPackages.haskell-language-server;
|
||||
type = either package (listOf str);
|
||||
};
|
||||
};
|
||||
|
||||
dap = {
|
||||
enable = mkEnableOption "DAP support for Haskell" // {default = config.vim.languages.enableDAP;};
|
||||
package = mkOption {
|
||||
description = "Haskell DAP package or command to run the Haskell DAP";
|
||||
default = haskellPackages.haskell-debug-adapter;
|
||||
type = either package (listOf str);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable (mkMerge [
|
||||
(mkIf cfg.treesitter.enable {
|
||||
vim.treesitter = {
|
||||
enable = true;
|
||||
grammars = [cfg.treesitter.package];
|
||||
};
|
||||
})
|
||||
|
||||
(mkIf (cfg.dap.enable || cfg.lsp.enable) {
|
||||
vim = {
|
||||
startPlugins = ["haskell-tools-nvim"];
|
||||
luaConfigRC.haskell-tools-nvim =
|
||||
entryAfter
|
||||
["lsp-setup"]
|
||||
''
|
||||
vim.g.haskell_tools = {
|
||||
${optionalString cfg.lsp.enable ''
|
||||
-- LSP
|
||||
tools = {
|
||||
hover = {
|
||||
enable = true,
|
||||
},
|
||||
},
|
||||
hls = {
|
||||
cmd = ${
|
||||
if isList cfg.lsp.package
|
||||
then expToLua cfg.lsp.package
|
||||
else ''{"${cfg.lsp.package}/bin/haskell-language-server-wrapper"}''
|
||||
},
|
||||
on_attach = function(client, bufnr, ht)
|
||||
default_on_attach(client, bufnr, ht)
|
||||
local opts = { noremap = true, silent = true, buffer = bufnr }
|
||||
vim.keymap.set('n', '<localleader>cl', vim.lsp.codelens.run, opts)
|
||||
vim.keymap.set('n', '<localleader>hs', ht.hoogle.hoogle_signature, opts)
|
||||
vim.keymap.set('n', '<localleader>ea', ht.lsp.buf_eval_all, opts)
|
||||
vim.keymap.set('n', '<localleader>rr', ht.repl.toggle, opts)
|
||||
vim.keymap.set('n', '<localleader>rf', function()
|
||||
ht.repl.toggle(vim.api.nvim_buf_get_name(0))
|
||||
end, opts)
|
||||
vim.keymap.set('n', '<localleader>rq', ht.repl.quit, opts)
|
||||
end,
|
||||
},
|
||||
''}
|
||||
${optionalString cfg.dap.enable ''
|
||||
dap = {
|
||||
cmd = ${
|
||||
if isList cfg.dap.package
|
||||
then expToLua cfg.dap.package
|
||||
else ''${cfg.dap.package}/bin/haskell-debug-adapter''
|
||||
},
|
||||
},
|
||||
''}
|
||||
}
|
||||
'';
|
||||
};
|
||||
})
|
||||
]);
|
||||
}
|
|
@ -13,7 +13,7 @@
|
|||
inherit (lib.types) bool package str listOf either enum;
|
||||
inherit (lib.nvim.types) mkGrammarOption;
|
||||
inherit (lib.nvim.lua) expToLua;
|
||||
inherit (lib.nvim.dag) entryAnywhere;
|
||||
inherit (lib.nvim.dag) entryAfter entryAnywhere;
|
||||
|
||||
cfg = config.vim.languages.rust;
|
||||
|
||||
|
@ -127,7 +127,7 @@ in {
|
|||
vim = {
|
||||
startPlugins = ["rustaceanvim"];
|
||||
|
||||
luaConfigRC.rustaceanvim = entryAnywhere ''
|
||||
pluginRC.rustaceanvim = entryAfter ["lsp-setup"] ''
|
||||
vim.g.rustaceanvim = {
|
||||
${optionalString cfg.lsp.enable ''
|
||||
-- LSP
|
||||
|
|
|
@ -23,8 +23,11 @@
|
|||
package = pkgs.typescript-language-server;
|
||||
lspConfig = ''
|
||||
lspconfig.ts_ls.setup {
|
||||
capabilities = capabilities;
|
||||
on_attach = attach_keymaps,
|
||||
capabilities = capabilities,
|
||||
on_attach = function(client, bufnr)
|
||||
attach_keymaps(client, bufnr);
|
||||
client.server_capabilities.documentFormattingProvider = false;
|
||||
end,
|
||||
cmd = ${
|
||||
if isList cfg.lsp.package
|
||||
then expToLua cfg.lsp.package
|
||||
|
@ -79,6 +82,7 @@
|
|||
ls_sources,
|
||||
null_ls.builtins.formatting.prettier.with({
|
||||
command = "${cfg.format.package}/bin/prettier",
|
||||
filetypes = { "typescript" },
|
||||
})
|
||||
)
|
||||
'';
|
||||
|
|
Loading…
Reference in a new issue