diff --git a/.github/actions/setup-nix/action.yml b/.github/actions/setup-nix/action.yml new file mode 100644 index 0000000..dfd6c22 --- /dev/null +++ b/.github/actions/setup-nix/action.yml @@ -0,0 +1,67 @@ +name: setup-nix + +inputs: + system: + type: string + required: true + sandbox: + type: string + default: "true" + +runs: + using: composite + steps: + - name: reclaim space (linux) + if: runner.os == 'Linux' + uses: wimpysworld/nothing-but-nix@main + with: + hatchet-protocol: rampage + + - name: reclaim space (darwin) + if: runner.os == 'macOS' + shell: bash + run: | + echo "::group::disk space (before)" + sudo df -h + echo "::endgroup::" + + echo "::group::disable mds" + sudo mdutil -i off -a || echo "mdutil failed" + sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.metadata.mds.plist \ + || echo "launchctl unload failed" + echo "::endgroup::" + + echo "Background space expansion started. /nix will grow as space becomes available." + sudo rm -rf \ + /Applications/Xcode_* \ + /Library/Developer/CoreSimulator \ + /Library/Frameworks \ + /Users/runner/.dotnet \ + /Users/runner/.rustup \ + /Users/runner/Library/Android \ + /Users/runner/Library/Caches \ + /Users/runner/Library/Developer/CoreSimulator \ + /Users/runner/hostedtoolcache & + + - name: install nix + uses: cachix/install-nix-action@v31 + with: + # Putting build-dir in /nix is a workaround for https://github.com/wimpysworld/nothing-but-nix/issues/18 + extra_nix_config: | + build-dir = /nix/build + sandbox = ${{ inputs.sandbox }} + system = ${{ inputs.system }} + + - name: create build-dir + shell: bash + run: sudo mkdir -p /nix/build + + - name: post setup-nix + if: runner.os == 'macOS' + uses: srz-zumix/post-run-action@v2 + with: + shell: bash -e {0} + post-run: | + echo "::group::disk space (after)" + sudo df -h + echo "::endgroup::" \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..c8e831c --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,135 @@ +name: Nix + +on: + push: + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + build: + strategy: + fail-fast: false + matrix: + system: + - x86_64-linux + - aarch64-linux + - x86_64-darwin + runs-on: ${{ matrix.system == 'x86_64-linux' && 'ubuntu-24.04' + || matrix.system == 'aarch64-linux' && 'ubuntu-24.04-arm' + || matrix.system == 'x86_64-darwin' && 'macos-latest' }} + steps: + - uses: actions/checkout@v4 + + - name: setup nix + uses: ./.github/actions/setup-nix + with: + system: ${{ matrix.system }} + + - name: Login to tailscale + uses: tailscale/github-action@v3.2.3 + with: + oauth-client-id: ${{ secrets.TS_OAUTH_CLIENT_ID }} + oauth-secret: ${{ secrets.TS_OAUTH_SECRET }} + hostname: ${{ matrix.system == 'x86_64-linux' && 'github-actions-x86-64-linux' + || matrix.system == 'aarch64-linux' && 'github-actions-aarch64-linux' + || matrix.system == 'x86_64-darwin' && 'github-actions-x86-64-darwin' }} + tags: tag:ci + + # - name: Install and start Tailscale + # run: | + # # Start tailscaled daemon in background using nix shell + # nix profile add nixpkgs#tailscale + # sudo tailscaled --state=mem: & + + # # Wait for daemon to be ready + # sleep 10 + + # # Connect using OAuth + # HOSTNAME="${{ matrix.system == 'x86_64-linux' && 'github-actions-x86-64-linux' + # || matrix.system == 'aarch64-linux' && 'github-actions-aarch64-linux' + # || matrix.system == 'x86_64-darwin' && 'github-actions-x86-64-darwin' }}" + + # tailscale up \ + # --authkey="${{ secrets.TS_OAUTH_SECRET }}?preauthorized=true&ephemeral=true" \ + # --hostname="$HOSTNAME" \ + # --advertise-tags="tag:ci" \ + # --accept-routes + + - name: Tailscale status + run: tailscale status || true + + - name: Check if Attic endpoint is reachable + id: check_attic + run: | + if curl --connect-timeout 20 --silent --head http://wallfacer.curl-boga.ts.net:7080 | grep "200 OK"; then + echo "Attic endpoint is reachable" + echo "reachable=true" >> $GITHUB_OUTPUT + else + echo "Attic endpoint is not reachable" + echo "reachable=false" >> $GITHUB_OUTPUT + fi + + - name: Curl the cache + run: | + curl --connect-timeout 20 --silent http://wallfacer.curl-boga.ts.net:7080/main/nix-cache-info || echo "Cache endpoint not reachable" + + - name: Setup Attic cache + if: steps.check_attic.outputs.reachable == 'true' + uses: ryanccn/attic-action@v0.3.1 + with: + endpoint: http://wallfacer.curl-boga.ts.net:7080 + cache: main + token: ${{ secrets.ATTIC_TOKEN }} + + - name: Check the flake + run: nix flake check --accept-flake-config + + + - name: Build the Neovim Configuration + run: nix build --accept-flake-config . -j3 + timeout-minutes: 300 + continue-on-error: true + + - name: Print out the size of /nix/store + run: du -sh /nix/store + + - name: Get the init.lua path + if: matrix.system == 'x86_64-linux' + run: | + init_path=$(grep "init=" result/bin/nixvim-print-init | awk -F'=' '{print $2}') + cp $init_path init.lua + + - name: Upload the artifact + uses: actions/upload-artifact@v4 + if: matrix.system == 'x86_64-linux' + with: + name: neovim-configuration + path: init.lua + + - name: Publish the init.lua to an orphan github branch + if: matrix.system == 'x86_64-linux' + run: | + git config --global user.name github-actions + git config --global user.email github-actions@github.com + git checkout --orphan init-lua + git rm -rf . + git add init.lua + git commit -m "Publish init.lua" + git push --force origin init-lua + git checkout main # switch back to main branch for graceful job ending + + check-formatting: + runs-on: ubuntu-24.04 + steps: + - name: Checkout the repository + uses: actions/checkout@v2 + + - name: Install nix + uses: cachix/install-nix-action@v16 + + - name: Check formatting (dont update) + run: nix shell nixpkgs#alejandra -c alejandra -c . + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e2f5dd2 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +result \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..0a54b1a --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2025 Osman F Bayram + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..f128cb9 --- /dev/null +++ b/README.md @@ -0,0 +1,6 @@ + +This is my neovim configuration. I am using [nix](https://github.com/nixos/nix) and [nixvim](https://github.com/nix-community/nixvim) to generate the neovim configuration. + +I am also pushing the generated neovim configuration in another branch using github actions. You can see my generated init.lua file [here](https://github.com/osbm/osbm-nvim/blob/init-lua/init.lua). + + diff --git a/config/colorscheme.nix b/config/colorscheme.nix new file mode 100644 index 0000000..9d792c8 --- /dev/null +++ b/config/colorscheme.nix @@ -0,0 +1,8 @@ +{ + colorschemes = { + catppuccin = { + enable = true; + settings.flavor = "mocha"; + }; + }; +} diff --git a/config/default.nix b/config/default.nix new file mode 100644 index 0000000..c288068 --- /dev/null +++ b/config/default.nix @@ -0,0 +1,64 @@ +{pkgs, ...}: { + imports = [ + ./colorscheme.nix + ./options.nix + ./plugins + ]; + + config = { + # Use as leader key + globals.mapleader = " "; + globals.maplocalleader = " "; + + # Set 'vi' and 'vim' aliases to nixvim + viAlias = true; + vimAlias = true; + + # Setup clipboard support + clipboard = { + # Use xsel as clipboard provider + # providers.xsel.enable = true; + + # Sync system clipboard + register = "unnamedplus"; + }; + extraPackages = with pkgs; [ + nix-inspect + nixd + git + git-lfs + cloc + ripgrep + lazygit + black + fd + ripgrep + ]; + + keymaps = [ + { + mode = "n"; + key = "gg"; + action = "LazyGit"; + options = { + desc = "LazyGit (root dir)"; + }; + } + ]; + extraPlugins = with pkgs.vimPlugins; [ + lazygit-nvim + ]; + + extraConfigLua = '' + require("telescope").load_extension("lazygit") + ''; + performance = { + byteCompileLua = { + enable = true; + nvimRuntime = true; + configs = true; + plugins = true; + }; + }; + }; +} diff --git a/config/options.nix b/config/options.nix new file mode 100644 index 0000000..fa918f5 --- /dev/null +++ b/config/options.nix @@ -0,0 +1,49 @@ +{ + opts = { + # Enable relative line numbers + number = true; + relativenumber = true; + + # show spaces tabs and trailing spaces + list = true; + listchars = "tab:» ,trail:·,multispace:·,lead: ,nbsp:⎕"; + + # Tab options + tabstop = + 2; # Number of spaces a in the text stands for (local to buffer) + shiftwidth = + 2; # Number of spaces used for each step of (auto)indent (local to buffer) + softtabstop = + 0; # If non-zero, number of spaces to insert for a (local to buffer) + expandtab = true; # Expand to spaces in Insert mode (local to buffer) + autoindent = true; # Do clever autoindenting + # TODO: i want to see 4 spaces when i press tab in python and 2 spaces in nix using setlocal + # is it possible for me to set this per language? + + # folding + foldmethod = "expr"; + foldexpr = "nvim_treesitter#foldexpr()"; + foldlevel = 99; # Folds with a level higher than this number will be closed + foldcolumn = "1"; + foldenable = true; + foldlevelstart = -1; + fillchars = { + horiz = "━"; + horizup = "┻"; + horizdown = "┳"; + vert = "┃"; + vertleft = "┫"; + vertright = "┣"; + verthoriz = "╋"; + + eob = " "; + diff = "╱"; + + fold = " "; + foldopen = ""; + foldclose = ""; + + msgsep = "‾"; + }; + }; +} diff --git a/config/plugins/avante.nix b/config/plugins/avante.nix new file mode 100644 index 0000000..dbe9ec7 --- /dev/null +++ b/config/plugins/avante.nix @@ -0,0 +1,23 @@ +{ + plugins.avante = { + lazyLoad.settings.event = ["DeferredUIEnter"]; + settings = { + # provider = "ollama"; + # provider = "claude"; + providers = { + # claude = { + # endpoint = "https://api.anthropic.com"; + # extra_request_body = { + # max_tokens = 4096; + # temperature = 0; + # }; + # model = "claude-3-5-sonnet-20240620"; + # }; + ollama = { + endpoint = "http://localhost:11434"; + model = "qwen2.5-coder:32b"; + }; + }; + }; + }; +} diff --git a/config/plugins/blink-cmp.nix b/config/plugins/blink-cmp.nix new file mode 100644 index 0000000..73a09b4 --- /dev/null +++ b/config/plugins/blink-cmp.nix @@ -0,0 +1,36 @@ +{ + plugins.blink-cmp = { + settings = { + # snippets = { + # preset = "luasnip"; + # }; + sources = { + default = [ + "lsp" + "path" + "buffer" + "copilot" + ]; + providers = { + copilot = { + async = true; + module = "blink-copilot"; + name = "copilot"; + score_offset = 100; + # Optional configurations + opts = { + max_completions = 3; + max_attempts = 4; + kind = "Copilot"; + debounce = 750; + auto_refresh = { + backward = true; + forward = true; + }; + }; + }; + }; + }; + }; + }; +} diff --git a/config/plugins/cmp.nix b/config/plugins/cmp.nix new file mode 100644 index 0000000..e9eacab --- /dev/null +++ b/config/plugins/cmp.nix @@ -0,0 +1,31 @@ +{ + plugins.cmp = { + autoEnableSources = true; + settings = { + sources = [ + # LSP source + { + name = "nvim_lsp"; + } + # For path completion + { + name = "path"; + } + # For buffer completion + { + name = "buffer"; + keyword_length = 5; + } + # For command line completion + {name = "cmdline";} + ]; + mapping = { + # means enter + "" = "cmp.mapping.confirm({ select = true })"; + "" = "cmp.mapping.select_next_item()"; + "" = "cmp.mapping.select_prev_item()"; + "" = "cmp.mapping.close()"; + }; + }; + }; +} diff --git a/config/plugins/comment.nix b/config/plugins/comment.nix new file mode 100644 index 0000000..aa5a156 --- /dev/null +++ b/config/plugins/comment.nix @@ -0,0 +1,6 @@ +{ + plugins.comment.settings = { + toggler.line = ""; + opleader.line = ""; + }; +} diff --git a/config/plugins/default.nix b/config/plugins/default.nix new file mode 100644 index 0000000..e417720f --- /dev/null +++ b/config/plugins/default.nix @@ -0,0 +1,81 @@ +{lib, ...}: { + imports = + lib.mapAttrsToList (name: _path: ./. + "/${name}") + (lib.filterAttrs (filename: kind: + filename != "default.nix" && (kind == "regular" || kind == "directory")) + (builtins.readDir ./.)); + + plugins = { + # todo comments highlighter + todo-comments.enable = true; + + # a statusline plugin + lualine.enable = true; + + # syntax highlighting + treesitter.enable = true; + + # completion plugin + cmp.enable = false; + + # blink completion plugin + blink-cmp.enable = true; + + # Extensible UI for Neovim notifications and LSP progress messages. + fidget.enable = true; + + # A navigation plugin that uses lsp symbols to provide a breadcrumb trail + navic.enable = true; # TODO: not seeing the output rn + + # fast create folders and files + oil.enable = true; + + # a file explorer + telescope.enable = true; + + # vim exercises + vim-be-good.enable = true; + + # Provides Nerd Font icons + web-devicons.enable = true; + + # better ui experience + noice.enable = true; + + # an introduction plugin + mini.enable = true; # TODO look more into the mini plugin + + # cursor animation + smear-cursor.enable = false; + + # add buffer tab plugin + bufferline.enable = true; + + # git integration + gitsigns.enable = true; + + # commenting related plugin + comment.enable = true; + + # lsp support + lsp.enable = true; + + # gives me hardtime about my bad habits + hardtime.enable = false; # TODO: enable when I get used to my new keyboard + + # tip pop-up + which-key.enable = true; + + # ai support + avante.enable = true; + + # lazy loading provider + lz-n.enable = true; + + # oil git status shower + oil-git-status.enable = true; + + # blink copilot + blink-copilot.enable = true; + }; +} diff --git a/config/plugins/gitsigns.nix b/config/plugins/gitsigns.nix new file mode 100644 index 0000000..1b38099 --- /dev/null +++ b/config/plugins/gitsigns.nix @@ -0,0 +1,5 @@ +{ + plugins.gitsigns.settings = { + current_line_blame = true; + }; +} diff --git a/config/plugins/lsp.nix b/config/plugins/lsp.nix new file mode 100644 index 0000000..e545733 --- /dev/null +++ b/config/plugins/lsp.nix @@ -0,0 +1,25 @@ +{ + lib, + pkgs, + self, + ... +}: { + plugins.lsp.servers = { + astro.enable = true; + dockerls.enable = true; + nixd = { + enable = true; + settings = let + flake = ''(builtins.getFlake "${self}")''; + in { + nixpkgs.expr = "import ${flake}.inputs.nixpkgs { }"; + formatting.command = ["${lib.getExe pkgs.nixfmt-rfc-style}"]; + }; + }; + pyright.enable = true; + typos_lsp = { + enable = true; + extraOptions.init_options.diagnosticSeverity = "Hint"; + }; + }; +} diff --git a/config/plugins/mini.nix b/config/plugins/mini.nix new file mode 100644 index 0000000..7875b5e --- /dev/null +++ b/config/plugins/mini.nix @@ -0,0 +1,40 @@ +{ + config, + lib, + ... +}: { + plugins.mini = { + modules = { + starter = { + header = '' + _ _ + ___ ___| |__ _ __ ___ __| | _____ __ + / _ \/ __| '_ \| '_ ` _ \ / _` |/ _ \ \ / / + | (_) \__ \ |_) | | | | | || (_| | __/\ V / + \___/|___/_.__/|_| |_| |_(_)__,_|\___| \_/ + ''; + # this items and content_hooks are copied from khanelivim config + # but i want to understand them + items = { + "__unkeyed-1.builtin_actions".__raw = "require('mini.starter').sections.builtin_actions()"; + "__unkeyed-2.recent_files_current_directory".__raw = "require('mini.starter').sections.recent_files(10, true)"; + "__unkeyed-3.recent_files".__raw = "require('mini.starter').sections.recent_files(10, false)"; + "__unkeyed-4.sessions".__raw = lib.mkIf (config.plugins.mini.enable + && lib.hasAttr "sessions" config.plugins.mini.modules) + "require('mini.starter').sections.sessions(5, true)"; + __unkeyed-5 = lib.mkIf config.plugins.persistence.enable { + name = "Restore session"; + action.__raw = "[[lua require('persistence').load()]]"; + section = "Session"; + }; + }; + + content_hooks = { + "__unkeyed-1.adding_bullet".__raw = "require('mini.starter').gen_hook.adding_bullet()"; + "__unkeyed-2.indexing".__raw = "require('mini.starter').gen_hook.indexing('all', { 'Builtin actions' })"; + "__unkeyed-3.padding".__raw = "require('mini.starter').gen_hook.aligning('center', 'center')"; + }; + }; + }; + }; +} diff --git a/config/plugins/oil.nix b/config/plugins/oil.nix new file mode 100644 index 0000000..4a6151b --- /dev/null +++ b/config/plugins/oil.nix @@ -0,0 +1,25 @@ +{ + config, + lib, + ... +}: { + plugins.oil.settings = { + view_options = { + show_hidden = true; + }; + win_options = { + signcolumn = "yes:2"; + }; + }; + # add this keymaps only if oil plugin is enabled + keymaps = lib.mkIf config.plugins.oil.enable [ + { + action = "Oil"; + key = "-"; + options = { + silent = true; + # TODO what does silent do? + }; + } + ]; +} diff --git a/config/plugins/treesitter.nix b/config/plugins/treesitter.nix new file mode 100644 index 0000000..54cec01 --- /dev/null +++ b/config/plugins/treesitter.nix @@ -0,0 +1,21 @@ +{ + plugins.treesitter = { + folding = true; # i dont like the way it starts neovim with everything folded + settings = { + ensure_installed = [ + "python" + "astro" + "just" + "dockerfile" + "json" + "yaml" + "lua" + "nix" + "c" + "markdown" + # TODO: add mdx + ]; + highlight = {enable = true;}; + }; + }; +} diff --git a/config/plugins/which-key.nix b/config/plugins/which-key.nix new file mode 100644 index 0000000..59973ae --- /dev/null +++ b/config/plugins/which-key.nix @@ -0,0 +1,8 @@ +{ + plugins.which-key.settings = { + delay = 500; + win = { + border = "single"; + }; + }; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..a386e99 --- /dev/null +++ b/flake.lock @@ -0,0 +1,240 @@ +{ + "nodes": { + "flake-parts": { + "inputs": { + "nixpkgs-lib": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1760948891, + "narHash": "sha256-TmWcdiUUaWk8J4lpjzu4gCGxWY6/Ok7mOK4fIFfBuU4=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "864599284fc7c0ba6357ed89ed5e2cd5040f0c04", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "ixx": { + "inputs": { + "flake-utils": [ + "nixvim", + "nuschtosSearch", + "flake-utils" + ], + "nixpkgs": [ + "nixvim", + "nuschtosSearch", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1754860581, + "narHash": "sha256-EM0IE63OHxXCOpDHXaTyHIOk2cNvMCGPqLt/IdtVxgk=", + "owner": "NuschtOS", + "repo": "ixx", + "rev": "babfe85a876162c4acc9ab6fb4483df88fa1f281", + "type": "github" + }, + "original": { + "owner": "NuschtOS", + "ref": "v0.1.1", + "repo": "ixx", + "type": "github" + } + }, + "nix-formatter-pack": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ], + "nmd": "nmd", + "nmt": "nmt" + }, + "locked": { + "lastModified": 1756744433, + "narHash": "sha256-6BSEvkprwEQDQQgW5UH/1GkBPGM8M9+qX6o9ePslr6E=", + "owner": "Gerschtli", + "repo": "nix-formatter-pack", + "rev": "63b748033a3fa0af80f8ed908521122e48858c30", + "type": "github" + }, + "original": { + "owner": "Gerschtli", + "repo": "nix-formatter-pack", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1761373498, + "narHash": "sha256-Q/uhWNvd7V7k1H1ZPMy/vkx3F8C13ZcdrKjO7Jv7v0c=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "6a08e6bb4e46ff7fcbb53d409b253f6bad8a28ce", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs_2": { + "locked": { + "lastModified": 1761656231, + "narHash": "sha256-EiED5k6gXTWoAIS8yQqi5mAX6ojnzpHwAQTS3ykeYMg=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "e99366c665bdd53b7b500ccdc5226675cfc51f45", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixvim": { + "inputs": { + "flake-parts": "flake-parts", + "nixpkgs": "nixpkgs_2", + "nuschtosSearch": "nuschtosSearch", + "systems": "systems_2" + }, + "locked": { + "lastModified": 1761744315, + "narHash": "sha256-OknzyEoI+VEYgk/FWMyx3tvjb/MPPyqS+G/aemDz51w=", + "owner": "nix-community", + "repo": "nixvim", + "rev": "6233fc6b2c3f203d8a5970f4a2c1df5777902717", + "type": "github" + }, + "original": { + "owner": "nix-community", + "repo": "nixvim", + "type": "github" + } + }, + "nmd": { + "flake": false, + "locked": { + "lastModified": 1666190571, + "narHash": "sha256-Z1hc7M9X6L+H83o9vOprijpzhTfOBjd0KmUTnpHAVjA=", + "owner": "rycee", + "repo": "nmd", + "rev": "b75d312b4f33bd3294cd8ae5c2ca8c6da2afc169", + "type": "gitlab" + }, + "original": { + "owner": "rycee", + "repo": "nmd", + "type": "gitlab" + } + }, + "nmt": { + "flake": false, + "locked": { + "lastModified": 1648075362, + "narHash": "sha256-u36WgzoA84dMVsGXzml4wZ5ckGgfnvS0ryzo/3zn/Pc=", + "owner": "rycee", + "repo": "nmt", + "rev": "d83601002c99b78c89ea80e5e6ba21addcfe12ae", + "type": "gitlab" + }, + "original": { + "owner": "rycee", + "repo": "nmt", + "type": "gitlab" + } + }, + "nuschtosSearch": { + "inputs": { + "flake-utils": "flake-utils", + "ixx": "ixx", + "nixpkgs": [ + "nixvim", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1761730856, + "narHash": "sha256-t1i5p/vSWwueZSC0Z2BImxx3BjoUDNKyC2mk24krcMY=", + "owner": "NuschtOS", + "repo": "search", + "rev": "e29de6db0cb3182e9aee75a3b1fd1919d995d85b", + "type": "github" + }, + "original": { + "owner": "NuschtOS", + "repo": "search", + "type": "github" + } + }, + "root": { + "inputs": { + "nix-formatter-pack": "nix-formatter-pack", + "nixpkgs": "nixpkgs", + "nixvim": "nixvim" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..ab0b46c --- /dev/null +++ b/flake.nix @@ -0,0 +1,71 @@ +{ + description = "My custom neovim configuration that has been mixed and matched from various sources"; + + nixConfig = { + extra-substituters = [ + "https://nix-community.cachix.org" + ]; + extra-trusted-public-keys = [ + "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" + ]; + }; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + # https://gerschtli.github.io/nix-formatter-pack/nix-formatter-pack-options.html + nix-formatter-pack = { + url = "github:Gerschtli/nix-formatter-pack"; + inputs.nixpkgs.follows = "nixpkgs"; + }; + nixvim.url = "github:nix-community/nixvim"; + }; + + outputs = { + self, + nixpkgs, + nixvim, + nix-formatter-pack, + ... + }: let + forAllSystems = nixpkgs.lib.genAttrs [ + "aarch64-linux" + "i686-linux" + "x86_64-linux" + "aarch64-darwin" + "x86_64-darwin" + ]; + in { + formatter = forAllSystems (system: + nix-formatter-pack.lib.mkFormatter { + pkgs = nixpkgs.legacyPackages.${system}; + config.tools = { + deadnix.enable = true; + alejandra.enable = true; + statix.enable = true; + }; + }); + + packages = forAllSystems (system: let + pkgs = import nixpkgs {inherit system;}; + mkNixvim = specialArgs: + nixvim.legacyPackages.${system}.makeNixvimWithModule { + inherit pkgs; + module = ./config; + extraSpecialArgs = + specialArgs + // { + inherit pkgs self; + }; + }; + in rec { + default = mkNixvim {}; + lite = mkNixvim {withLSP = false;}; + + default-print-init = default.config.build.printInitPackage; + lite-print-init = lite.config.build.printInitPackage; + + default-init = default.config.build.initSource; + lite-init = lite.config.build.initSource; + }); + }; +} diff --git a/init.lua b/init.lua deleted file mode 100644 index ec72bb4..0000000 --- a/init.lua +++ /dev/null @@ -1,212 +0,0 @@ --- Ignore the user lua configuration -vim.opt.runtimepath:remove(vim.fn.stdpath("config")) -- ~/.config/nvim -vim.opt.runtimepath:remove(vim.fn.stdpath("config") .. "/after") -- ~/.config/nvim/after - --- Nixvim's internal module table --- Can be used to share code throughout init.lua -local _M = {} - --- Set up options {{{ -do - local nixvim_options = { - autoindent = true, - clipboard = "unnamedplus", - expandtab = true, - list = true, - listchars = "tab:» ,trail:·,multispace:·,lead: ,nbsp:⎕", - number = true, - relativenumber = true, - shiftwidth = 2, - softtabstop = 0, - tabstop = 2, - termguicolors = true, - } - - for k, v in pairs(nixvim_options) do - vim.opt[k] = v - end -end --- }}} - -require("gruvbox").setup({}) - -vim.cmd([[let $BAT_THEME = 'gruvbox' - -colorscheme gruvbox -]]) -require("nvim-web-devicons").setup({}) - -require("mini.starter").setup({ - content_hooks = { - require("mini.starter").gen_hook.adding_bullet(), - require("mini.starter").gen_hook.indexing("all", { "Builtin actions" }), - require("mini.starter").gen_hook.aligning("center", "center"), - }, - header = " _ _\n ___ ___| |__ _ __ ___ __| | _____ __\n / _ \\/ __| '_ \\| '_ ` _ \\ / _` |/ _ \\ \\ / /\n| (_) \\__ \\ |_) | | | | | || (_| | __/\\ V /\n \\___/|___/_.__/|_| |_| |_(_)__,_|\\___| \\_/\n", - items = { - require("mini.starter").sections.builtin_actions(), - require("mini.starter").sections.recent_files(10, true), - require("mini.starter").sections.recent_files(10, false), - }, -}) - --- LSP {{{ -do - local __lspServers = { - { extraOptions = { init_options = { diagnosticSeverity = "Hint" } }, name = "typos_lsp" }, - { name = "pyright" }, - { - extraOptions = { - settings = { - nixd = { - formatting = { - command = { - "/nix/store/8dy4rqc44frv0wi4k6akn0a2znmj7bym-nixfmt-unstable-2025-04-04/bin/nixfmt", - }, - }, - nixpkgs = { - expr = 'import (builtins.getFlake "/nix/store/gv8kpbbakfkw91b3xkr0xgkhwzmnqq6r-source").inputs.nixpkgs { }', - }, - }, - }, - }, - name = "nixd", - }, - { name = "dockerls" }, - { name = "astro" }, - } - -- Adding lspOnAttach function to nixvim module lua table so other plugins can hook into it. - _M.lspOnAttach = function(client, bufnr) end - local __lspCapabilities = function() - capabilities = vim.lsp.protocol.make_client_capabilities() - - capabilities = vim.tbl_deep_extend("force", capabilities, require("cmp_nvim_lsp").default_capabilities()) - - return capabilities - end - - local __setup = { - on_attach = _M.lspOnAttach, - capabilities = __lspCapabilities(), - } - - for i, server in ipairs(__lspServers) do - if type(server) == "string" then - require("lspconfig")[server].setup(__setup) - else - local options = server.extraOptions - - if options == nil then - options = __setup - else - options = vim.tbl_extend("keep", options, __setup) - end - - require("lspconfig")[server.name].setup(options) - end - end -end --- }}} - -local cmp = require("cmp") -cmp.setup({ - mapping = { - [""] = cmp.mapping.close(), - [""] = cmp.mapping.select_next_item(), - [""] = cmp.mapping.select_prev_item(), - [""] = cmp.mapping.confirm({ select = true }), - }, - sources = { - { name = "nvim_lsp" }, - { name = "path" }, - { keyword_length = 5, name = "buffer" }, - { name = "cmdline" }, - }, -}) - -vim.opt.runtimepath:prepend(vim.fs.joinpath(vim.fn.stdpath("data"), "site")) -require("nvim-treesitter.configs").setup({ - ensure_installed = { "python", "astro", "just", "dockerfile", "json", "yaml", "lua", "nix", "c", "markdown" }, - highlight = { enable = true }, - parser_install_dir = vim.fs.joinpath(vim.fn.stdpath("data"), "site"), -}) - -require("todo-comments").setup({}) - -require("telescope").setup({}) - -local __telescopeExtensions = {} -for i, extension in ipairs(__telescopeExtensions) do - require("telescope").load_extension(extension) -end - -require("smear_cursor").setup({}) - -require("oil").setup({ view_options = { show_hidden = true } }) - -require("noice").setup({}) - -require("nvim-navic").setup({}) - -require("lualine").setup({}) - -require("gitsigns").setup({ current_line_blame = true }) - -require("fidget").setup({}) - -require("Comment").setup({ opleader = { line = "" }, toggler = { line = "" } }) - -require("bufferline").setup({}) - --- Set up keybinds {{{ -do - local __nixvim_binds = { { action = "Oil", key = "-", mode = "", options = { silent = true } } } - for i, map in ipairs(__nixvim_binds) do - vim.keymap.set(map.mode, map.key, map.action, map.options) - end -end --- }}} - --- Set up autogroups {{ -do - local __nixvim_autogroups = { nixvim_binds_LspAttach = { clear = true } } - - for group_name, options in pairs(__nixvim_autogroups) do - vim.api.nvim_create_augroup(group_name, options) - end -end --- }} --- Set up autocommands {{ -do - local __nixvim_autocommands = { - { - callback = function(args) - do - local __nixvim_binds = {} - - for i, map in ipairs(__nixvim_binds) do - local options = vim.tbl_extend("keep", map.options or {}, { buffer = args.buf }) - vim.keymap.set(map.mode, map.key, map.action, options) - end - end - end, - desc = "Load keymaps for LspAttach", - event = "LspAttach", - group = "nixvim_binds_LspAttach", - }, - } - - for _, autocmd in ipairs(__nixvim_autocommands) do - vim.api.nvim_create_autocmd(autocmd.event, { - group = autocmd.group, - pattern = autocmd.pattern, - buffer = autocmd.buffer, - desc = autocmd.desc, - callback = autocmd.callback, - command = autocmd.command, - once = autocmd.once, - nested = autocmd.nested, - }) - end -end --- }}