commit 6eae514dabfbc3c51f506e2fb22a12957a04b133 Author: antoine Date: Sun Mar 22 09:48:53 2026 +0100 init diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f25d22e --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +result +*.AppImage diff --git a/config.nix b/config.nix new file mode 100644 index 0000000..a64b882 --- /dev/null +++ b/config.nix @@ -0,0 +1,15 @@ +{...}: { + imports = [ + ./plugins/options.nix + ./plugins/theme.nix + ./plugins/completion.nix + ./plugins/lsp.nix + ./plugins/formatter.nix + ./plugins/statusline.nix + ./plugins/git.nix + ./plugins/ui.nix + ./plugins/navigation.nix + ./plugins/editing.nix + ./plugins/keymaps.nix + ]; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..33086fc --- /dev/null +++ b/flake.lock @@ -0,0 +1,142 @@ +{ + "nodes": { + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1751685974, + "narHash": "sha256-NKw96t+BgHIYzHUjkTK95FqYRVKB8DHpVhefWSz/kTw=", + "ref": "refs/heads/main", + "rev": "549f2762aebeff29a2e5ece7a7dc0f955281a1d1", + "revCount": 92, + "type": "git", + "url": "https://git.lix.systems/lix-project/flake-compat.git" + }, + "original": { + "type": "git", + "url": "https://git.lix.systems/lix-project/flake-compat.git" + } + }, + "flake-parts": { + "inputs": { + "nixpkgs-lib": [ + "nvf", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1769996383, + "narHash": "sha256-AnYjnFWgS49RlqX7LrC4uA+sCCDBj0Ry/WOJ5XWAsa0=", + "owner": "hercules-ci", + "repo": "flake-parts", + "rev": "57928607ea566b5db3ad13af0e57e921e6b12381", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "flake-parts", + "type": "github" + } + }, + "mnw": { + "locked": { + "lastModified": 1770419553, + "narHash": "sha256-b1XqsH7AtVf2dXmq2iyRr2NC1yG7skY7Z6N2MpWHlK4=", + "owner": "Gerg-L", + "repo": "mnw", + "rev": "2aaffa8030d0b262176146adbb6b0e6374ce2957", + "type": "github" + }, + "original": { + "owner": "Gerg-L", + "repo": "mnw", + "type": "github" + } + }, + "ndg": { + "inputs": { + "nixpkgs": [ + "nvf", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1768214250, + "narHash": "sha256-hnBZDQWUxJV3KbtvyGW5BKLO/fAwydrxm5WHCWMQTbw=", + "owner": "feel-co", + "repo": "ndg", + "rev": "a6bd3c1ce2668d096e4fdaaa03ad7f03ba1fbca8", + "type": "github" + }, + "original": { + "owner": "feel-co", + "ref": "refs/tags/v2.6.0", + "repo": "ndg", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1773821835, + "narHash": "sha256-TJ3lSQtW0E2JrznGVm8hOQGVpXjJyXY2guAxku2O9A4=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "b40629efe5d6ec48dd1efba650c797ddbd39ace0", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "nvf": { + "inputs": { + "flake-compat": "flake-compat", + "flake-parts": "flake-parts", + "mnw": "mnw", + "ndg": "ndg", + "nixpkgs": [ + "nixpkgs" + ], + "systems": "systems" + }, + "locked": { + "lastModified": 1774134539, + "narHash": "sha256-VTbmIpAP4OlM76uwUUezfewBUsrfWk2l3H2QaTY6QLc=", + "owner": "notashelf", + "repo": "nvf", + "rev": "85ca579065a079ee9ee603339668c7c16b61c4f7", + "type": "github" + }, + "original": { + "owner": "notashelf", + "repo": "nvf", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs", + "nvf": "nvf" + } + }, + "systems": { + "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..0f6f13d --- /dev/null +++ b/flake.nix @@ -0,0 +1,32 @@ +{ + description = "Antoine's neovim config"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + nvf.url = "github:notashelf/nvf"; + nvf.inputs.nixpkgs.follows = "nixpkgs"; + }; + + outputs = { + nixpkgs, + nvf, + ... + }: let + system = "x86_64-linux"; + pkgs = nixpkgs.legacyPackages.${system}; + neovim = (nvf.lib.neovimConfiguration { + inherit pkgs; + modules = [./config.nix]; + }).neovim; + in { + packages.${system}.default = pkgs.symlinkJoin { + name = "nvim"; + paths = [neovim]; + nativeBuildInputs = [pkgs.makeWrapper]; + postBuild = '' + wrapProgram $out/bin/nvim \ + --prefix PATH : ${pkgs.lib.makeBinPath [pkgs.git pkgs.fzf]} + ''; + }; + }; +} diff --git a/plugins/completion.nix b/plugins/completion.nix new file mode 100644 index 0000000..1481df6 --- /dev/null +++ b/plugins/completion.nix @@ -0,0 +1,29 @@ +{...}: { + vim = { + autocomplete.nvim-cmp = { + enable = true; + mappings = { + complete = ""; + close = ""; + scrollDocsUp = ""; + scrollDocsDown = ""; + confirm = ""; + next = ""; + previous = ""; + }; + }; + + snippets.luasnip.enable = true; + + luaConfigRC.luasnip-keymaps = '' + vim.keymap.set({"i", "s"}, "", function() + local ls = require("luasnip") + if ls.expand_or_jumpable() then ls.expand_or_jump() end + end, {silent = true}) + vim.keymap.set({"i", "s"}, "", function() + local ls = require("luasnip") + if ls.jumpable(-1) then ls.jump(-1) end + end, {silent = true}) + ''; + }; +} diff --git a/plugins/editing.nix b/plugins/editing.nix new file mode 100644 index 0000000..54795cf --- /dev/null +++ b/plugins/editing.nix @@ -0,0 +1,42 @@ +{pkgs, ...}: { + vim = { + autopairs.nvim-autopairs.enable = true; + comments.comment-nvim.enable = true; + + extraPlugins = with pkgs.vimPlugins; { + flash-nvim = { + package = flash-nvim; + setup = ''require("flash").setup({})''; + }; + trouble-nvim = { + package = trouble-nvim; + setup = ''require("trouble").setup({})''; + }; + inc-rename-nvim = { + package = inc-rename-nvim; + setup = ''require("inc_rename").setup({})''; + }; + dressing-nvim = { + package = dressing-nvim; + }; + }; + + keymaps = [ + # Flash + {key = "s"; mode = ["n" "x" "o"]; lua = true; action = ''function() require("flash").jump() end''; desc = "Flash";} + {key = "S"; mode = ["n" "x" "o"]; lua = true; action = ''function() require("flash").treesitter() end''; desc = "Flash Treesitter";} + {key = "R"; mode = ["o" "x"]; lua = true; action = ''function() require("flash").treesitter_search() end''; desc = "Treesitter Search";} + + # Trouble + {key = "lD"; mode = ["n"]; lua = true; action = ''function() require("trouble").open({mode = "diagnostics"}) end''; desc = "Workspace Diagnostics";} + {key = "ld"; mode = ["n"]; lua = true; action = ''function() require("trouble").open({mode = "diagnostics", filter = {buf = 0}}) end''; desc = "Document Diagnostics";} + {key = "lx"; mode = ["n"]; lua = true; action = ''function() require("trouble").open({mode = "lsp_definitions"}) end''; desc = "Lsp Definitions";} + {key = "lt"; mode = ["n"]; lua = true; action = ''function() require("trouble").open({mode = "lsp_type_definitions"}) end''; desc = "Lsp Type Definitions";} + {key = "li"; mode = ["n"]; lua = true; action = ''function() require("trouble").open({mode = "lsp_implementations"}) end''; desc = "Lsp Implementations";} + {key = "lr"; mode = ["n"]; lua = true; action = ''function() require("trouble").open({mode = "lsp_references"}) end''; desc = "Lsp References";} + + # Inc-rename (expr = true to build the command string dynamically) + {key = "ln"; mode = ["n"]; lua = true; expr = true; action = ''function() return ":IncRename " .. vim.fn.expand("") end''; desc = "LSP Rename";} + ]; + }; +} diff --git a/plugins/formatter.nix b/plugins/formatter.nix new file mode 100644 index 0000000..33506bf --- /dev/null +++ b/plugins/formatter.nix @@ -0,0 +1,17 @@ +{...}: { + vim.formatter.conform-nvim = { + enable = true; + setupOpts = { + formatters_by_ft = { + lua = ["stylua"]; + rust = ["rustfmt"]; + nix = ["alejandra"]; + python = ["black"]; + }; + format_on_save = { + timeout_ms = 2000; + lsp_format = "fallback"; + }; + }; + }; +} diff --git a/plugins/git.nix b/plugins/git.nix new file mode 100644 index 0000000..8526dd6 --- /dev/null +++ b/plugins/git.nix @@ -0,0 +1,6 @@ +{...}: { + vim.git = { + gitsigns.enable = true; + vim-fugitive.enable = true; + }; +} diff --git a/plugins/keymaps.nix b/plugins/keymaps.nix new file mode 100644 index 0000000..9e0fced --- /dev/null +++ b/plugins/keymaps.nix @@ -0,0 +1,23 @@ +{...}: { + vim.keymaps = [ + # Page navigation (centered) + {key = ""; mode = ["n"]; action = "zz"; desc = "Page down centered";} + {key = ""; mode = ["n"]; action = "zz"; desc = "Page up centered";} + + # Quickfix navigation + {key = "]c"; mode = ["n"]; action = "cnext"; desc = "Next quickfix";} + {key = "[c"; mode = ["n"]; action = "cprev"; desc = "Prev quickfix";} + + # Split management + {key = "sv"; mode = ["n"]; action = "v"; desc = "Split vertically";} + {key = "sh"; mode = ["n"]; action = "s"; desc = "Split horizontally";} + {key = "se"; mode = ["n"]; action = "="; desc = "Equal splits";} + {key = "sx"; mode = ["n"]; action = "close"; desc = "Close split";} + + # Tab management + {key = "tx"; mode = ["n"]; action = "tabclose"; desc = "Close tab";} + {key = "tn"; mode = ["n"]; action = "tabnew"; desc = "New tab";} + {key = ""; mode = ["n"]; action = "tabnext"; desc = "Next tab";} + {key = ""; mode = ["n"]; action = "tabprevious"; desc = "Prev tab";} + ]; +} diff --git a/plugins/lsp.nix b/plugins/lsp.nix new file mode 100644 index 0000000..5703359 --- /dev/null +++ b/plugins/lsp.nix @@ -0,0 +1,61 @@ +{...}: { + vim = { + lsp.enable = true; + + languages = { + enableFormat = true; + enableTreesitter = true; + enableExtraDiagnostics = true; + + python = { + enable = true; + lsp = { + enable = true; + servers = ["ty"]; + }; + format = { + enable = true; + type = ["black"]; + }; + }; + + lua = { + enable = true; + lsp.enable = true; + format.enable = true; + }; + + rust = { + enable = true; + lsp.enable = true; + extensions.crates-nvim.enable = true; + format.enable = true; + }; + + nix = { + enable = true; + lsp = { + enable = true; + servers = ["nil"]; + }; + format = { + enable = true; + type = ["alejandra"]; + }; + }; + + clang = { + enable = true; + lsp.enable = true; + }; + }; + + keymaps = [ + {key = "ls"; mode = ["n"]; action = "FzfLua lsp_document_symbols"; desc = "Document Symbols";} + {key = "lS"; mode = ["n"]; action = "FzfLua lsp_live_workspace_symbols"; desc = "Workspace Symbols";} + {key = "la"; mode = ["n"]; lua = true; action = "function() vim.lsp.buf.code_action() end"; desc = "Code Actions";} + {key = "K"; mode = ["n"]; lua = true; action = "function() vim.lsp.buf.hover() end"; desc = "Hover Docs";} + {key = "lR"; mode = ["n"]; action = "LspRestart"; desc = "Restart LSP";} + ]; + }; +} diff --git a/plugins/navigation.nix b/plugins/navigation.nix new file mode 100644 index 0000000..742a27c --- /dev/null +++ b/plugins/navigation.nix @@ -0,0 +1,36 @@ +{...}: { + vim = { + fzf-lua = { + enable = true; + profile = "telescope"; + }; + + filetree.nvimTree = { + enable = true; + setupOpts = { + filters.dotfiles = false; + git.enable = true; + renderer.group_empty = true; + }; + }; + + session.nvim-session-manager.enable = true; + + keymaps = [ + # FZF-lua + {key = "ff"; mode = ["n"]; action = "FzfLua files"; desc = "Find Files";} + {key = "fg"; mode = ["n"]; action = "FzfLua live_grep"; desc = "Live Grep";} + {key = "fb"; mode = ["n"]; action = "FzfLua buffers"; desc = "Buffer List";} + {key = "fh"; mode = ["n"]; action = "FzfLua help_tags"; desc = "Help Tags";} + {key = "fo"; mode = ["n"]; action = "FzfLua oldfiles"; desc = "Recent Files";} + {key = "fn"; mode = ["n"]; action = "FzfLua notify"; desc = "Notifications";} + + # Nvim-tree + {key = ""; mode = ["n"]; action = "NvimTreeToggle"; desc = "File Tree";} + {key = "e"; mode = ["n"]; action = "NvimTreeFindFile"; desc = "File Tree (find current file)";} + + # Sessions + {key = "fp"; mode = ["n"]; action = "SessionManager load_session"; desc = "Session List";} + ]; + }; +} diff --git a/plugins/options.nix b/plugins/options.nix new file mode 100644 index 0000000..3365419 --- /dev/null +++ b/plugins/options.nix @@ -0,0 +1,28 @@ +{lib, ...}: { + vim = { + globals.mapleader = ","; + + lineNumberMode = "relNumber"; + hideSearchHighlight = true; + searchCase = "smart"; + undoFile.enable = true; + + clipboard = { + enable = true; + registers = "unnamedplus"; + }; + + luaConfigRC.options = lib.nvim.dag.entryAfter ["globalsScript"] '' + vim.opt.tabstop = 2 + vim.opt.shiftwidth = 2 + vim.opt.expandtab = true + vim.opt.autoindent = true + vim.opt.signcolumn = "yes" + vim.opt.splitright = true + vim.opt.splitbelow = true + vim.opt.laststatus = 3 + vim.opt.sessionoptions = "curdir,folds,globals,help,tabpages,terminal,winsize" + vim.opt.timeoutlen = 300 + ''; + }; +} diff --git a/plugins/statusline.nix b/plugins/statusline.nix new file mode 100644 index 0000000..8aef715 --- /dev/null +++ b/plugins/statusline.nix @@ -0,0 +1,18 @@ +{pkgs, ...}: { + vim.extraPlugins.lualine-nvim = { + package = pkgs.vimPlugins.lualine-nvim; + setup = '' + require("lualine").setup({ + options = { + theme = "catppuccin", + globalstatus = true, + section_separators = { + left = string.char(0xEE, 0x82, 0xB4), + right = string.char(0xEE, 0x82, 0xB6), + }, + component_separators = { left = "|", right = "|" }, + }, + }) + ''; + }; +} diff --git a/plugins/theme.nix b/plugins/theme.nix new file mode 100644 index 0000000..a5a3a86 --- /dev/null +++ b/plugins/theme.nix @@ -0,0 +1,8 @@ +{...}: { + vim.theme = { + enable = true; + name = "catppuccin"; + style = "mocha"; + transparent = true; + }; +} diff --git a/plugins/ui.nix b/plugins/ui.nix new file mode 100644 index 0000000..167dbd7 --- /dev/null +++ b/plugins/ui.nix @@ -0,0 +1,41 @@ +{...}: { + vim = { + visuals.indent-blankline.enable = true; + + mini = { + icons.enable = true; + surround.enable = true; + }; + + luaConfigRC.mini-icons-mock = '' + require("mini.icons").mock_nvim_web_devicons() + ''; + + binds.whichKey = { + enable = true; + setupOpts.delay = 300; + }; + + ui.noice = { + enable = true; + setupOpts = { + lsp.override = { + "vim.lsp.util.convert_input_to_markdown_lines" = true; + "vim.lsp.util.stylize_markdown" = true; + }; + presets = { + lsp_doc_border = true; + bottom_search = true; + long_message_to_split = true; + inc_rename = true; + }; + messages.enabled = false; + }; + }; + + dashboard.alpha = { + enable = true; + theme = "dashboard"; + }; + }; +}