Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruixi-rebirth committed Feb 16, 2025
0 parents commit 729c12c
Show file tree
Hide file tree
Showing 63 changed files with 4,042 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Set update schedule for GitHub Actions
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
# Check for updates to GitHub Actions every week
interval: "weekly"
21 changes: 21 additions & 0 deletions .github/workflows/flakehub-publish-tagged.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: "Publish tags to FlakeHub"
on:
workflow_dispatch:
schedule:
- cron: "0 0 * * 6"
jobs:
flakehub-publish:
runs-on: "ubuntu-latest"
permissions:
id-token: "write"
contents: "read"
steps:
- uses: "actions/checkout@v4"
with:
ref: "${{ (inputs.tag != null) && format('refs/tags/{0}', inputs.tag) || '' }}"
- uses: "DeterminateSystems/nix-installer-action@main"
- uses: "DeterminateSystems/flakehub-push@main"
with:
visibility: "public"
name: "Ruixi-rebirth/nvim-flake"
rolling: true
30 changes: 30 additions & 0 deletions .github/workflows/push_to_cachix.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: "push_to_cachix"
on:
workflow_dispatch:
schedule:
- cron: "0 0 * * 6"
env:
CACHIX_CACHE_NAME: ruixi-rebirth
jobs:
push_to_cachix:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install nix
uses: cachix/install-nix-action@v30
with:
nix_path: nixpkgs=channel:nixos-unstable
extra_nix_config: |
experimental-features = nix-command flakes
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- name: Flake check
run: nix flake check --all-systems
- name: Setup cachix
uses: cachix/cachix-action@v15
with:
name: ${{ env.CACHIX_CACHE_NAME }}
signingKey: "${{ secrets.CACHIX_SIGNING_KEY }}"
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
- name: Push build results to Cachix
run: nix build --json | jq -r '.[].outputs | to_entries[].value' | cachix push $CACHIX_CACHE_NAME
29 changes: 29 additions & 0 deletions .github/workflows/update.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: update-flake-lock
on:
workflow_dispatch:
schedule:
- cron: "0 0 * * 5"

jobs:
lockfile:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Nix
uses: cachix/install-nix-action@v30
with:
extra_nix_config: |
access-tokens = github.com=${{ secrets.GITHUB_TOKEN }}
- name: Update flake.lock
uses: DeterminateSystems/update-flake-lock@main
with:
pr-title: "flake: update the lock" # Title of PR to be created
pr-labels: | # Labels to be set on the PR
dependencies
automated
token: ${{ secrets.GITHUB_TOKEN }}
- uses: peter-evans/enable-pull-request-automerge@v3
with:
pull-request-number: ${{ github.event.pull_request.number }}
merge-method: squash
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.DS_Store
/result
/.pre-commit-config.yaml
22 changes: 22 additions & 0 deletions .nvim.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
local nvim_lsp = require("lspconfig")
nvim_lsp.nixd.setup({
cmd = { "nixd" },
settings = {
nixd = {
nixpkgs = {
expr = 'import (builtins.getFlake ("git+file://" + toString ./.)).inputs.nixpkgs { }',
},
formatting = {
command = { "nix fmt" },
},
options = {
flake_parts = {
expr = 'let flake = builtins.getFlake ("git+file://" + toString ./.); in flake.debug.options // flake.currentSystem.options',
},
nixvim = {
expr = '(builtins.getFlake ("git+file://" + toString ./.)).packages.${builtins.currentSystem}.default.options',
},
},
},
},
})
51 changes: 51 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
## Ruixi-rebirth'nvim

