From f975867a81791d84965f4d663b89a986273e6563 Mon Sep 17 00:00:00 2001 From: Emmet Date: Sat, 14 Sep 2024 13:29:42 -0500 Subject: [PATCH 1/2] Updated system and learning nvim/nvchad --- flake.lock | 60 ++++++++++++++++++++++++++---------------- flake.nix | 5 ++++ profiles/work/home.nix | 5 ++-- user/app/nvim/nvim.nix | 10 +++++++ 4 files changed, 55 insertions(+), 25 deletions(-) create mode 100644 user/app/nvim/nvim.nix diff --git a/flake.lock b/flake.lock index fb8abc2..30de9c3 100644 --- a/flake.lock +++ b/flake.lock @@ -150,11 +150,11 @@ "blocklist-hosts": { "flake": false, "locked": { - "lastModified": 1725674607, - "narHash": "sha256-vTaoz2yRd9g3NZNKYufZeB8UJ381aBPmRV91lEmV37o=", + "lastModified": 1726250228, + "narHash": "sha256-2YJRNkIDqU5ruMNPiU1PvfURBE93WGPJuwBmyUJw5Ho=", "owner": "StevenBlack", "repo": "hosts", - "rev": "10b187280ec15374e4d2b28e7705046e7d535d91", + "rev": "c388521f8786b76abcd5d7a129aba877ac09160a", "type": "github" }, "original": { @@ -559,11 +559,11 @@ ] }, "locked": { - "lastModified": 1725694918, - "narHash": "sha256-+HsjshXpqNiJHLaJaK0JnIicJ/a1NquKcfn4YZ3ILgg=", + "lastModified": 1726308872, + "narHash": "sha256-d4vwO5N4RsLnCY7k5tY9xbdYDWQsY3RDMeUoIa4ms2A=", "owner": "nix-community", "repo": "home-manager", - "rev": "aaebdea769a5c10f1c6e50ebdf5924c1a13f0cda", + "rev": "6c1a461a444e6ccb3f3e42bb627b510c3a722a57", "type": "github" }, "original": { @@ -779,7 +779,6 @@ "locked": { "lastModified": 1725203994, "narHash": "sha256-N7Kfq8tpOWjtRKBnH5RqcDtQFGZPZ5vXgmxbnZVPCuU=", - "ref": "refs/heads/main", "rev": "73b0fc26c0e2f6f82f9d9f5b02e660a958902763", "revCount": 248, "type": "git", @@ -1089,11 +1088,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1725634671, - "narHash": "sha256-v3rIhsJBOMLR8e/RNWxr828tB+WywYIoajrZKFM+0Gg=", + "lastModified": 1726062873, + "narHash": "sha256-IiA3jfbR7K/B5+9byVi9BZGWTD4VSbWe8VLpp9B/iYk=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "574d1eac1c200690e27b8eb4e24887f8df7ac27c", + "rev": "4f807e8940284ad7925ebd0a0993d2a1791acb2f", "type": "github" }, "original": { @@ -1136,11 +1135,11 @@ }, "nixpkgs-stable": { "locked": { - "lastModified": 1725407940, - "narHash": "sha256-tiN5Rlg/jiY0tyky+soJZoRzLKbPyIdlQ77xVgREDNM=", + "lastModified": 1726062281, + "narHash": "sha256-PyFVySdGj3enKqm8RQuo4v1KLJLmNLOq2yYOHsI6e2Q=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "6f6c45b5134a8ee2e465164811e451dcb5ad86e3", + "rev": "e65aa8301ba4f0ab8cb98f944c14aa9da07394f8", "type": "github" }, "original": { @@ -1235,6 +1234,22 @@ "type": "github" } }, + "nvchad": { + "flake": false, + "locked": { + "lastModified": 1726117897, + "narHash": "sha256-Av0yO+tFzlQiZSIzSw5Zj9C/BDXuHpvJ6D0b1Gu2gzw=", + "owner": "NvChad", + "repo": "starter", + "rev": "59f23d053a047a0c6c555fea2fc4b7b26201e64f", + "type": "github" + }, + "original": { + "owner": "NvChad", + "repo": "starter", + "type": "github" + } + }, "nwg-dock-hyprland-pin-nixpkgs": { "locked": { "lastModified": 1716385560, @@ -1468,11 +1483,11 @@ ] }, "locked": { - "lastModified": 1725727445, - "narHash": "sha256-f5TrY73wfL4kvRmEtZXpzgCuxVFlNqMUNY6QSX16IPA=", + "lastModified": 1725914634, + "narHash": "sha256-U74hu15xSb6JNySMOwyJrsh4uk1DVa182bdHLeHdYMc=", "owner": "pjones", "repo": "plasma-manager", - "rev": "1b9c8200d6438c98c427536abbc5b6fd6a5250c8", + "rev": "60becd0e994e25b372c8d0500fc944396f6c1085", "type": "github" }, "original": { @@ -1519,6 +1534,7 @@ "nix-straight": "nix-straight", "nixpkgs": "nixpkgs", "nixpkgs-stable": "nixpkgs-stable", + "nvchad": "nvchad", "nwg-dock-hyprland-pin-nixpkgs": "nwg-dock-hyprland-pin-nixpkgs", "org-krita": "org-krita", "org-nursery": "org-nursery", @@ -1554,11 +1570,11 @@ "nixpkgs": "nixpkgs_2" }, "locked": { - "lastModified": 1725675754, - "narHash": "sha256-hXW3csqePOcF2e/PYnpXj72KEYyNj2HzTrVNmS/F7Ug=", + "lastModified": 1726280639, + "narHash": "sha256-YfLRPlFZWrT2oRLNAoqf7G3+NnUTDdlIJk6tmBU7kXM=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "8cc45e678e914a16c8e224c3237fb07cf21e5e54", + "rev": "e9f8641c92f26fd1e076e705edb12147c384171d", "type": "github" }, "original": { @@ -1616,11 +1632,11 @@ "systems": "systems_6" }, "locked": { - "lastModified": 1725290973, - "narHash": "sha256-+jwXF9KI0HfvDgpsoJGvOdfOGGSKOrID1wQB79zjUbo=", + "lastModified": 1726170940, + "narHash": "sha256-sobkRkGBaMX9pD0bwU1iVPWi0WtQvZqlHyl1YtvNDio=", "owner": "danth", "repo": "stylix", - "rev": "ef81ad9e85e60420cc83d4642619c14b57139d33", + "rev": "35233f929629c8eb64e939e35260fc8347f94df9", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 65c9a40..0f0da2c 100644 --- a/flake.nix +++ b/flake.nix @@ -264,6 +264,11 @@ nix-straight.flake = false; nix-doom-emacs.inputs.nix-straight.follows = "nix-straight"; + nvchad = { + url = "github:NvChad/starter"; + flake = false; + }; + eaf = { url = "github:emacs-eaf/emacs-application-framework"; flake = false; diff --git a/profiles/work/home.nix b/profiles/work/home.nix index c9e7110..02c0ec6 100644 --- a/profiles/work/home.nix +++ b/profiles/work/home.nix @@ -13,6 +13,7 @@ ../../user/shell/sh.nix # My zsh and bash config ../../user/shell/cli-collection.nix # Useful CLI apps ../../user/app/doom-emacs/doom.nix # My doom emacs config + ../../user/app/nvim/nvim.nix # My doom emacs config #../../user/app/emacsng # Me experimenting with emacsng and a vanilla config ../../user/app/ranger/ranger.nix # My ranger file manager config ../../user/app/git/git.nix # My git config @@ -116,9 +117,7 @@ vlc mpv yt-dlp - (blender-hip.override { - cudaSupport = true; - }) + blender-hip libresprite # cura is moderately broken on wayland, so use xwayland (pkgs-stable.cura.overrideAttrs (oldAttrs: { diff --git a/user/app/nvim/nvim.nix b/user/app/nvim/nvim.nix new file mode 100644 index 0000000..b99c3fc --- /dev/null +++ b/user/app/nvim/nvim.nix @@ -0,0 +1,10 @@ +{ pkgs, inputs, ... }: + +{ + home.packages = with pkgs; [ + neovim + neovide + ]; + home.file.".config/nvim".source = inputs.nvchad; + home.file.".config/nvim".recursive = true; +} From 29eacd05bbce414747948f0349b0d00d92c8aa44 Mon Sep 17 00:00:00 2001 From: Emmet Date: Sat, 14 Sep 2024 20:31:57 -0500 Subject: [PATCH 2/2] Migrating some doom emacs to nvchad --- flake.nix | 2 +- user/app/nvim/README.md | 9 ++ user/app/nvim/init.lua | 89 ++++++++++++++++++++ user/app/nvim/lua/chadrc.lua | 17 ++++ user/app/nvim/lua/configs/conform.lua | 15 ++++ user/app/nvim/lua/configs/lazy.lua | 47 +++++++++++ user/app/nvim/lua/configs/lspconfig.lua | 24 ++++++ user/app/nvim/lua/mappings.lua | 26 ++++++ user/app/nvim/lua/options.lua | 6 ++ user/app/nvim/lua/plugins/init.lua | 42 +++++++++ user/app/nvim/lua/themes/stylix.lua.mustache | 70 +++++++++++++++ user/app/nvim/nvim.nix | 9 +- 12 files changed, 353 insertions(+), 3 deletions(-) create mode 100644 user/app/nvim/README.md create mode 100644 user/app/nvim/init.lua create mode 100644 user/app/nvim/lua/chadrc.lua create mode 100644 user/app/nvim/lua/configs/conform.lua create mode 100644 user/app/nvim/lua/configs/lazy.lua create mode 100644 user/app/nvim/lua/configs/lspconfig.lua create mode 100644 user/app/nvim/lua/mappings.lua create mode 100644 user/app/nvim/lua/options.lua create mode 100644 user/app/nvim/lua/plugins/init.lua create mode 100644 user/app/nvim/lua/themes/stylix.lua.mustache diff --git a/flake.nix b/flake.nix index 0f0da2c..ac70a0f 100644 --- a/flake.nix +++ b/flake.nix @@ -32,7 +32,7 @@ term = "alacritty"; # Default terminal command; font = "Intel One Mono"; # Selected font fontPkg = pkgs.intel-one-mono; # Font package - editor = "emacsclient"; # Default editor; + editor = "neovide"; # Default editor; # editor spawning translator # generates a command that can be used to spawn editor inside a gui # EDITOR and TERM session variables must be set in home.nix or other module diff --git a/user/app/nvim/README.md b/user/app/nvim/README.md new file mode 100644 index 0000000..dc0deaa --- /dev/null +++ b/user/app/nvim/README.md @@ -0,0 +1,9 @@ +**This repo is supposed to used as config by NvChad users!** + +- The main nvchad repo (NvChad/NvChad) is used as a plugin by this repo. +- So you just import its modules , like `require "nvchad.options" , require "nvchad.mappings"` +- So you can delete the .git from this repo ( when you clone it locally ) or fork it :) + +# Credits + +1) Lazyvim starter https://github.com/LazyVim/starter as nvchad's starter was inspired by Lazyvim's . It made a lot of things easier! diff --git a/user/app/nvim/init.lua b/user/app/nvim/init.lua new file mode 100644 index 0000000..64d8655 --- /dev/null +++ b/user/app/nvim/init.lua @@ -0,0 +1,89 @@ +vim.g.base46_cache = vim.fn.stdpath "data" .. "/nvchad/base46/" +vim.g.mapleader = " " + +if vim.g.neovide then + -- Helper function for transparency formatting + local alpha = function() + return string.format("%x", math.floor(255 * vim.g.transparency or 0.8)) + end + vim.g.transparency = 0 + vim.g.neovide_background_color = vim.g.neovide_background_color .. alpha() + vim.g.neovide_transparency = 0.8 + vim.g.neovide_floating_blur_amount_x = 8.0 + vim.g.neovide_floating_blur_amount_y = 8.0 +end + +vim.g.neovide_scale_factor = 1.0 + +-- bootstrap lazy and all plugins +local lazypath = vim.fn.stdpath "data" .. "/lazy/lazy.nvim" + +if not vim.uv.fs_stat(lazypath) then + local repo = "https://github.com/folke/lazy.nvim.git" + vim.fn.system { "git", "clone", "--filter=blob:none", repo, "--branch=stable", lazypath } +end + +vim.opt.rtp:prepend(lazypath) + +local lazy_config = require "configs.lazy" + +-- load plugins +require("lazy").setup({ + { + "NvChad/NvChad", + lazy = false, + branch = "v2.5", + import = "nvchad.plugins", + }, + + { import = "plugins" }, +}, lazy_config) + +require("workspaces").setup({ + hooks = { + open = { "Telescope find_files" }, + } +}) + +-- You dont need to set any of these options. These are the default ones. Only +-- the loading is important +require('telescope').setup { + defaults = { + winblend = 80, + }, + pickers = { + find_files = { + }, + }, + extensions = { + fzf = { + fuzzy = true, -- false will only do exact matching + override_generic_sorter = true, -- override the generic sorter + override_file_sorter = true, -- override the file sorter + case_mode = "smart_case", -- or "ignore_case" or "respect_case" + -- the default case_mode is "smart_case" + }, + workspaces = { + -- keep insert mode after selection in the picker, default is false + keep_insert = true, + -- Highlight group used for the path in the picker, default is "String" + path_hl = "String" + } + } +} +-- To get fzf loaded and working with telescope, you need to call +-- load_extension, somewhere after setup function: +require('telescope').load_extension('fzf') +require('telescope').load_extension('project') +require('telescope').load_extension('workspaces') + +-- load theme +dofile(vim.g.base46_cache .. "defaults") +dofile(vim.g.base46_cache .. "statusline") + +require "options" +require "nvchad.autocmds" + +vim.schedule(function() + require "mappings" +end) diff --git a/user/app/nvim/lua/chadrc.lua b/user/app/nvim/lua/chadrc.lua new file mode 100644 index 0000000..5fd0c74 --- /dev/null +++ b/user/app/nvim/lua/chadrc.lua @@ -0,0 +1,17 @@ +-- This file needs to have same structure as nvconfig.lua +-- https://github.com/NvChad/ui/blob/v2.5/lua/nvconfig.lua +-- Please read that file to know all available options :( + +---@type ChadrcConfig +local M = {} + +M.base46 = { + theme = "stylix", + + -- hl_override = { + -- Comment = { italic = true }, + -- ["@comment"] = { italic = true }, + -- }, +} + +return M diff --git a/user/app/nvim/lua/configs/conform.lua b/user/app/nvim/lua/configs/conform.lua new file mode 100644 index 0000000..35ba6cf --- /dev/null +++ b/user/app/nvim/lua/configs/conform.lua @@ -0,0 +1,15 @@ +local options = { + formatters_by_ft = { + lua = { "stylua" }, + -- css = { "prettier" }, + -- html = { "prettier" }, + }, + + -- format_on_save = { + -- -- These options will be passed to conform.format() + -- timeout_ms = 500, + -- lsp_fallback = true, + -- }, +} + +return options diff --git a/user/app/nvim/lua/configs/lazy.lua b/user/app/nvim/lua/configs/lazy.lua new file mode 100644 index 0000000..cd170bd --- /dev/null +++ b/user/app/nvim/lua/configs/lazy.lua @@ -0,0 +1,47 @@ +return { + defaults = { lazy = true }, + install = { colorscheme = { "nvchad" } }, + + ui = { + icons = { + ft = "", + lazy = "󰂠 ", + loaded = "", + not_loaded = "", + }, + }, + + performance = { + rtp = { + disabled_plugins = { + "2html_plugin", + "tohtml", + "getscript", + "getscriptPlugin", + "gzip", + "logipat", + "netrw", + "netrwPlugin", + "netrwSettings", + "netrwFileHandlers", + "matchit", + "tar", + "tarPlugin", + "rrhelper", + "spellfile_plugin", + "vimball", + "vimballPlugin", + "zip", + "zipPlugin", + "tutor", + "rplugin", + "syntax", + "synmenu", + "optwin", + "compiler", + "bugreport", + "ftplugin", + }, + }, + }, +} diff --git a/user/app/nvim/lua/configs/lspconfig.lua b/user/app/nvim/lua/configs/lspconfig.lua new file mode 100644 index 0000000..478df01 --- /dev/null +++ b/user/app/nvim/lua/configs/lspconfig.lua @@ -0,0 +1,24 @@ +-- load defaults i.e lua_lsp +require("nvchad.configs.lspconfig").defaults() + +local lspconfig = require "lspconfig" + +-- EXAMPLE +local servers = { "html", "cssls" } +local nvlsp = require "nvchad.configs.lspconfig" + +-- lsps with default config +for _, lsp in ipairs(servers) do + lspconfig[lsp].setup { + on_attach = nvlsp.on_attach, + on_init = nvlsp.on_init, + capabilities = nvlsp.capabilities, + } +end + +-- configuring single server, example: typescript +-- lspconfig.ts_ls.setup { +-- on_attach = nvlsp.on_attach, +-- on_init = nvlsp.on_init, +-- capabilities = nvlsp.capabilities, +-- } diff --git a/user/app/nvim/lua/mappings.lua b/user/app/nvim/lua/mappings.lua new file mode 100644 index 0000000..17f4517 --- /dev/null +++ b/user/app/nvim/lua/mappings.lua @@ -0,0 +1,26 @@ +require "nvchad.mappings" + +-- add yours here + +local map = vim.keymap.set +local builtin = require("telescope.builtin") +local utils = require("telescope.utils") +local change_scale_factor = function(delta) + vim.g.neovide_scale_factor = vim.g.neovide_scale_factor * delta +end + +vim.keymap.set("n", "", function() + change_scale_factor(1.25) +end) +vim.keymap.set("n", "", function() + change_scale_factor(1/1.25) +end) + +map("n", ";", ":", { desc = "CMD enter command mode" }) +map({"n", "v", "i"}, "", ":", { desc = "CMD enter command mode" }) +map("n", ".", "Telescope find_files", { desc = "telescope find files" }) +map("n", "gg", "Neogit", { desc = "Neogit status buffer" }) +map("n", "pp", "Telescope workspaces", { desc = "telescope workspaces" }) +map("i", "jk", "") + +-- map({ "n", "i", "v" }, "", " w ") diff --git a/user/app/nvim/lua/options.lua b/user/app/nvim/lua/options.lua new file mode 100644 index 0000000..738f20b --- /dev/null +++ b/user/app/nvim/lua/options.lua @@ -0,0 +1,6 @@ +require "nvchad.options" + +-- add yours here! + +-- local o = vim.o +-- o.cursorlineopt ='both' -- to enable cursorline! diff --git a/user/app/nvim/lua/plugins/init.lua b/user/app/nvim/lua/plugins/init.lua new file mode 100644 index 0000000..a433f1b --- /dev/null +++ b/user/app/nvim/lua/plugins/init.lua @@ -0,0 +1,42 @@ +return { + { + "stevearc/conform.nvim", + -- event = 'BufWritePre', -- uncomment for format on save + opts = require "configs.conform", + }, + + -- These are some examples, uncomment them if you want to see them work! + { + "neovim/nvim-lspconfig", + config = function() + require "configs.lspconfig" + end, + }, + + { + "nvim-treesitter/nvim-treesitter", + opts = { + ensure_installed = { + "vim", "lua", "vimdoc", + "html", "css" + }, + }, + }, + + { 'nvim-telescope/telescope-fzf-native.nvim', build = 'make', lazy = false, }, + { 'nvim-telescope/telescope-project.nvim', lazy = false, }, + { 'natecraddock/workspaces.nvim', lazy = false, }, + + { + "NeogitOrg/neogit", + lazy = false, + dependencies = { + "nvim-lua/plenary.nvim", -- required + "sindrets/diffview.nvim", -- optional - Diff integration + + -- Only one of these is needed. + "nvim-telescope/telescope.nvim", -- optional + }, + config = true + }, +} diff --git a/user/app/nvim/lua/themes/stylix.lua.mustache b/user/app/nvim/lua/themes/stylix.lua.mustache new file mode 100644 index 0000000..fba0ee7 --- /dev/null +++ b/user/app/nvim/lua/themes/stylix.lua.mustache @@ -0,0 +1,70 @@ +local M = {} + +M.base_30 = { + white = "#{{base07-hex}}", + darker_black = "#{{base00-hex}}", + black = "#{{base00-hex}}", -- nvim bg + black2 = "#{{base01-hex}}", + one_bg = "#{{base01-hex}}", + one_bg2 = "#{{base02-hex}}", + one_bg3 = "#{{base03-hex}}", + grey = "#{{base04-hex}}", + grey_fg = "#{{base04-hex}}", + grey_fg2 = "#{{base05-hex}}", + light_grey = "#{{base06-hex}}", + red = "#{{base08-hex}}", + baby_pink = "#{{base08-hex}}", + pink = "#{{base08-hex}}", + line = "#{{base02-hex}}", -- for lines like vertsplit + green = "#{{base0B-hex}}", + vibrant_green = "#{{base0B-hex}}", + blue = "#{{base0D-hex}}", + nord_blue = "#{{base0D-hex}}", + yellow = "#{{base0A-hex}}", + sun = "#{{base0A-hex}}", + purple = "#{{base0E-hex}}", + dark_purple = "#{{base0E-hex}}", + teal = "#{{base0C-hex}}", + orange = "#{{base09-hex}}", + cyan = "#{{base0C-hex}}", + statusline_bg = "#{{base02-hex}}", + lightbg = "#{{base03-hex}}", + pmenu_bg = "#{{base0D-hex}}", + folder_bg = "#{{base05-hex}}", +} + +M.base_16 = { + base00 = "#{{base00-hex}}", + base01 = "#{{base01-hex}}", + base02 = "#{{base02-hex}}", + base03 = "#{{base03-hex}}", + base04 = "#{{base04-hex}}", + base05 = "#{{base05-hex}}", + base06 = "#{{base06-hex}}", + base07 = "#{{base07-hex}}", + base08 = "#{{base08-hex}}", + base09 = "#{{base09-hex}}", + base0A = "#{{base0A-hex}}", + base0B = "#{{base0B-hex}}", + base0C = "#{{base0C-hex}}", + base0D = "#{{base0D-hex}}", + base0E = "#{{base0E-hex}}", + base0F = "#{{base0F-hex}}", +} + +M.polish_hl = { + treesitter = { + luaTSField = { fg = M.base_16.base0D }, + ["@tag.delimiter"] = { fg = M.base_30.cyan }, + ["@function"] = { fg = M.base_30.orange }, + ["@variable.parameter"] = { fg = M.base_16.base0F }, + ["@constructor"] = { fg = M.base_16.base0A }, + ["@tag.attribute"] = { fg = M.base_30.orange }, + }, +} + +M = require("base46").override_theme(M, "stylix") + +M.type = "{{polarity}}" + +return M diff --git a/user/app/nvim/nvim.nix b/user/app/nvim/nvim.nix index b99c3fc..4d41d0a 100644 --- a/user/app/nvim/nvim.nix +++ b/user/app/nvim/nvim.nix @@ -1,10 +1,15 @@ -{ pkgs, inputs, ... }: +{ config, pkgs, inputs, ... }: { home.packages = with pkgs; [ neovim neovide + lua-language-server ]; - home.file.".config/nvim".source = inputs.nvchad; + home.file.".config/nvim".source = ./.; home.file.".config/nvim".recursive = true; + home.file.".config/nvim/lua/themes/stylix.lua".source = config.lib.stylix.colors { + template = builtins.readFile ./lua/themes/stylix.lua.mustache; + extension = ".lua"; + }; }