diff --git a/.github/workflows/flake-check.yml b/.github/workflows/flake-check.yml index 97c50d6..b8afe01 100644 --- a/.github/workflows/flake-check.yml +++ b/.github/workflows/flake-check.yml @@ -1,4 +1,4 @@ -name: "nix build and flake check" +name: "nix flake and fmt check" on: pull_request: push: @@ -6,20 +6,8 @@ jobs: flake-check: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: cachix/install-nix-action@v30 - with: - github_access_token: ${{ secrets.github_token }} - - run: nix flake check - - nixfmt: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: cachix/install-nix-action@v30 - with: - github_access_token: ${{ secrets.github_token }} - - name: install nixfmt - run: nix-env -f -iAP nixfmt-rfc-style - - name: check that nix files are formatted correctly - run : nixfmt --check + - uses: actions/checkout@v4 + - uses: cachix/install-nix-action@v30 + with: + github_access_token: ${{ secrets.github_token }} + - run: nix flake check diff --git a/flake.lock b/flake.lock index 195682e..312d505 100644 --- a/flake.lock +++ b/flake.lock @@ -84,6 +84,22 @@ "type": "github" } }, + "nixpkgs_2": { + "locked": { + "lastModified": 1733097829, + "narHash": "sha256-9hbb1rqGelllb4kVUCZ307G2k3/UhmA8PPGBoyuWaSw=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "2c15aa59df0017ca140d9ba302412298ab4bf22a", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, "root": { "inputs": { "home-manager": "home-manager", @@ -91,7 +107,8 @@ "nixpkgs-borg": "nixpkgs-borg", "nixpkgs-evolution": "nixpkgs-evolution", "nixpkgs-master": "nixpkgs-master", - "sops-nix": "sops-nix" + "sops-nix": "sops-nix", + "treefmt": "treefmt" } }, "sops-nix": { @@ -113,6 +130,24 @@ "repo": "sops-nix", "type": "github" } + }, + "treefmt": { + "inputs": { + "nixpkgs": "nixpkgs_2" + }, + "locked": { + "lastModified": 1735135567, + "narHash": "sha256-8T3K5amndEavxnludPyfj3Z1IkcFdRpR23q+T0BVeZE=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "9e09d30a644c57257715902efbb3adc56c79cf28", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 987564c..7bc1bd9 100644 --- a/flake.nix +++ b/flake.nix @@ -11,6 +11,7 @@ url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs"; }; + treefmt.url = "github:numtide/treefmt-nix"; nixpkgs-borg.url = "github:cything/nixpkgs/borg"; nixpkgs-master.url = "github:nixos/nixpkgs/master"; nixpkgs-evolution.url = "github:nixos/nixpkgs/a49023bcb550bcd84e1fa8afcbe7aa8bc0850bf4"; @@ -21,6 +22,7 @@ self, nixpkgs, home-manager, + treefmt, ... }@inputs: let @@ -65,10 +67,22 @@ }; } ); + + treefmtEval = forEachSystem ( + pkgs: + treefmt.lib.evalModule pkgs { + projectRootFile = "flake.nix"; + programs.nixfmt.enable = true; + programs.stylua.enable = true; + } + ); in { packages = forEachSystem (pkgs: import ./pkgs { inherit pkgs; }); - formatter = forEachSystem (pkgs: pkgs.nixfmt-rfc-style); + formatter = forEachSystem (pkgs: treefmtEval.${pkgs.system}.config.build.wrapper); + checks = forEachSystem (pkgs: { + formatting = treefmtEval.${pkgs.system}.config.build.check self; + }); nixosConfigurations = let diff --git a/home/nvim/init.lua b/home/nvim/init.lua index 963373d..e4af88d 100644 --- a/home/nvim/init.lua +++ b/home/nvim/init.lua @@ -8,13 +8,13 @@ vim.g.loaded_netrwPlugin = 1 vim.opt.termguicolors = true require("nvim-tree").setup() -require("lualine").setup { - options = { - theme = "auto", - icons_enabled = true, - globalstatus = true, - } -} +require("lualine").setup({ + options = { + theme = "auto", + icons_enabled = true, + globalstatus = true, + }, +}) require("gitsigns").setup() @@ -34,24 +34,24 @@ opt.showmode = false opt.mouse = "" opt.wrap = false -vim.cmd.colorscheme "iceberg" +vim.cmd.colorscheme("iceberg") keymap.set("n", "s", require("nvim-tree.api").tree.toggle, { - desc = "toggle nvim-tree", - silent = true, + desc = "toggle nvim-tree", + silent = true, }) -- shortcut to command mode keymap.set({ "n", "x" }, ";", ":", { silent = true }) keymap.set("n", "o", "printf('m`%so``', v:count1)", { - expr = true, - desc = "insert line below without moving cursor", + expr = true, + desc = "insert line below without moving cursor", }) keymap.set("n", "O", "printf('m`%sO``', v:count1)", { - expr = true, - desc = "insert line above without moving cursor", + expr = true, + desc = "insert line above without moving cursor", }) keymap.set("n", "/", [[/\v]]) @@ -65,7 +65,7 @@ keymap.set("x", "p", '"_cp') -- Break inserted text into smaller undo units when we insert some punctuation chars. local undo_ch = { ",", ".", "!", "?", ";", ":" } for _, ch in ipairs(undo_ch) do - keymap.set("i", ch, ch .. "u") + keymap.set("i", ch, ch .. "u") end keymap.set("i", "", "") diff --git a/home/nvim/lua/config/fzf.lua b/home/nvim/lua/config/fzf.lua index 032123c..c96f06d 100644 --- a/home/nvim/lua/config/fzf.lua +++ b/home/nvim/lua/config/fzf.lua @@ -8,14 +8,14 @@ keymap.set("n", "fc", fzf.resume, { silent = true }) keymap.set("n", "fs", fzf.treesitter, { silent = true }) keymap.set("n", "fg", fzf.grep_project, { silent = true }) -fzf.setup { - "fzf-native", - keymap = { - fzf = { - ["ctrl-u"] = "half-page-up", - ["ctrl-d"] = "half-page-down", - ["ctrl-j"] = "preview-page-down", - ["ctrl-k"] = "preview-page-up", - } - } -} +fzf.setup({ + "fzf-native", + keymap = { + fzf = { + ["ctrl-u"] = "half-page-up", + ["ctrl-d"] = "half-page-down", + ["ctrl-j"] = "preview-page-down", + ["ctrl-k"] = "preview-page-up", + }, + }, +}) diff --git a/home/nvim/lua/config/hop.lua b/home/nvim/lua/config/hop.lua index 3b46044..3724b9f 100644 --- a/home/nvim/lua/config/hop.lua +++ b/home/nvim/lua/config/hop.lua @@ -1,16 +1,16 @@ -local hop = require('hop') +local hop = require("hop") local keymap = vim.keymap -hop.setup { - case_insensitive = true; - char2_fallback_key = "", - quit_key = "', "", { - silent = true; - noremap = true; - callback = function() - hop.hint_char1() - end, +hop.setup({ + case_insensitive = true, + char2_fallback_key = "", + quit_key = "", "", { + silent = true, + noremap = true, + callback = function() + hop.hint_char1() + end, }) diff --git a/home/nvim/lua/config/lsp.lua b/home/nvim/lua/config/lsp.lua index 602744e..4b516eb 100644 --- a/home/nvim/lua/config/lsp.lua +++ b/home/nvim/lua/config/lsp.lua @@ -8,69 +8,69 @@ keymap.set("n", "gr", lsp.buf.references) keymap.set("n", "[d", diagnostic.goto_prev) keymap.set("n", "]d", diagnostic.goto_next) -diagnostic.config { - signs = false, -} +diagnostic.config({ + signs = false, +}) local lspconfig = require("lspconfig") local capabilities = require("cmp_nvim_lsp").default_capabilities() -lspconfig.pylsp.setup { capabilities = capabilities } -lspconfig.clangd.setup { capabilities = capabilities } -lspconfig.vimls.setup { capabilities = capabilities } -lspconfig.bashls.setup { capabilities = capabilities } -lspconfig.rust_analyzer.setup { - capabilities = capabilities, -} +lspconfig.pylsp.setup({ capabilities = capabilities }) +lspconfig.clangd.setup({ capabilities = capabilities }) +lspconfig.vimls.setup({ capabilities = capabilities }) +lspconfig.bashls.setup({ capabilities = capabilities }) +lspconfig.rust_analyzer.setup({ + capabilities = capabilities, +}) -lspconfig.gopls.setup { - settings = { - gopls = { - analyses = { - unusedparams = true, - }, - staticcheck = true, - gofumpt = true, - } - }, - capabilities = capabilities, -} +lspconfig.gopls.setup({ + settings = { + gopls = { + analyses = { + unusedparams = true, + }, + staticcheck = true, + gofumpt = true, + }, + }, + capabilities = capabilities, +}) -lspconfig.lua_ls.setup { - capabilities = capabilities, - on_init = function(client) - if client.workspace_folders then - local path = client.workspace_folders[1].name - if vim.uv.fs_stat(path..'/.luarc.json') or vim.uv.fs_stat(path..'/.luarc.jsonc') then - return - end - end +lspconfig.lua_ls.setup({ + capabilities = capabilities, + on_init = function(client) + if client.workspace_folders then + local path = client.workspace_folders[1].name + if vim.uv.fs_stat(path .. "/.luarc.json") or vim.uv.fs_stat(path .. "/.luarc.jsonc") then + return + end + end - client.config.settings.Lua = vim.tbl_deep_extend('force', client.config.settings.Lua, { - runtime = { - -- Tell the language server which version of Lua you're using - -- (most likely LuaJIT in the case of Neovim) - version = 'LuaJIT' - }, - -- Make the server aware of Neovim runtime files - workspace = { - checkThirdParty = false, - library = { - vim.env.VIMRUNTIME - -- Depending on the usage, you might want to add additional paths here. - -- "${3rd}/luv/library" - -- "${3rd}/busted/library", - } - -- or pull in all of 'runtimepath'. NOTE: this is a lot slower - -- library = vim.api.nvim_get_runtime_file("", true) - } - }) - end, - settings = { - Lua = {} - } -} + client.config.settings.Lua = vim.tbl_deep_extend("force", client.config.settings.Lua, { + runtime = { + -- Tell the language server which version of Lua you're using + -- (most likely LuaJIT in the case of Neovim) + version = "LuaJIT", + }, + -- Make the server aware of Neovim runtime files + workspace = { + checkThirdParty = false, + library = { + vim.env.VIMRUNTIME, + -- Depending on the usage, you might want to add additional paths here. + -- "${3rd}/luv/library" + -- "${3rd}/busted/library", + }, + -- or pull in all of 'runtimepath'. NOTE: this is a lot slower + -- library = vim.api.nvim_get_runtime_file("", true) + }, + }) + end, + settings = { + Lua = {}, + }, +}) -lspconfig.nixd.setup { capabilities = capabilities } -lspconfig.sqls.setup { capabilities = capabilities } -lspconfig.hls.setup { capabilities = capabilities } +lspconfig.nixd.setup({ capabilities = capabilities }) +lspconfig.sqls.setup({ capabilities = capabilities }) +lspconfig.hls.setup({ capabilities = capabilities }) diff --git a/home/nvim/lua/config/nvim-cmp.lua b/home/nvim/lua/config/nvim-cmp.lua index 8ad2453..8cfdedb 100644 --- a/home/nvim/lua/config/nvim-cmp.lua +++ b/home/nvim/lua/config/nvim-cmp.lua @@ -1,54 +1,54 @@ local cmp = require("cmp") -local luasnip = require("luasnip"); +local luasnip = require("luasnip") -cmp.setup { - snippet = { - expand = function(args) - require('luasnip').lsp_expand(args.body) - end, - }, - mapping = { - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - if luasnip.expandable() then - luasnip.expand() - else - cmp.confirm({ - select = true, - }) - end - else - fallback() - end - end), + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + if luasnip.expandable() then + luasnip.expand() + else + cmp.confirm({ + select = true, + }) + end + else + fallback() + end + end), - [""] = cmp.mapping(function(fallback) - if luasnip.locally_jumpable(1) then - luasnip.jump(1) - elseif cmp.visible() then - cmp.select_next_item() - else - fallback() - end - end, { "i", "s" }), + [""] = cmp.mapping(function(fallback) + if luasnip.locally_jumpable(1) then + luasnip.jump(1) + elseif cmp.visible() then + cmp.select_next_item() + else + fallback() + end + end, { "i", "s" }), - [""] = cmp.mapping(function(fallback) - if luasnip.locally_jumpable(-1) then - luasnip.jump(-1) - elseif cmp.visible() then - cmp.select_prev_item() - else - fallback() - end - end, { "i", "s" }), - }, - sources = cmp.config.sources ({ - { name = "nvim_lsp" }, - { name = "luasnip" }, - }, { - { name = "buffer" }, - { name = "path" }, - }) -} + [""] = cmp.mapping(function(fallback) + if luasnip.locally_jumpable(-1) then + luasnip.jump(-1) + elseif cmp.visible() then + cmp.select_prev_item() + else + fallback() + end + end, { "i", "s" }), + }, + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "luasnip" }, + }, { + { name = "buffer" }, + { name = "path" }, + }), +}) diff --git a/home/nvim/lua/plugin_specs.lua b/home/nvim/lua/plugin_specs.lua index 691c703..a51272e 100644 --- a/home/nvim/lua/plugin_specs.lua +++ b/home/nvim/lua/plugin_specs.lua @@ -1,99 +1,99 @@ -- Bootstrap lazy.nvim local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" if not (vim.uv or vim.loop).fs_stat(lazypath) then - local lazyrepo = "https://github.com/folke/lazy.nvim.git" - local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) - if vim.v.shell_error ~= 0 then - vim.api.nvim_echo({ - { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, - { out, "WarningMsg" }, - { "\nPress any key to exit..." }, - }, true, {}) - vim.fn.getchar() - os.exit(1) - end + local lazyrepo = "https://github.com/folke/lazy.nvim.git" + local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath }) + if vim.v.shell_error ~= 0 then + vim.api.nvim_echo({ + { "Failed to clone lazy.nvim:\n", "ErrorMsg" }, + { out, "WarningMsg" }, + { "\nPress any key to exit..." }, + }, true, {}) + vim.fn.getchar() + os.exit(1) + end end vim.opt.rtp:prepend(lazypath) vim.g.mapleader = "," local plugin_specs = { - { - "nvim-treesitter/nvim-treesitter", - build = ":TSUpdate", - event = "VeryLazy", - }, + { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + event = "VeryLazy", + }, - { - "neovim/nvim-lspconfig", - event = { "BufRead", "BufNewFile" }, - config = function() - require("config.lsp") - end, - }, + { + "neovim/nvim-lspconfig", + event = { "BufRead", "BufNewFile" }, + config = function() + require("config.lsp") + end, + }, - { - "hrsh7th/nvim-cmp", - event = 'VeryLazy', - dependencies = { - "hrsh7th/cmp-nvim-lsp", - "hrsh7th/cmp-path", - "hrsh7th/cmp-buffer", - "hrsh7th/cmp-omni", - "hrsh7th/cmp-cmdline", - "saadparwaiz1/cmp_luasnip", - }, - config = function() - require("config.nvim-cmp") - end, - }, + { + "hrsh7th/nvim-cmp", + event = "VeryLazy", + dependencies = { + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-path", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-omni", + "hrsh7th/cmp-cmdline", + "saadparwaiz1/cmp_luasnip", + }, + config = function() + require("config.nvim-cmp") + end, + }, - { - "L3MON4D3/LuaSnip", - version = "v2.*", - build = "make install_jsregexp", - }, + { + "L3MON4D3/LuaSnip", + version = "v2.*", + build = "make install_jsregexp", + }, - { "stevearc/dressing.nvim", event = "VeryLazy" }, + { "stevearc/dressing.nvim", event = "VeryLazy" }, - { - "nvim-tree/nvim-tree.lua", - lazy = false, - dependencies = { - "nvim-tree/nvim-web-devicons", - }, - }, + { + "nvim-tree/nvim-tree.lua", + lazy = false, + dependencies = { + "nvim-tree/nvim-web-devicons", + }, + }, - { - "ibhagwan/fzf-lua", - dependencies = { "nvim-tree/nvim-web-devicons" }, - config = function() - require("config.fzf") - end, - }, + { + "ibhagwan/fzf-lua", + dependencies = { "nvim-tree/nvim-web-devicons" }, + config = function() + require("config.fzf") + end, + }, - { "windwp/nvim-autopairs", event = "InsertEnter", config = true }, + { "windwp/nvim-autopairs", event = "InsertEnter", config = true }, - { "tpope/vim-commentary", event = "VeryLazy" }, + { "tpope/vim-commentary", event = "VeryLazy" }, - { "folke/tokyonight.nvim", lazy = false, priority = 1000 }, + { "folke/tokyonight.nvim", lazy = false, priority = 1000 }, - { "lewis6991/gitsigns.nvim"}, + { "lewis6991/gitsigns.nvim" }, - { "nvim-lualine/lualine.nvim", dependencies = { "nvim-tree/nvim-web-devicons" } }, + { "nvim-lualine/lualine.nvim", dependencies = { "nvim-tree/nvim-web-devicons" } }, - { - 'smoka7/hop.nvim', - version = "*", - config = function() - require("config.hop") - end, - }, + { + "smoka7/hop.nvim", + version = "*", + config = function() + require("config.hop") + end, + }, - { "cocopon/iceberg.vim" } + { "cocopon/iceberg.vim" }, } require("lazy").setup({ - spec = plugin_specs, - rocks = { enabled = true }, + spec = plugin_specs, + rocks = { enabled = true }, })