My Neovim configuration uses [nixvim](https://github.com/nix-community/nixvim), with lazy loading handled by the plugin [lazy.nvim](https://github.com/folke/lazy.nvim).

[![Cachix Cache](https://img.shields.io/badge/cachix-ruixi_rebirth-blue.svg)](https://ruixi-rebirth.cachix.org) ![Build and populate cache](https://github.com/Ruixi-rebirth/nvim-flake/workflows/push_to_cachix/badge.svg)

### Flake Usage

- Temporarily use it in the terminal:

```console
nix run "github:Ruixi-rebirth/nvim-flake#lazynvim"
```

- Use as a package:

```nix
{
inputs = {
nvim-flake.url = "github:Ruixi-rebirth/nvim-flake";
};
outputs = inputs: {
nixosConfigurations."my-laptop-hostname" =
let system = "x86_64-linux";
in nixpkgs.lib.nixosSystem {
inherit system;
modules = [({pkgs, config, ... }: {
config = {
nix.settings = {
# add binary caches
trusted-public-keys = [
"ruixi-rebirth.cachix.org-1:ypGqoIU9MfXwv/fE02ZGg8mutJqmcYHgLTR1DMoPGac="
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
];
substituters = [
"https://ruixi-rebirth.cachix.org"
"https://cache.nixos.org"
];
};
# pull specific packages (built against inputs.nixpkgs, usually `nixos-unstable`)
environment.systemPackages = [
inputs.nvim-flake.packages.${system}.lazynvim
];
};
})];
};
};
}
```
57 changes: 57 additions & 0 deletions config/base/autocmd.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{ helpers, ... }:
{
autoCmd = [
{
# Jump to the last edit position
event = [ "BufReadPost" ];
pattern = [ "*" ];
command = ''
if line("'\"") > 1 && line("'\"") <= line("$") |
exe "normal! g`\""
endif
'';
}
{
# Automatically remove trailing whitespace before saving the file
event = [ "BufWritePre" ];
pattern = [ "*" ];
command = "%s/\\s\\+$//e";
}
{
event = [ "FileType" ];
pattern = [ "*" ];
callback = helpers.mkRaw ''
function()
local util = require("lspconfig.util")
local root_dir = util.find_git_ancestor(vim.fn.expand("%:p"))
if root_dir then
pcall(function() vim.cmd('cd ' .. root_dir) end)
else
local file_dir = vim.fn.expand('%:p:h')
pcall(function() vim.cmd('cd ' .. file_dir) end)
end
end
'';
}
{
# Save folding state
event = [ "BufWinLeave" ];
pattern = [ "*" ];
callback = helpers.mkRaw ''
function()
pcall(function() vim.cmd("mkview") end)
end
'';
}
{
# Restore folding state
event = [ "BufRead" ];
pattern = [ "*" ];
callback = helpers.mkRaw ''
function()
pcall(function() vim.cmd("loadview") end)
end
'';
}
];
}
8 changes: 8 additions & 0 deletions config/base/clipboard.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
clipboard = {
register = "unnamedplus";
providers = {
wl-copy.enable = true;
};
};
}
9 changes: 9 additions & 0 deletions config/base/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
imports = [
./options.nix
./clipboard.nix
./keymaps.nix
./autocmd.nix
./extraConfigLua.nix
];
}
42 changes: 42 additions & 0 deletions config/base/extraConfigLua.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
extraConfigLua = ''
-- Add '-' to the list of characters considered part of a keyword
vim.cmd([[set iskeyword+=-]])
-- Allow moving between lines using arrow keys and h/l when at the start/end of a line
vim.cmd("set whichwrap+=<,>,[,],h,l")
local util = require("lspconfig.util")
local function load_project_nvim_config()
local root_dir = function(fname)
return util.find_git_ancestor(fname)
end
local current_file = vim.fn.expand("%:p")
local project_root = root_dir(current_file)
if project_root then
local nvim_config_path = project_root .. "/.nvim.lua"
if vim.loop.fs_stat(nvim_config_path) then
vim.cmd("source " .. nvim_config_path)
end
end
end
load_project_nvim_config()
local load_clipboard_config = function()
if vim.fn.has("wsl") == 1 then
vim.g.clipboard = {
name = "WslClipboard",
copy = {
["+"] = "cb cp",
["*"] = "cb cp",
},
paste = {
["+"] = "cb p",
["*"] = "cb p",
},
cache_enabled = 0,
}
end
end
load_clipboard_config()
'';
}
Loading

0 comments on commit 729c12c

Please sign in to comment.