From 351e042a7cf362d2fdd1b2f271e710b777392e87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jalil=20David=20Salam=C3=A9=20Messina?= Date: Sun, 30 Jun 2024 14:03:24 +0200 Subject: [PATCH 1/2] [chore] flake.lock: update inputs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix for OpenSSH vulnerability: ``` • Updated input 'home-manager': 'github:nix-community/home-manager/a1fddf0967c33754271761d91a3d921772b30d0e' (2024-06-16) → 'github:nix-community/home-manager/391ca6e950c2525b4f853cbe29922452c14eda82' (2024-07-01) • Updated input 'nixos-hardware': 'github:NixOS/nixos-hardware/a59f00f5ac65b19382617ba00f360f8bc07ed3ac' (2024-06-29) → 'github:NixOS/nixos-hardware/6e253f12b1009053eff5344be5e835f604bb64cd' (2024-07-02) • Updated input 'nixpkgs': 'github:NixOS/nixpkgs/89c49874fb15f4124bf71ca5f42a04f2ee5825fd' (2024-06-26) → 'github:NixOS/nixpkgs/d032c1a6dfad4eedec7e35e91986becc699d7d69' (2024-07-01) • Updated input 'nixvim': 'github:nix-community/nixvim/c062b976eff9f13597c7c23d77a6b3ac677b7fd5' (2024-06-29) → 'github:nix-community/nixvim/079c2c479b5707adf0b03f817be30945c92c15cf' (2024-07-01) • Updated input 'nixvim/flake-parts': 'github:hercules-ci/flake-parts/2a55567fcf15b1b1c7ed712a2c6fadaec7412ea8' (2024-06-01) → 'github:hercules-ci/flake-parts/c3c5ecc05edc7dafba779c6c1a61cd08ac6583e9' (2024-06-30) • Updated input 'nixvim/treefmt-nix': 'github:numtide/treefmt-nix/065a23edceff48f948816b795ea8cc6c0dee7cdf' (2024-06-24) → 'github:numtide/treefmt-nix/8df5ff62195d4e67e2264df0b7f5e8c9995fd0bd' (2024-06-30) • Updated input 'unstable': 'github:NixOS/nixpkgs/b2852eb9365c6de48ffb0dc2c9562591f652242a' (2024-06-27) → 'github:NixOS/nixpkgs/2741b4b489b55df32afac57bc4bfd220e8bf617e' (2024-06-29) ``` --- flake.lock | 42 +++++++++++++++++++++--------------------- flake.nix | 14 ++++++++++---- home/default.nix | 7 +++++-- nvim/standalone.nix | 1 - 4 files changed, 36 insertions(+), 28 deletions(-) diff --git a/flake.lock b/flake.lock index a1f7656..862182b 100644 --- a/flake.lock +++ b/flake.lock @@ -197,11 +197,11 @@ ] }, "locked": { - "lastModified": 1717285511, - "narHash": "sha256-iKzJcpdXih14qYVcZ9QC9XuZYnPc6T8YImb6dX166kw=", + "lastModified": 1719745305, + "narHash": "sha256-xwgjVUpqSviudEkpQnioeez1Uo2wzrsMaJKJClh+Bls=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "2a55567fcf15b1b1c7ed712a2c6fadaec7412ea8", + "rev": "c3c5ecc05edc7dafba779c6c1a61cd08ac6583e9", "type": "github" }, "original": { @@ -334,11 +334,11 @@ ] }, "locked": { - "lastModified": 1718530513, - "narHash": "sha256-BmO8d0r+BVlwWtMLQEYnwmngqdXIuyFzMwvmTcLMee8=", + "lastModified": 1719827385, + "narHash": "sha256-qs+nU20Sm8czHg3bhGCqiH+8e13BJyRrKONW34g3i50=", "owner": "nix-community", "repo": "home-manager", - "rev": "a1fddf0967c33754271761d91a3d921772b30d0e", + "rev": "391ca6e950c2525b4f853cbe29922452c14eda82", "type": "github" }, "original": { @@ -407,11 +407,11 @@ }, "nixos-hardware": { "locked": { - "lastModified": 1719681865, - "narHash": "sha256-Lp+l1IsREVbz8WM35OJYZz8sAH0XOjrZWUXVB5bJ2qg=", + "lastModified": 1719895800, + "narHash": "sha256-xNbjISJTFailxass4LmdWeV4jNhAlmJPwj46a/GxE6M=", "owner": "NixOS", "repo": "nixos-hardware", - "rev": "a59f00f5ac65b19382617ba00f360f8bc07ed3ac", + "rev": "6e253f12b1009053eff5344be5e835f604bb64cd", "type": "github" }, "original": { @@ -422,11 +422,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1719426051, - "narHash": "sha256-yJL9VYQhaRM7xs0M867ZFxwaONB9T2Q4LnGo1WovuR4=", + "lastModified": 1719838683, + "narHash": "sha256-Zw9rQjHz1ilNIimEXFeVa1ERNRBF8DoXDhLAZq5B4pE=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "89c49874fb15f4124bf71ca5f42a04f2ee5825fd", + "rev": "d032c1a6dfad4eedec7e35e91986becc699d7d69", "type": "github" }, "original": { @@ -456,11 +456,11 @@ "treefmt-nix": "treefmt-nix" }, "locked": { - "lastModified": 1719695745, - "narHash": "sha256-4i71R8xofnwmlhb84swOLQro63pHvC37NVIipbz1I04=", + "lastModified": 1719860300, + "narHash": "sha256-ZeF+zI+/53HeS567/mXS2Gw+w8k9FsjRC/TzoVQOpi4=", "owner": "nix-community", "repo": "nixvim", - "rev": "c062b976eff9f13597c7c23d77a6b3ac677b7fd5", + "rev": "079c2c479b5707adf0b03f817be30945c92c15cf", "type": "github" }, "original": { @@ -541,11 +541,11 @@ ] }, "locked": { - "lastModified": 1719243788, - "narHash": "sha256-9T9mSY35EZSM1KAwb7K9zwQ78qTlLjosZgtUGnw4rn4=", + "lastModified": 1719749022, + "narHash": "sha256-ddPKHcqaKCIFSFc/cvxS14goUhCOAwsM1PbMr0ZtHMg=", "owner": "numtide", "repo": "treefmt-nix", - "rev": "065a23edceff48f948816b795ea8cc6c0dee7cdf", + "rev": "8df5ff62195d4e67e2264df0b7f5e8c9995fd0bd", "type": "github" }, "original": { @@ -556,11 +556,11 @@ }, "unstable": { "locked": { - "lastModified": 1719506693, - "narHash": "sha256-C8e9S7RzshSdHB7L+v9I51af1gDM5unhJ2xO1ywxNH8=", + "lastModified": 1719690277, + "narHash": "sha256-0xSej1g7eP2kaUF+JQp8jdyNmpmCJKRpO12mKl/36Kc=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "b2852eb9365c6de48ffb0dc2c9562591f652242a", + "rev": "2741b4b489b55df32afac57bc4bfd220e8bf617e", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index b4a6394..9bad87f 100644 --- a/flake.nix +++ b/flake.nix @@ -40,7 +40,6 @@ nixvim = { url = "github:nix-community/nixvim"; inputs = { - # Disable until fixed upstream: https://github.com/nix-community/nixvim/issues/1699 nixpkgs.follows = "unstable"; devshell.follows = "devshell"; nix-darwin.follows = ""; # disable MacOS stuff @@ -138,14 +137,21 @@ nixvim = nixvim.overlays.default; jpassmenu = jpassmenu.overlays.default; audiomenu = audiomenu.overlays.default; - unstable = final: prev: { + unstable = final: prev: let + unstablePkgs = unstable.legacyPackages.${prev.system}; + in { + # Get unstable packages + unstable = unstablePkgs; + # Update vim plugins with the versions from unstable + vimPlugins = prev.vimPlugins // unstablePkgs.vimPlugins; + # Get specific packages from unstable inherit - (unstable.legacyPackages.${prev.system}) + (unstablePkgs) gitoxide jujutsu wezterm + neovim-unwrapped ; - unstable = unstable.legacyPackages.${prev.system}; }; }; diff --git a/home/default.nix b/home/default.nix index 4e2e369..f0d84c7 100644 --- a/home/default.nix +++ b/home/default.nix @@ -29,8 +29,11 @@ in { # Better cat (bat) bat = { enable = true; - # Disable headers and numbers - config.style = "plain"; + config = { + # Disable headers and numbers + style = "plain"; + theme = lib.mkForce "gruvbox-dark"; + }; }; # Direnv direnv = { diff --git a/nvim/standalone.nix b/nvim/standalone.nix index 91ea5ae..5f0fbf1 100644 --- a/nvim/standalone.nix +++ b/nvim/standalone.nix @@ -2,7 +2,6 @@ imports = [./options.nix ./plugins.nix ./mappings.nix ./augroups.nix]; config = { - package = pkgs.unstable.neovim-unwrapped; globals.mapleader = " "; # Appearance colorschemes.gruvbox = { -- 2.47.0 From dc130e472360493be3343b99d4773ecc3933085a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jalil=20David=20Salam=C3=A9=20Messina?= Date: Tue, 2 Jul 2024 09:29:44 +0200 Subject: [PATCH 2/2] [feat] nvim: highlight lua codesnippets Adding a comment with the language will automatically highlight the code: ```nix luaCode = /*lua*/ '' function() return "look ma I'm highlighted!" end ''; ``` (May only work using treesitter) --- nvim/augroups.nix | 48 ++++++++++++------- nvim/mappings.nix | 113 +++++++++++++++++++++++++++++++++++++------- nvim/plugins.nix | 103 +++++++++++++++++++++++++--------------- nvim/standalone.nix | 66 ++++++++++++++------------ 4 files changed, 227 insertions(+), 103 deletions(-) diff --git a/nvim/augroups.nix b/nvim/augroups.nix index f810aaf..64b15ca 100644 --- a/nvim/augroups.nix +++ b/nvim/augroups.nix @@ -12,28 +12,38 @@ in { group = "highlightOnYank"; event = "TextYankPost"; pattern = "*"; - callback = mkRaw '' - function() - vim.highlight.on_yank { - higroup = ( - vim.fn['hlexists'] 'HighlightedyankRegion' > 0 and 'HighlightedyankRegion' or 'IncSearch' - ), - timeout = 200, - } - end - ''; + callback = + mkRaw + /* + lua + */ + '' + function() + vim.highlight.on_yank { + higroup = ( + vim.fn['hlexists'] 'HighlightedyankRegion' > 0 and 'HighlightedyankRegion' or 'IncSearch' + ), + timeout = 200, + } + end + ''; } { group = "restoreCursorPosition"; event = "BufReadPost"; pattern = "*"; - callback = mkRaw '' - function() - if vim.fn.line '\'"' > 0 and vim.fn.line '\'"' <= vim.fn.line '$' then - vim.cmd [[execute "normal! g'\""]] + callback = + mkRaw + /* + lua + */ + '' + function() + if vim.fn.line '\'"' > 0 and vim.fn.line '\'"' <= vim.fn.line '$' then + vim.cmd [[execute "normal! g'\""]] + end end - end - ''; + ''; } { group = "lspConfig"; @@ -42,7 +52,11 @@ in { callback = let opts = "noremap = true, buffer = bufnr"; in - mkRaw '' + mkRaw + /* + lua + */ + '' function(opts) local bufnr = opts.buf local client = vim.lsp.get_client_by_id(opts.data.client_id) diff --git a/nvim/mappings.nix b/nvim/mappings.nix index 693d0ce..b953bd5 100644 --- a/nvim/mappings.nix +++ b/nvim/mappings.nix @@ -51,99 +51,180 @@ in { { mode = "n"; key = "dj"; - action = mkRaw "vim.diagnostic.goto_next"; + action = + mkRaw + # lua + '' + vim.diagnostic.goto_next + ''; options.desc = "Diagnostics next [J]"; } { mode = "n"; key = "dk"; - action = mkRaw "vim.diagnostic.goto_prev"; + action = + mkRaw + # lua + '' + vim.diagnostic.goto_prev + ''; options.desc = "Diagnostics previous [K]"; } { mode = "n"; key = "xx"; - action = mkRaw "require('trouble').toggle"; + action = + mkRaw + # lua + '' + require('trouble').toggle + ''; options.desc = "Toggle trouble"; } { mode = "n"; key = "xw"; - action = mkRaw "function() require('trouble').toggle('workspace_diagnostics') end"; + action = + mkRaw + # lua + '' + function() require('trouble').toggle('workspace_diagnostics') end + ''; options.desc = "Toggle Workspace trouble"; } { mode = "n"; key = "xd"; - action = mkRaw "function() require('trouble').toggle('document_diagnostics') end"; + action = + mkRaw + # lua + '' + function() require('trouble').toggle('document_diagnostics') end + ''; options.desc = "Toggle Document trouble"; } { mode = "n"; key = "xq"; - action = mkRaw "function() require('trouble').toggle('quickfix') end"; + action = + mkRaw + # lua + '' + function() require('trouble').toggle('quickfix') end + ''; options.desc = "Toggle Quickfix trouble"; } { mode = "n"; key = "xl"; - action = mkRaw "function() require('trouble').toggle('loclist') end"; + action = + mkRaw + # lua + '' + function() require('trouble').toggle('loclist') end + ''; options.desc = "Toggle Loclist trouble"; } { mode = "n"; key = "gR"; - action = mkRaw "function() require('trouble').toggle('lsp_references') end"; + action = + mkRaw + # lua + '' + function() require('trouble').toggle('lsp_references') end + ''; options.desc = "Toggle lsp References trouble"; } # Telescope { mode = "n"; key = "ff"; - action = mkRaw "require('telescope.builtin').find_files"; + action = + mkRaw + # lua + '' + require('telescope.builtin').find_files + ''; options.desc = "Find Files"; } { mode = "n"; key = "fg"; - action = mkRaw "require('telescope.builtin').live_grep"; + action = + mkRaw + # lua + '' + require('telescope.builtin').live_grep + ''; options.desc = "Find Grep"; } { mode = "n"; key = "fh"; - action = mkRaw "require('telescope.builtin').help_tags"; + action = + mkRaw + # lua + '' + require('telescope.builtin').help_tags + ''; options.desc = "Find Help"; } { mode = "n"; key = "fb"; - action = mkRaw "require('telescope.builtin').buffers"; + action = + mkRaw + # lua + '' + require('telescope.builtin').buffers + ''; options.desc = "Find Buffer"; } { mode = "n"; key = "fd"; - action = mkRaw "require('telescope.builtin').diagnostics"; + action = + mkRaw + # lua + '' + require('telescope.builtin').diagnostics + ''; options.desc = "Find Diagnostics"; } { mode = "n"; key = "fq"; - action = mkRaw "require('telescope.builtin').quickfix"; + action = + mkRaw + # lua + '' + require('telescope.builtin').quickfix + ''; options.desc = "Find Quickfix"; } { mode = "n"; key = "w"; - action = mkRaw "require('conform').format"; + action = + mkRaw + # lua + '' + require('conform').format + ''; options.desc = "Format buffer"; } # Nvim Silicon { mode = "v"; key = "sc"; - action = mkRaw "require('nvim-silicon').clip"; + action = + mkRaw + # lua + '' + require('nvim-silicon').clip + + ''; options.desc = "Snap Code (to clipboard)"; } ]; diff --git a/nvim/plugins.nix b/nvim/plugins.nix index ed12e5e..56a146b 100644 --- a/nvim/plugins.nix +++ b/nvim/plugins.nix @@ -15,14 +15,28 @@ in { enable = true; cmdline = { "/" = { - mapping = mkRaw "cmp.mapping.preset.cmdline()"; + mapping = + mkRaw + /* + lua + */ + '' + cmp.mapping.preset.cmdline() + ''; sources = [ {name = "rg";} {name = "buffer";} ]; }; ":" = { - mapping = mkRaw "cmp.mapping.preset.cmdline()"; + mapping = + mkRaw + /* + lua + */ + '' + cmp.mapping.preset.cmdline() + ''; sources = [ {name = "path";} {name = "cmdline";} @@ -31,7 +45,13 @@ in { }; settings = { # Snippets - snippet.expand = "function(args) require('luasnip').lsp_expand(args.body) end"; + snippet.expand = + /* + lua + */ + '' + function(args) require('luasnip').lsp_expand(args.body) end + ''; # Completion Sources sources = [ { @@ -83,42 +103,47 @@ in { groupIndex = 1; } ]; - mapping = mkRaw '' - cmp.mapping.preset.insert({ - [""] = function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif require("luasnip").expand_or_jumpable() then - require("luasnip").expand_or_jump() - elseif has_words_before() then - cmp.complete() - else - fallback() - end - end, - [""] = function(fallback) - if cmp.visible() then - cmp.select_prev_item() - elseif require("luasnip").jumpable(-1) then - require("luasnip").jump(-1) - else - fallback() - end - end, - [""] = cmp.mapping(function(fallback) - if require("luasnip").choice_active() then - require("luasnip").next_choice() - else - fallback() - end - end), - [""] = cmp.mapping.scroll_docs(-4), - [""] = cmp.mapping.scroll_docs(4), - [""] = cmp.mapping.complete { }, - [""] = cmp.mapping.close(), - [""] = cmp.mapping.confirm { select = true }, - }) - ''; + mapping = + mkRaw + /* + lua + */ + '' + cmp.mapping.preset.insert({ + [""] = function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif require("luasnip").expand_or_jumpable() then + require("luasnip").expand_or_jump() + elseif has_words_before() then + cmp.complete() + else + fallback() + end + end, + [""] = function(fallback) + if cmp.visible() then + cmp.select_prev_item() + elseif require("luasnip").jumpable(-1) then + require("luasnip").jump(-1) + else + fallback() + end + end, + [""] = cmp.mapping(function(fallback) + if require("luasnip").choice_active() then + require("luasnip").next_choice() + else + fallback() + end + end), + [""] = cmp.mapping.scroll_docs(-4), + [""] = cmp.mapping.scroll_docs(4), + [""] = cmp.mapping.complete { }, + [""] = cmp.mapping.close(), + [""] = cmp.mapping.confirm { select = true }, + }) + ''; }; }; # FIXME: doesn't include formatters diff --git a/nvim/standalone.nix b/nvim/standalone.nix index 5f0fbf1..45c662d 100644 --- a/nvim/standalone.nix +++ b/nvim/standalone.nix @@ -55,37 +55,41 @@ pkgs.unstable.typos pkgs.unstable.yamlfmt ]; - extraConfigLuaPre = '' - -- Lua Pre Config - if vim.fn.has 'termguicolors' then - -- Enable RGB colors - vim.g.termguicolors = true - end + extraConfigLuaPre = + # lua + '' + -- Lua Pre Config + if vim.fn.has 'termguicolors' then + -- Enable RGB colors + vim.g.termguicolors = true + end - -- Useful function - local has_words_before = function() - -- unpack = unpack or table.unpack - local line, col = unpack(vim.api.nvim_win_get_cursor(0)) - return col ~= 0 - and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match '%s' == nil - end - -- END: Lua Pre Config - ''; - extraConfigLua = '' - -- Lua Config - require("nvim-silicon").setup { - theme = "gruvbox-dark", - pad_horiz = 16, - pad_vert = 16, - -- Current buffer name - window_title = function() - return vim.fn.fnamemodify( - vim.api.nvim_buf_get_name(vim.api.nvim_get_current_buf()), - ":t" - ) - end, - } - -- END: Lua Config - ''; + -- Useful function + local has_words_before = function() + -- unpack = unpack or table.unpack + local line, col = unpack(vim.api.nvim_win_get_cursor(0)) + return col ~= 0 + and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match '%s' == nil + end + -- END: Lua Pre Config + ''; + extraConfigLua = + # lua + '' + -- Lua Config + require("nvim-silicon").setup { + theme = "gruvbox-dark", + pad_horiz = 16, + pad_vert = 16, + -- Current buffer name + window_title = function() + return vim.fn.fnamemodify( + vim.api.nvim_buf_get_name(vim.api.nvim_get_current_buf()), + ":t" + ) + end, + } + -- END: Lua Config + ''; }; } -- 2.47.0