From 07dcfdaedb920572429142e8455ec2dc56bf01c5 Mon Sep 17 00:00:00 2001 From: zack Date: Tue, 8 Oct 2024 00:27:07 -0400 Subject: [PATCH] config lazyvim --- flake.lock | 38 ++--- .../apps/tools/neovim/config/lazyvim.json | 31 ++++ .../tools/neovim/config/lua/config/lazy.lua | 52 +++--- .../tools/neovim/config/lua/plugins/core.lua | 39 +++++ .../config/lua/plugins/extras/clangd.lua | 153 ++++++++++++++++++ .../neovim/config/lua/plugins/extras/rust.lua | 118 ++++++++++++++ modules/nixos/protocols/wayland/default.nix | 3 +- modules/nixos/ui/fonts/default.nix | 5 +- systems/x86_64-linux/earth/default.nix | 2 +- .../earth/hardware-configuration.nix | 2 +- 10 files changed, 391 insertions(+), 52 deletions(-) create mode 100644 modules/home/apps/tools/neovim/config/lazyvim.json create mode 100644 modules/home/apps/tools/neovim/config/lua/plugins/extras/clangd.lua create mode 100644 modules/home/apps/tools/neovim/config/lua/plugins/extras/rust.lua diff --git a/flake.lock b/flake.lock index d50386a..920a35f 100644 --- a/flake.lock +++ b/flake.lock @@ -709,11 +709,11 @@ "xdph": "xdph" }, "locked": { - "lastModified": 1728223706, - "narHash": "sha256-HrsylIpk+17wwsh/+sgUBmL7VHakF+EWv9v9Dx1268I=", + "lastModified": 1728303775, + "narHash": "sha256-+DykzTwUrLGOLHQdnWB1Wp0WIfBGhpqXoyTXdwIOoiY=", "ref": "refs/heads/main", - "rev": "4e41cda27ed4176005082436cb35878335e63fae", - "revCount": 5301, + "rev": "97444ed7a8a83406970fcc05907db1110435b59b", + "revCount": 5302, "submodules": true, "type": "git", "url": "https://github.com/hyprwm/Hyprland" @@ -1065,11 +1065,11 @@ }, "nixlib": { "locked": { - "lastModified": 1727571693, - "narHash": "sha256-b7sFVeqMtz8xntCL3tBY3O8suTg5PeF53LTL3eCcKyc=", + "lastModified": 1728176478, + "narHash": "sha256-px3Q0W//c+mZ4kPMXq4poztsjtXM1Ja1rN+825YMDUQ=", "owner": "nix-community", "repo": "nixpkgs.lib", - "rev": "bb58a3bf239e03fca9d51062e2fe028a4ea5a3d1", + "rev": "b61309c3c1b6013d36299bc8285612865b3b9e4c", "type": "github" }, "original": { @@ -1086,11 +1086,11 @@ ] }, "locked": { - "lastModified": 1727917377, - "narHash": "sha256-eefXdEPUMuhiV6Vy3ASSyApCseE9OoKDgL/G6qenw/4=", + "lastModified": 1728308313, + "narHash": "sha256-GThSJ4OcPOOtf8j8ge7ik4141BHVbBALu0N7Ju+Nw18=", "owner": "nix-community", "repo": "nixos-generators", - "rev": "9ae128172f823956e54947fe471bc6dfa670ecb4", + "rev": "71f9c8bcc87f15dba12515e94e40de243b5db103", "type": "github" }, "original": { @@ -1160,11 +1160,11 @@ }, "nixpkgs-unstable": { "locked": { - "lastModified": 1728217273, - "narHash": "sha256-p/gvyVf24WFs0bted3c71uSQk++ZOYRWbg3bjRoePu4=", + "lastModified": 1728249353, + "narHash": "sha256-7NBJm1jfMeAowE1J2oljYqWVvI9X7FyyxBY4O8uB/Os=", "owner": "nixos", "repo": "nixpkgs", - "rev": "50b3bd3fed0442bcbf7f58355e990da84af1749d", + "rev": "c8a17040be4a20b29589cb4043a9e0c36af1930e", "type": "github" }, "original": { @@ -1450,11 +1450,11 @@ "systems": "systems_12" }, "locked": { - "lastModified": 1728247562, - "narHash": "sha256-ovmRSqdZgwNIrbwenGAym7hXOexPgKsJoo7fta7CG3E=", + "lastModified": 1728305369, + "narHash": "sha256-CxUppOwq/RxEKJ26MP9g9/t5qn1WxKn6UQd039pQSMo=", "owner": "raphamorim", "repo": "rio", - "rev": "f27b9a1c1e0cb76be2eecfe59eb962912e5ea09e", + "rev": "b9d8879b5463cbe71a47cca6494d3fe0ec1c9485", "type": "github" }, "original": { @@ -1581,11 +1581,11 @@ ] }, "locked": { - "lastModified": 1728188225, - "narHash": "sha256-3Mf0XHpECwSxVDb7VYmiD7mqcMA3FcVVfqs3LLZHdaA=", + "lastModified": 1728274624, + "narHash": "sha256-auf6OnXvV8LiH/KvGIDmxUdhPeivGSxOHxrPvMHd+T4=", "owner": "Gerg-L", "repo": "spicetify-nix", - "rev": "f532f68a72549f8ee585aa2f6f7dbe9e2ce5a45c", + "rev": "4bcc76b94f01cfddc899191e99d96059b8702608", "type": "github" }, "original": { diff --git a/modules/home/apps/tools/neovim/config/lazyvim.json b/modules/home/apps/tools/neovim/config/lazyvim.json new file mode 100644 index 0000000..e009e9a --- /dev/null +++ b/modules/home/apps/tools/neovim/config/lazyvim.json @@ -0,0 +1,31 @@ +{ + "extras": [ + "lazyvim.plugins.extras.coding.mini-comment", + "lazyvim.plugins.extras.coding.yanky", + "lazyvim.plugins.extras.dap.core", + "lazyvim.plugins.extras.editor.dial", + "lazyvim.plugins.extras.editor.inc-rename", + "lazyvim.plugins.extras.lang.angular", + "lazyvim.plugins.extras.lang.astro", + "lazyvim.plugins.extras.lang.cmake", + "lazyvim.plugins.extras.lang.docker", + "lazyvim.plugins.extras.lang.haskell", + "lazyvim.plugins.extras.lang.java", + "lazyvim.plugins.extras.lang.json", + "lazyvim.plugins.extras.lang.markdown", + "lazyvim.plugins.extras.lang.nix", + "lazyvim.plugins.extras.lang.sql", + "lazyvim.plugins.extras.lang.svelte", + "lazyvim.plugins.extras.lang.tailwind", + "lazyvim.plugins.extras.lang.tex", + "lazyvim.plugins.extras.lang.typescript", + "lazyvim.plugins.extras.test.core", + "lazyvim.plugins.extras.util.dot", + "lazyvim.plugins.extras.util.mini-hipatterns", + "lazyvim.plugins.extras.coding.luasnip" + ], + "news": { + "NEWS.md": "6520" + }, + "version": 6 +} diff --git a/modules/home/apps/tools/neovim/config/lua/config/lazy.lua b/modules/home/apps/tools/neovim/config/lua/config/lazy.lua index 7833bd6..7f21316 100644 --- a/modules/home/apps/tools/neovim/config/lua/config/lazy.lua +++ b/modules/home/apps/tools/neovim/config/lua/config/lazy.lua @@ -3,32 +3,34 @@ require("lazy").setup({ -- add LazyVim and import its plugins { "LazyVim/LazyVim", import = "lazyvim.plugins" }, -- import/override with your plugins - { import = "lazyvim.plugins.extras.lang.rust" }, - { import = "lazyvim.plugins.extras.lang.json" }, - { import = "lazyvim.plugins.extras.lang.astro" }, - { import = "lazyvim.plugins.extras.lang.git" }, - { import = "lazyvim.plugins.extras.lang.docker" }, - { import = "lazyvim.plugins.extras.lang.clangd" }, - { import = "lazyvim.plugins.extras.lang.cmake" }, - { import = "lazyvim.plugins.extras.lang.haskell" }, - { import = "lazyvim.plugins.extras.lang.java" }, - { import = "lazyvim.plugins.extras.lang.markdown" }, - { import = "lazyvim.plugins.extras.lang.nix" }, - { import = "lazyvim.plugins.extras.lang.sql" }, - { import = "lazyvim.plugins.extras.lang.svelte" }, - { import = "lazyvim.plugins.extras.lang.tailwind" }, - { import = "lazyvim.plugins.extras.lang.tex" }, - { import = "lazyvim.plugins.extras.lang.typescript" }, - { import = "lazyvim.plugins.extras.lang.toml" }, - { import = "lazyvim.plugins.extras.lang.angular" }, - - { import = "lazyvim.plugins.extras.formatting.prettier" }, - - { import = "lazyvim.plugins.extras.coding.luasnip" }, - { import = "lazyvim.plugins.extras.coding.yanky" }, - - { import = "lazyvim.plugins.extras.dap.core" }, + -- { import = "lazyvim.plugins.extras.lang.rust" }, + -- { import = "lazyvim.plugins.extras.lang.json" }, + -- { import = "lazyvim.plugins.extras.lang.astro" }, + -- { import = "lazyvim.plugins.extras.lang.git" }, + -- { import = "lazyvim.plugins.extras.lang.docker" }, + -- { import = "lazyvim.plugins.extras.lang.clangd" }, + -- { import = "lazyvim.plugins.extras.lang.cmake" }, + -- { import = "lazyvim.plugins.extras.lang.haskell" }, + -- { import = "lazyvim.plugins.extras.lang.java" }, + -- { import = "lazyvim.plugins.extras.lang.markdown" }, + -- { import = "lazyvim.plugins.extras.lang.nix" }, + -- { import = "lazyvim.plugins.extras.lang.sql" }, + -- { import = "lazyvim.plugins.extras.lang.svelte" }, + -- { import = "lazyvim.plugins.extras.lang.tailwind" }, + -- { import = "lazyvim.plugins.extras.lang.tex" }, + -- { import = "lazyvim.plugins.extras.lang.typescript" }, + -- { import = "lazyvim.plugins.extras.lang.toml" }, + -- { import = "lazyvim.plugins.extras.lang.angular" }, + -- + -- { import = "lazyvim.plugins.extras.formatting.prettier" }, + -- + -- { import = "lazyvim.plugins.extras.coding.luasnip" }, + -- { import = "lazyvim.plugins.extras.coding.yanky" }, + -- + -- { import = "lazyvim.plugins.extras.dap.core" }, { import = "plugins" }, + { import = "plugins.extras.rust" }, + -- { import = "plugins.extras.clangd" }, }, defaults = { -- By default, only LazyVim plugins will be lazy-loaded. Your custom plugins will load during startup. diff --git a/modules/home/apps/tools/neovim/config/lua/plugins/core.lua b/modules/home/apps/tools/neovim/config/lua/plugins/core.lua index 1d1ccd1..bd0a97f 100644 --- a/modules/home/apps/tools/neovim/config/lua/plugins/core.lua +++ b/modules/home/apps/tools/neovim/config/lua/plugins/core.lua @@ -13,4 +13,43 @@ return { }, }, }, + -- { + -- "saghen/blink.cmp", + -- lazy = false, -- lazy loading handled internally + -- -- optional: provides snippets for the snippet source + -- dependencies = "rafamadriz/friendly-snippets", + -- + -- -- use a release tag to download pre-built binaries + -- version = "v0.*", + -- -- OR build from source, requires nightly: https://rust-lang.github.io/rustup/concepts/channels.html#working-with-nightly-rust + -- -- build = 'cargo build --release', + -- + -- opts = { + -- keymap = { + -- show = "", + -- accept = "", + -- select_prev = { "", "" }, + -- select_next = { "", "" }, + -- + -- snippet_forward = "", + -- snippet_backward = "", + -- }, + -- + -- highlight = { + -- -- sets the fallback highlight groups to nvim-cmp's highlight groups + -- -- useful for when your theme doesn't support blink.cmp + -- -- will be removed in a future release, assuming themes add support + -- use_nvim_cmp_as_default = true, + -- }, + -- -- set to 'mono' for 'Nerd Font Mono' or 'normal' for 'Nerd Font' + -- -- adjusts spacing to ensure icons are aligned + -- nerd_font_variant = "normal", + -- + -- -- experimental auto-brackets support + -- -- accept = { auto_brackets = { enabled = true } } + -- + -- -- experimental signature help support + -- -- trigger = { signature_help = { enabled = true } } + -- }, + -- }, } diff --git a/modules/home/apps/tools/neovim/config/lua/plugins/extras/clangd.lua b/modules/home/apps/tools/neovim/config/lua/plugins/extras/clangd.lua new file mode 100644 index 0000000..ac1bb06 --- /dev/null +++ b/modules/home/apps/tools/neovim/config/lua/plugins/extras/clangd.lua @@ -0,0 +1,153 @@ +return { + recommended = function() + return LazyVim.extras.wants({ + ft = { "c", "cpp", "objc", "objcpp", "cuda", "proto" }, + root = { + ".clangd", + ".clang-tidy", + ".clang-format", + "compile_commands.json", + "compile_flags.txt", + "configure.ac", -- AutoTools + }, + }) + end, + + -- Add C/C++ to treesitter + { + "nvim-treesitter/nvim-treesitter", + opts = { ensure_installed = { "cpp" } }, + }, + + { + "p00f/clangd_extensions.nvim", + lazy = true, + config = function() end, + opts = { + inlay_hints = { + inline = false, + }, + ast = { + --These require codicons (https://github.com/microsoft/vscode-codicons) + role_icons = { + type = "", + declaration = "", + expression = "", + specifier = "", + statement = "", + ["template argument"] = "", + }, + kind_icons = { + Compound = "", + Recovery = "", + TranslationUnit = "", + PackExpansion = "", + TemplateTypeParm = "", + TemplateTemplateParm = "", + TemplateParamObject = "", + }, + }, + }, + }, + + -- Correctly setup lspconfig for clangd 🚀 + { + "neovim/nvim-lspconfig", + opts = { + servers = { + -- Ensure mason installs the server + clangd = { + keys = { + { "ch", "ClangdSwitchSourceHeader", desc = "Switch Source/Header (C/C++)" }, + }, + root_dir = function(fname) + return require("lspconfig.util").root_pattern( + "Makefile", + "configure.ac", + "configure.in", + "config.h.in", + "meson.build", + "meson_options.txt", + "build.ninja" + )(fname) or require("lspconfig.util").root_pattern("compile_commands.json", "compile_flags.txt")( + fname + ) or require("lspconfig.util").find_git_ancestor(fname) + end, + capabilities = { + offsetEncoding = { "utf-16" }, + }, + cmd = { + "clangd", + "--background-index", + "--clang-tidy", + "--header-insertion=iwyu", + "--completion-style=detailed", + "--function-arg-placeholders", + "--fallback-style=llvm", + }, + init_options = { + usePlaceholders = true, + completeUnimported = true, + clangdFileStatus = true, + }, + }, + }, + setup = { + clangd = function(_, opts) + local clangd_ext_opts = LazyVim.opts("clangd_extensions.nvim") + require("clangd_extensions").setup(vim.tbl_deep_extend("force", clangd_ext_opts or {}, { server = opts })) + return false + end, + }, + }, + }, + + { + "nvim-cmp", + opts = function(_, opts) + table.insert(opts.sorting.comparators, 1, require("clangd_extensions.cmp_scores")) + end, + }, + + { + "mfussenegger/nvim-dap", + optional = true, + opts = function() + local dap = require("dap") + if not dap.adapters["codelldb"] then + require("dap").adapters["codelldb"] = { + type = "server", + host = "localhost", + port = "${port}", + executable = { + command = "codelldb", + args = { + "--port", + "${port}", + }, + }, + } + end + for _, lang in ipairs({ "c", "cpp" }) do + dap.configurations[lang] = { + { + type = "codelldb", + request = "launch", + name = "Launch file", + program = function() + return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file") + end, + cwd = "${workspaceFolder}", + }, + { + type = "codelldb", + request = "attach", + name = "Attach to process", + pid = require("dap.utils").pick_process, + cwd = "${workspaceFolder}", + }, + } + end + end, + }, +} diff --git a/modules/home/apps/tools/neovim/config/lua/plugins/extras/rust.lua b/modules/home/apps/tools/neovim/config/lua/plugins/extras/rust.lua new file mode 100644 index 0000000..d1da5b2 --- /dev/null +++ b/modules/home/apps/tools/neovim/config/lua/plugins/extras/rust.lua @@ -0,0 +1,118 @@ +return { + recommended = function() + return LazyVim.extras.wants({ + ft = "rust", + root = { "Cargo.toml", "rust-project.json" }, + }) + end, + + -- Extend auto completion + { + "hrsh7th/nvim-cmp", + dependencies = { + { + "Saecki/crates.nvim", + event = { "BufRead Cargo.toml" }, + opts = { + completion = { + cmp = { enabled = true }, + }, + }, + }, + }, + ---@param opts cmp.ConfigSchema + opts = function(_, opts) + opts.sources = opts.sources or {} + table.insert(opts.sources, { name = "crates" }) + end, + }, + + -- Add Rust & related to treesitter + { + "nvim-treesitter/nvim-treesitter", + opts = { ensure_installed = { "rust", "ron" } }, + }, + + { + "mrcjkb/rustaceanvim", + version = vim.fn.has("nvim-0.10.0") == 0 and "^4" or false, + ft = { "rust" }, + opts = { + server = { + on_attach = function(_, bufnr) + vim.keymap.set("n", "cR", function() + vim.cmd.RustLsp("codeAction") + end, { desc = "Code Action", buffer = bufnr }) + vim.keymap.set("n", "dr", function() + vim.cmd.RustLsp("debuggables") + end, { desc = "Rust Debuggables", buffer = bufnr }) + end, + default_settings = { + -- rust-analyzer language server configuration + ["rust-analyzer"] = { + cargo = { + allFeatures = true, + loadOutDirsFromCheck = true, + buildScripts = { + enable = true, + }, + }, + -- Add clippy lints for Rust. + checkOnSave = true, + procMacro = { + enable = true, + ignored = { + ["async-trait"] = { "async_trait" }, + ["napi-derive"] = { "napi" }, + ["async-recursion"] = { "async_recursion" }, + }, + }, + }, + }, + }, + }, + config = function(_, opts) + vim.g.rustaceanvim = vim.tbl_deep_extend("keep", vim.g.rustaceanvim or {}, opts or {}) + if vim.fn.executable("rust-analyzer") == 0 then + LazyVim.error( + "**rust-analyzer** not found in PATH, please install it.\nhttps://rust-analyzer.github.io/", + { title = "rustaceanvim" } + ) + end + end, + }, + + -- Correctly setup lspconfig for Rust 🚀 + { + "neovim/nvim-lspconfig", + opts = { + servers = { + taplo = { + keys = { + { + "K", + function() + if vim.fn.expand("%:t") == "Cargo.toml" and require("crates").popup_available() then + require("crates").show_popup() + else + vim.lsp.buf.hover() + end + end, + desc = "Show Crate Documentation", + }, + }, + }, + }, + }, + }, + + { + "nvim-neotest/neotest", + optional = true, + opts = { + adapters = { + ["rustaceanvim.neotest"] = {}, + }, + }, + }, +} diff --git a/modules/nixos/protocols/wayland/default.nix b/modules/nixos/protocols/wayland/default.nix index 2abbff6..0f7516c 100644 --- a/modules/nixos/protocols/wayland/default.nix +++ b/modules/nixos/protocols/wayland/default.nix @@ -72,8 +72,7 @@ in { extraPortals = [ pkgs.xdg-desktop-portal-gtk pkgs.xdg-desktop-portal-wlr - # inputs.hyprland.packages.${pkgs.system}.xdg-desktop-portal-hyprland - pkgs.xdg-desktop-portal-hyprland + inputs.hyprland.packages.${pkgs.system}.xdg-desktop-portal-hyprland pkgs.xwaylandvideobridge ]; }; diff --git a/modules/nixos/ui/fonts/default.nix b/modules/nixos/ui/fonts/default.nix index 340de17..888cbfa 100644 --- a/modules/nixos/ui/fonts/default.nix +++ b/modules/nixos/ui/fonts/default.nix @@ -40,10 +40,7 @@ in { exportGlyphNames = true [buildPlans.IosevkaCustom.variants] - inherits = "ss20" - - [buildPlans.IosevkaCustom.variants.design] - one = "base-flat-top-serif" + inherits = "ss03" ''; }) noto-fonts diff --git a/systems/x86_64-linux/earth/default.nix b/systems/x86_64-linux/earth/default.nix index 8c29a1e..faf8f7c 100644 --- a/systems/x86_64-linux/earth/default.nix +++ b/systems/x86_64-linux/earth/default.nix @@ -26,7 +26,7 @@ hardware.audio.enable = true; hardware.nvidia.enable = true; - nprograms.nix-ld.enable = true; + programs.nix-ld.enable = true; programs.steam.enable = true; programs.steam.gamescopeSession.enable = true; diff --git a/systems/x86_64-linux/earth/hardware-configuration.nix b/systems/x86_64-linux/earth/hardware-configuration.nix index 20fbb46..f805281 100644 --- a/systems/x86_64-linux/earth/hardware-configuration.nix +++ b/systems/x86_64-linux/earth/hardware-configuration.nix @@ -27,7 +27,7 @@ fsType = "vfat"; }; - fileSystems."/mnt/lul/" = { + fileSystems."/mnt/lul" = { device = "/dev/disk/by-partuuid/2b7f6948-57a6-4fef-a931-b3aa962faee3"; fsType = "ntfs-3g"; };