From ac7f8ef19b645af5afe8f5f8044868a0cf25a620 Mon Sep 17 00:00:00 2001 From: Nathan Reiner Date: Sat, 28 Sep 2024 15:17:50 +0200 Subject: nixvim: refactor --- common/default.nix | 7 +- common/home/default.nix | 1 + common/home/hyprland/default.nix | 27 ++- common/home/programs/nixvim/default.nix | 195 +-------------------- common/home/programs/nixvim/plugins/cmp.nix | 45 +++++ common/home/programs/nixvim/plugins/dashboard.nix | 68 +++++++ common/home/programs/nixvim/plugins/default.nix | 27 +++ .../programs/nixvim/plugins/friendly-snippets.nix | 4 + common/home/programs/nixvim/plugins/lsp-format.nix | 4 + common/home/programs/nixvim/plugins/lsp.nix | 39 +++++ common/home/programs/nixvim/plugins/lualine.nix | 4 + common/home/programs/nixvim/plugins/luasnip.nix | 4 + common/home/programs/nixvim/plugins/nvim-tree.nix | 7 + common/home/programs/nixvim/plugins/telescope.nix | 4 + common/home/programs/nixvim/plugins/treesitter.nix | 24 +++ common/home/programs/waybar/default.nix | 1 + common/home/programs/waybar/style.css | 5 +- flake.lock | 48 ++--- 18 files changed, 289 insertions(+), 225 deletions(-) create mode 100644 common/home/programs/nixvim/plugins/cmp.nix create mode 100644 common/home/programs/nixvim/plugins/dashboard.nix create mode 100644 common/home/programs/nixvim/plugins/default.nix create mode 100644 common/home/programs/nixvim/plugins/friendly-snippets.nix create mode 100644 common/home/programs/nixvim/plugins/lsp-format.nix create mode 100644 common/home/programs/nixvim/plugins/lsp.nix create mode 100644 common/home/programs/nixvim/plugins/lualine.nix create mode 100644 common/home/programs/nixvim/plugins/luasnip.nix create mode 100644 common/home/programs/nixvim/plugins/nvim-tree.nix create mode 100644 common/home/programs/nixvim/plugins/telescope.nix create mode 100644 common/home/programs/nixvim/plugins/treesitter.nix diff --git a/common/default.nix b/common/default.nix index 8baaf5c..382c38a 100644 --- a/common/default.nix +++ b/common/default.nix @@ -46,8 +46,11 @@ inherit config; }; - security.pam.services.hyprlock = { }; - security.rtkit.enable = true; + security = { + pam.services.hyprlock = { }; + rtkit.enable = true; + sudo.wheelNeedsPassword = false; + }; hardware.bluetooth.enable = true; diff --git a/common/home/default.nix b/common/home/default.nix index 44b562c..10b10cd 100644 --- a/common/home/default.nix +++ b/common/home/default.nix @@ -42,6 +42,7 @@ let pkgs.wev pkgs.signal-desktop pkgs.unzip + pkgs.sway-contrib.grimshot ]; in { diff --git a/common/home/hyprland/default.nix b/common/home/hyprland/default.nix index 0cef02b..fdab85c 100644 --- a/common/home/hyprland/default.nix +++ b/common/home/hyprland/default.nix @@ -8,14 +8,18 @@ settings = { "$mod" = "SUPER"; bind = [ - "$mod+Shift, Return, exec, alacritty" "$mod+Shift, Q, exit" + "$mod, C, killactive," + + "$mod, Escape, exec, hyprlock" + "$mod, Space, exec, wofi --show run" + + "$mod+Shift, Return, exec, alacritty" "$mod+Shift, B, exec, firefox" "$mod+Shift, P, exec, wofi-pass" "$mod+Shift, O, exec, wofi-pass otp" - "$mod, Escape, exec, hyprlock" - "$mod, Space, exec, wofi --show run" - "$mod, C, killactive," + + ", Print, exec, grimshot copy area" "$mod, h, movefocus, l" "$mod, l, movefocus, r" @@ -38,6 +42,10 @@ "$mod, 9, workspace, 9" "$mod, 0, workspace, 10" + "$mod, F1, movecurrentworkspacetomonitor, 0" + "$mod, F2, movecurrentworkspacetomonitor, 1" + "$mod, F3, movecurrentworkspacetomonitor, 2" + "$mod+Shift, 1, movetoworkspace, 1" "$mod+Shift, 2, movetoworkspace, 2" "$mod+Shift, 3, movetoworkspace, 3" @@ -55,12 +63,23 @@ "$mod, comma, resizeactive, -20 0" "$mod+Shift, period, resizeactive, 0 20" "$mod+Shift, comma, resizeactive, 0 -20" + + ", XF86AudioMute, exec, wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle" + ", XF86AudioRaiseVolume, exec, wpctl set-volume -l 1.5 @DEFAULT_AUDIO_SINK@ 5%+" + ", XF86AudioLowerVolume, exec, wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-" + ", XF86AudioPlay, exec, playerctl play-pause" + + ", XF86MonBrightnessDown, exec, brightnessctl set 10%-" + ", XF86MonBrightnessUp, exec, brightnessctl set +10%" ]; general = { gaps_in = 10; gaps_out = 10; layout = "dwindle"; + border_size = 3; + "col.active_border" = "rgba(b16286ff)"; + "col.inactive_border" = "rgba(3c3836ff)"; }; decoration = { diff --git a/common/home/programs/nixvim/default.nix b/common/home/programs/nixvim/default.nix index 80de5a1..f8ec8c6 100644 --- a/common/home/programs/nixvim/default.nix +++ b/common/home/programs/nixvim/default.nix @@ -54,200 +54,7 @@ colorscheme = "gruvbox-dark-pale"; }; - plugins = { - web-devicons.enable = true; - - dashboard = { - enable = true; - settings = { - change_to_vcs_root = true; - config = { - footer = [ "" ]; - - header = [ - "███╗ ██╗ ███████╗ ██████╗ ██╗ ██╗ ██╗ ███╗ ███╗" - "████╗ ██║ ██╔════╝██╔═══██╗ ██║ ██║ ██║ ████╗ ████║" - "██╔██╗ ██║ █████╗ ██║ ██║ ██║ ██║ ██║ ██╔████╔██║" - "██║╚██╗██║ ██╔══╝ ██║ ██║ ╚██╗ ██╔╝ ██║ ██║╚██╔╝██║" - "██║ ╚████║ ███████╗╚██████╔╝ ╚████╔╝ ██║ ██║ ╚═╝ ██║" - "╚═╝ ╚═══╝ ╚══════╝ ╚═════╝ ╚═══╝ ╚═╝ ╚═╝ ╚═╝" - ]; - - mru = { - limit = 10; - }; - - project = { - enable = true; - }; - - packages.enable = false; - - shortcut = [ - { - action = { - __raw = '' - function(path) - vim.cmd('Telescope find_files') - end - ''; - }; - desc = "Files"; - group = "Label"; - icon = " "; - icon_hl = "@variable"; - key = "f"; - } - { - action = { - __raw = '' - function() - vim.cmd('cd ~/global/system/config'); vim.cmd('Telescope find_files') - end - ''; - }; - icon = "󱄅 "; - icon_hl = "@variable"; - desc = "System Config"; - group = "Number"; - key = "c"; - } - ]; - - hide = [ - "statusline" - "tabline" - "winbar" - ]; - }; - theme = "hyper"; - }; - }; - - nvim-tree = { - enable = true; - autoClose = true; - disableNetrw = true; - hijackCursor = true; - }; - - telescope = { - enable = true; - }; - - lualine = { - enable = true; - }; - - treesitter = { - enable = true; - settings = { - auto_install = true; - highlight = { - additional_vim_regex_highlighting = true; - enable = true; - }; - incremental_selection = { - enable = true; - keymaps = { - init_selection = false; - node_decremental = "grm"; - node_incremental = "grn"; - scope_incremental = "grc"; - }; - }; - indent = { - enable = true; - }; - sync_install = false; - }; - }; - - luasnip = { - enable = true; - }; - - friendly-snippets = { - enable = true; - }; - - cmp = { - enable = true; - autoEnableSources = true; - settings = { - mapping = { - "" = "cmp.mapping.scroll_docs(-4)"; - "" = "cmp.mapping.scroll_docs(4)"; - "" = "cmp.mapping.complete()"; - "" = "cmp.mapping.abort()"; - "" = "cmp.mapping.confirm({ select = true })"; - "" = '' - cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - else - fallback() - end - end, { "i", "s" }) - ''; - "" = '' - cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_prev_item() - else - fallback() - end - end, { "i", "s" }) - ''; - }; - snippet = { - expand = "function(args) require('luasnip').lsp_expand(args.body) end"; - }; - sources = [ - { name = "nvim_lsp"; } - { name = "luasnip"; } - { name = "path"; } - { name = "buffer"; } - ]; - }; - }; - - lsp = { - enable = true; - servers = { - bashls = { - enable = true; - package = pkgs.unstable.bash-language-server; - }; - clangd.enable = true; - nixd = { - enable = true; - settings.formatting.command = [ "nixfmt" ]; - }; - rust-analyzer = { - enable = true; - installCargo = true; - installRustc = true; - }; - pyright.enable = true; - ocamllsp.enable = true; - }; - keymaps.lspBuf = { - "gd" = "definition"; - "gD" = "references"; - "gt" = "type_definition"; - "gi" = "implementation"; - "K" = "hover"; - "rn" = "rename"; - "ca" = "code_action"; - "f" = "format"; - }; - }; - - lsp-format = { - enable = true; - }; - }; + plugins = import ./plugins/default.nix; globals = { mapleader = ","; diff --git a/common/home/programs/nixvim/plugins/cmp.nix b/common/home/programs/nixvim/plugins/cmp.nix new file mode 100644 index 0000000..27cca04 --- /dev/null +++ b/common/home/programs/nixvim/plugins/cmp.nix @@ -0,0 +1,45 @@ +{ ... }: +{ + enable = true; + autoEnableSources = true; + settings = { + mapping = { + "" = "cmp.mapping.scroll_docs(-4)"; + "" = "cmp.mapping.scroll_docs(4)"; + "" = "cmp.mapping.complete()"; + "" = "cmp.mapping.abort()"; + "" = "cmp.mapping.confirm({ select = true })"; + "" = '' + cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + else + fallback() + end + end, { "i", "s" }) + ''; + "" = '' + cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_prev_item() + else + fallback() + end + end, { "i", "s" }) + ''; + }; + snippet = { + expand = '' + function(args) + require('luasnip').lsp_expand(args.body) + end + ''; + }; + sources = [ + { name = "nvim_lsp"; } + { name = "luasnip"; } + { name = "path"; } + { name = "buffer"; } + ]; + }; +} diff --git a/common/home/programs/nixvim/plugins/dashboard.nix b/common/home/programs/nixvim/plugins/dashboard.nix new file mode 100644 index 0000000..77a9f3e --- /dev/null +++ b/common/home/programs/nixvim/plugins/dashboard.nix @@ -0,0 +1,68 @@ +{ ... }: +{ + enable = true; + settings = { + change_to_vcs_root = true; + config = { + footer = [ "" ]; + + header = [ + "███╗ ██╗ ███████╗ ██████╗ ██╗ ██╗ ██╗ ███╗ ███╗" + "████╗ ██║ ██╔════╝██╔═══██╗ ██║ ██║ ██║ ████╗ ████║" + "██╔██╗ ██║ █████╗ ██║ ██║ ██║ ██║ ██║ ██╔████╔██║" + "██║╚██╗██║ ██╔══╝ ██║ ██║ ╚██╗ ██╔╝ ██║ ██║╚██╔╝██║" + "██║ ╚████║ ███████╗╚██████╔╝ ╚████╔╝ ██║ ██║ ╚═╝ ██║" + "╚═╝ ╚═══╝ ╚══════╝ ╚═════╝ ╚═══╝ ╚═╝ ╚═╝ ╚═╝" + ]; + + mru = { + limit = 10; + }; + + project = { + enable = true; + }; + + packages.enable = false; + + shortcut = [ + { + action = { + __raw = '' + function(path) + vim.cmd('Telescope find_files') + end + ''; + }; + desc = "Files"; + group = "Label"; + icon = " "; + icon_hl = "@variable"; + key = "f"; + } + { + action = { + __raw = '' + function() + vim.cmd('cd ~/global/system/config'); vim.cmd('Telescope find_files') + end + ''; + }; + icon = "󱄅 "; + icon_hl = "@variable"; + desc = "System Config"; + group = "Number"; + key = "c"; + } + ]; + + hide = [ + "statusline" + "tabline" + "winbar" + ]; + }; + theme = "hyper"; + }; + }; + diff --git a/common/home/programs/nixvim/plugins/default.nix b/common/home/programs/nixvim/plugins/default.nix new file mode 100644 index 0000000..6005c57 --- /dev/null +++ b/common/home/programs/nixvim/plugins/default.nix @@ -0,0 +1,27 @@ +{ pkgs, ... }: +let + plugins = [ + "web-devicons" + "dashboard" + "nvim-tree" + "telescope" + "lualine" + "treesitter" + "luasnip" + "friendly-snippets" + "cmp" + "lsp" + ]; +in +{ + plugins = builtins.listToAttrs ( + map (n: { + name = n; + value = + if builtins.pathExists ./${n}.nix then + (import ./${n}.nix { inherit pkgs; }) + else + { enable = true; }; + }) plugins + ); +} diff --git a/common/home/programs/nixvim/plugins/friendly-snippets.nix b/common/home/programs/nixvim/plugins/friendly-snippets.nix new file mode 100644 index 0000000..3887830 --- /dev/null +++ b/common/home/programs/nixvim/plugins/friendly-snippets.nix @@ -0,0 +1,4 @@ +{ ... }: +{ + enable = true; +} diff --git a/common/home/programs/nixvim/plugins/lsp-format.nix b/common/home/programs/nixvim/plugins/lsp-format.nix new file mode 100644 index 0000000..3887830 --- /dev/null +++ b/common/home/programs/nixvim/plugins/lsp-format.nix @@ -0,0 +1,4 @@ +{ ... }: +{ + enable = true; +} diff --git a/common/home/programs/nixvim/plugins/lsp.nix b/common/home/programs/nixvim/plugins/lsp.nix new file mode 100644 index 0000000..578518f --- /dev/null +++ b/common/home/programs/nixvim/plugins/lsp.nix @@ -0,0 +1,39 @@ +{ pkgs, ... }: +{ + enable = true; + servers = { + + bashls = { + enable = true; + package = pkgs.unstable.bash-language-server; + }; + + clangd.enable = true; + + nixd = { + enable = true; + settings.formatting.command = [ "nixfmt" ]; + }; + + rust-analyzer = { + enable = true; + installCargo = true; + installRustc = true; + }; + + pyright.enable = true; + + ocamllsp.enable = true; + }; + + keymaps.lspBuf = { + "gd" = "definition"; + "gD" = "references"; + "gt" = "type_definition"; + "gi" = "implementation"; + "K" = "hover"; + "rn" = "rename"; + "ca" = "code_action"; + "f" = "format"; + }; +} diff --git a/common/home/programs/nixvim/plugins/lualine.nix b/common/home/programs/nixvim/plugins/lualine.nix new file mode 100644 index 0000000..3887830 --- /dev/null +++ b/common/home/programs/nixvim/plugins/lualine.nix @@ -0,0 +1,4 @@ +{ ... }: +{ + enable = true; +} diff --git a/common/home/programs/nixvim/plugins/luasnip.nix b/common/home/programs/nixvim/plugins/luasnip.nix new file mode 100644 index 0000000..3887830 --- /dev/null +++ b/common/home/programs/nixvim/plugins/luasnip.nix @@ -0,0 +1,4 @@ +{ ... }: +{ + enable = true; +} diff --git a/common/home/programs/nixvim/plugins/nvim-tree.nix b/common/home/programs/nixvim/plugins/nvim-tree.nix new file mode 100644 index 0000000..dbd3256 --- /dev/null +++ b/common/home/programs/nixvim/plugins/nvim-tree.nix @@ -0,0 +1,7 @@ +{ ... }: +{ + enable = true; + autoClose = true; + disableNetrw = true; + hijackCursor = true; +} diff --git a/common/home/programs/nixvim/plugins/telescope.nix b/common/home/programs/nixvim/plugins/telescope.nix new file mode 100644 index 0000000..3887830 --- /dev/null +++ b/common/home/programs/nixvim/plugins/telescope.nix @@ -0,0 +1,4 @@ +{ ... }: +{ + enable = true; +} diff --git a/common/home/programs/nixvim/plugins/treesitter.nix b/common/home/programs/nixvim/plugins/treesitter.nix new file mode 100644 index 0000000..3fbd4b6 --- /dev/null +++ b/common/home/programs/nixvim/plugins/treesitter.nix @@ -0,0 +1,24 @@ +{ ... }: +{ + enable = true; + settings = { + auto_install = true; + highlight = { + additional_vim_regex_highlighting = true; + enable = true; + }; + incremental_selection = { + enable = true; + keymaps = { + init_selection = false; + node_decremental = "grm"; + node_incremental = "grn"; + scope_incremental = "grc"; + }; + }; + indent = { + enable = true; + }; + sync_install = false; + }; +} diff --git a/common/home/programs/waybar/default.nix b/common/home/programs/waybar/default.nix index c6b03e1..d02decb 100644 --- a/common/home/programs/waybar/default.nix +++ b/common/home/programs/waybar/default.nix @@ -13,6 +13,7 @@ modules-center = [ ]; modules-right = [ "bluetooth" + "pulseaudio" "battery" "tray" ]; diff --git a/common/home/programs/waybar/style.css b/common/home/programs/waybar/style.css index a676040..99dc06b 100644 --- a/common/home/programs/waybar/style.css +++ b/common/home/programs/waybar/style.css @@ -38,7 +38,10 @@ window { padding: 0px; } -#tray, #bluetooth { +#tray, +#bluetooth, +#pulseaudio +{ background: #282828; border-radius: 5px; margin-left: 10px; diff --git a/flake.lock b/flake.lock index da89ade..bbb1222 100644 --- a/flake.lock +++ b/flake.lock @@ -91,11 +91,11 @@ ] }, "locked": { - "lastModified": 1726745158, - "narHash": "sha256-D5AegvGoEjt4rkKedmxlSEmC+nNLMBPWFxvmYnVLhjk=", + "lastModified": 1727514110, + "narHash": "sha256-0YRcOxJG12VGDFH8iS8pJ0aYQQUAgo/r3ZAL+cSh9nk=", "owner": "cachix", "repo": "git-hooks.nix", - "rev": "4e743a6920eab45e8ba0fbe49dc459f1423a4b74", + "rev": "85f7a7177c678de68224af3402ab8ee1bcee25c8", "type": "github" }, "original": { @@ -155,11 +155,11 @@ ] }, "locked": { - "lastModified": 1726985855, - "narHash": "sha256-NJPGK030Y3qETpWBhj9oobDQRbXdXOPxtu+YgGvZ84o=", + "lastModified": 1727383923, + "narHash": "sha256-4/vacp3CwdGoPf8U4e/N8OsGYtO09WTcQK5FqYfJbKs=", "owner": "nix-community", "repo": "home-manager", - "rev": "04213d1ce4221f5d9b40bcee30706ce9a91d148d", + "rev": "ffe2d07e771580a005e675108212597e5b367d2d", "type": "github" }, "original": { @@ -176,11 +176,11 @@ ] }, "locked": { - "lastModified": 1727003835, - "narHash": "sha256-Cfllbt/ADfO8oxbT984MhPHR6FJBaglsr1SxtDGbpec=", + "lastModified": 1727507295, + "narHash": "sha256-I/FrX1peu4URoj5T5odfuKR2rm4GjYJJpCGF9c0/lDA=", "owner": "lnl7", "repo": "nix-darwin", - "rev": "bd7d1e3912d40f799c5c0f7e5820ec950f1e0b3d", + "rev": "f2e1c4aa29fc211947c3a7113cba1dd707433b70", "type": "github" }, "original": { @@ -191,11 +191,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1727129439, - "narHash": "sha256-nPyrcFm6FSk7CxzVW4x2hu62aLDghNcv9dX6DF3dXw8=", + "lastModified": 1727397532, + "narHash": "sha256-pojbL/qteElw/nIXlN8kmHn/w6PQbEHr7Iz+WOXs0EM=", "owner": "nixos", "repo": "nixpkgs", - "rev": "babc25a577c3310cce57c72d5bed70f4c3c3843a", + "rev": "f65141456289e81ea0d5a05af8898333cab5c53d", "type": "github" }, "original": { @@ -207,11 +207,11 @@ }, "nixpkgs-unstable": { "locked": { - "lastModified": 1726937504, - "narHash": "sha256-bvGoiQBvponpZh8ClUcmJ6QnsNKw0EMrCQJARK3bI1c=", + "lastModified": 1727348695, + "narHash": "sha256-J+PeFKSDV+pHL7ukkfpVzCOO7mBSrrpJ3svwBFABbhI=", "owner": "nixos", "repo": "nixpkgs", - "rev": "9357f4f23713673f310988025d9dc261c20e70c6", + "rev": "1925c603f17fc89f4c8f6bf6f631a802ad85d784", "type": "github" }, "original": { @@ -236,11 +236,11 @@ "treefmt-nix": "treefmt-nix" }, "locked": { - "lastModified": 1727286212, - "narHash": "sha256-iab+k8m6+MBkwQoyqMcMYggwILHCkMSkgNYd1GN0FbM=", + "lastModified": 1727515394, + "narHash": "sha256-4BPyE2P+QdXKNOE6sz5exRNOgLZW4J7tH11uk3qzWf8=", "owner": "nix-community", "repo": "nixvim", - "rev": "7bda0f1ce49e9da252bcee20b5f700e6dcd3cf8d", + "rev": "f9dcd86caefab831dc0c0612305772d31694a93e", "type": "github" }, "original": { @@ -258,11 +258,11 @@ ] }, "locked": { - "lastModified": 1726995581, - "narHash": "sha256-lgsE/CTkZk9OIiFGEIrxXZQ7Feiv41dqlN7pEfTdgew=", + "lastModified": 1727452028, + "narHash": "sha256-ehl/A4HQFRyqj1Fk7cl+dgSf/2Fb1jLwWJtZaMU6RfU=", "owner": "NuschtOS", "repo": "search", - "rev": "3b7dd61b365ca45380707453758a45f2e9977be3", + "rev": "9f7426e532ef8dfc839c4a3fcc567b13a20a70d3", "type": "github" }, "original": { @@ -304,11 +304,11 @@ ] }, "locked": { - "lastModified": 1726734507, - "narHash": "sha256-VUH5O5AcOSxb0uL/m34dDkxFKP6WLQ6y4I1B4+N3L2w=", + "lastModified": 1727431250, + "narHash": "sha256-uGRlRT47ecicF9iLD1G3g43jn2e+b5KaMptb59LHnvM=", "owner": "numtide", "repo": "treefmt-nix", - "rev": "ee41a466c2255a3abe6bc50fc6be927cdee57a9f", + "rev": "879b29ae9a0378904fbbefe0dadaed43c8905754", "type": "github" }, "original": { -- cgit v1.2.3-70-g09d2