diff --git a/modules/home-manager/nvim/default.nix b/modules/home-manager/nvim/default.nix index 9b6861b..fc99879 100755 --- a/modules/home-manager/nvim/default.nix +++ b/modules/home-manager/nvim/default.nix @@ -1,7 +1,7 @@ { inputs, pkgs, ... }: { + xdg.configFile = { - "nvim".source = inputs.astronvim; - "astronvim".source = ./astronvim; + source = "${pkgs.nvchad}"; }; programs = { @@ -21,48 +21,13 @@ packages = with pkgs; [ gcc neovide - #-- python - nodePackages.pyright # python language server - python311Packages.black # python formatter - - #-- nix - nil - rnix-lsp + # nix statix # Lints and suggestions for the nix programming language deadnix # Find and remove unused code in .nix source files alejandra # Nix Code Formatter - #-- golang - go - gomodifytags - iferr # generate error handling code for go - impl # generate function implementation for go - gotools # contains tools like: godoc, goimports, etc. - gopls # go language server - delve # go debugger - - #-- lua - stylua - lua-language-server - luarocks - - #-- bash - nodePackages.bash-language-server - shellcheck - shfmt - - #-- javascript/typescript --# - nodePackages.typescript - nodePackages.typescript-language-server - - #-- Misc - hadolint # Dockerfile linter - tree-sitter # common language parser/highlighter - nodePackages.prettier # common code formatter - - #-- Optional Requirements: - gdu # disk usage analyzer, required by AstroNvim - ripgrep # fast search tool, required by AstroNvim's 'fw'( is space key) + gdu + ripgrep ]; }; } diff --git a/pkgs/nvchad/custom/chadrc.lua b/pkgs/nvchad/custom/chadrc.lua new file mode 100644 index 0000000..f7347b9 --- /dev/null +++ b/pkgs/nvchad/custom/chadrc.lua @@ -0,0 +1,22 @@ +local M = {} + +M.ui = { + theme = "oxocarbon", + transparency = true, + nvdash = { + load_on_startup = true, + + header = { + "|------------------------|", + "| NOBODY FUX WITH TUX |", + "|------------------------|", + " \\ (•◡•) / ", + " \\ / ", + }, + }, +} + +M.mappings = require "custom.mappings" +M.plugins = "custom.plugins" + +return M diff --git a/pkgs/nvchad/custom/configs/conform.lua b/pkgs/nvchad/custom/configs/conform.lua new file mode 100644 index 0000000..3e6ae80 --- /dev/null +++ b/pkgs/nvchad/custom/configs/conform.lua @@ -0,0 +1,21 @@ +local prettier = { "prettierd", "prettier" } + +local options = { + lsp_fallback = true, + + formatters_by_ft = { + lua = { "stylua" }, + javascript = { prettier }, + typescript = { prettier }, + javascriptreact = { prettier }, + typescriptreact = { prettier }, + json = { prettier }, + jsonc = { prettier }, + css = { prettier }, + html = { prettier }, + markdown = { prettier }, + nix = { "alejandra" }, + }, +} + +require("conform").setup(options) diff --git a/pkgs/nvchad/custom/configs/lspconfig.lua b/pkgs/nvchad/custom/configs/lspconfig.lua new file mode 100644 index 0000000..bfd69cd --- /dev/null +++ b/pkgs/nvchad/custom/configs/lspconfig.lua @@ -0,0 +1,32 @@ +local configs = require "plugins.configs.lspconfig" +local on_attach = configs.on_attach +local capabilities = configs.capabilities + +local lspconfig = require "lspconfig" +-- local util = require "lspconfig/util" + +local servers = { "tsserver", "tailwindcss", "eslint" } + +for _, lsp in ipairs(servers) do + lspconfig[lsp].setup { + on_attach = on_attach, + capabilities = capabilities, + } +end + +-- lspconfig.gopls.setup { +-- on_attach = on_attach, +-- capabilities = capabilities, +-- cmd = { "gopls" }, +-- filetypes = { "go", "gomod", "gowork", "gotmpl" }, +-- root_dir = util.root_pattern("go.work", "go.mod", ".git"), +-- settings = { +-- gopls = { +-- completeUnimported = true, +-- usePlaceholders = true, +-- analyses = { +-- unusedparams = true, +-- }, +-- }, +-- }, +-- } diff --git a/pkgs/nvchad/custom/configs/noice.lua b/pkgs/nvchad/custom/configs/noice.lua new file mode 100644 index 0000000..c587099 --- /dev/null +++ b/pkgs/nvchad/custom/configs/noice.lua @@ -0,0 +1,16 @@ +local opts = { + lsp = { + override = { + ["vim.lsp.util.convert_input_to_markdown_lines"] = true, + ["vim.lsp.util.stylize_markdown"] = true, + ["cmp.entry.get_documentation"] = true, + }, + }, + presets = { + long_message_to_split = true, -- long messages will be sent to a split + inc_rename = false, -- enables an input dialog for inc-rename.nvim + lsp_doc_border = false, -- add a border to hover docs and signature help + }, +} + +return opts diff --git a/pkgs/nvchad/custom/configs/null-ls.lua b/pkgs/nvchad/custom/configs/null-ls.lua new file mode 100644 index 0000000..7d4ad65 --- /dev/null +++ b/pkgs/nvchad/custom/configs/null-ls.lua @@ -0,0 +1,33 @@ +local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) +local null_ls = require "null-ls" + +local b = null_ls.builtins + +local opts = { + sources = { + b.formatting.prettierd, + b.formatting.stylua, + + -- nix + b.code_actions.statix, + b.formatting.alejandra, + b.diagnostics.deadnix, + }, + on_attach = function(client, bufnr) + if client.supports_method "textDocument/formatting" then + vim.api.nvim_clear_autocmds { + group = augroup, + buffer = bufnr, + } + vim.api.nvim_create_autocmd("BufWritePre", { + group = augroup, + buffer = bufnr, + callback = function() + vim.lsp.buf.format { bufnr = bufnr } + end, + }) + end + end, +} + +return opts diff --git a/pkgs/nvchad/custom/configs/overrides.lua b/pkgs/nvchad/custom/configs/overrides.lua new file mode 100644 index 0000000..4915bab --- /dev/null +++ b/pkgs/nvchad/custom/configs/overrides.lua @@ -0,0 +1,57 @@ +local M = {} + +M.treesitter = { + ensure_installed = { + -- defaults + "vim", + "lua", + + -- web dev + "html", + "css", + "javascript", + "typescript", + "tsx", + + -- nix + "nix", + }, +} + +M.mason = { + ensure_installed = { + -- defaults + "lua-language-server", + "stylua", + + -- web dev + "css-lsp", + "html-lsp", + "prettierd", + "eslint-lsp", + "typescript-language-server", + "tailwindcss-language-server", + + -- nix + "nil", + }, +} + +M.nvterm = { + terminals = { + shell = vim.o.shell, + list = {}, + type_opts = { + float = { + relative = "editor", + row = 0.23, + col = 0.15, + width = 0.7, + height = 0.5, + border = "single", + }, + }, + }, +} + +return M diff --git a/pkgs/nvchad/custom/init.lua b/pkgs/nvchad/custom/init.lua new file mode 100644 index 0000000..4020812 --- /dev/null +++ b/pkgs/nvchad/custom/init.lua @@ -0,0 +1,3 @@ +local opt = vim.opt + +opt.relativenumber = true diff --git a/pkgs/nvchad/custom/mappings.lua b/pkgs/nvchad/custom/mappings.lua new file mode 100644 index 0000000..d3165be --- /dev/null +++ b/pkgs/nvchad/custom/mappings.lua @@ -0,0 +1,27 @@ +local M = {} + +M.nvterm = { + t = { + [""] = { + function() + require("nvterm.terminal").toggle "float" + end, + "Toggle floating term", + }, + }, + n = { + [""] = { + function() + require("nvterm.terminal").toggle "float" + end, + "Toggle floating term", + }, + ["Sl"] = { "SessionManager! load_last_session", desc = "Load last session" }, + ["Ss"] = { "SessionManager! save_current_session", desc = "Save this session" }, + ["Sd"] = { "SessionManager! delete_session", desc = "Delete session" }, + ["Sf"] = { "SessionManager! load_session", desc = "Search sessions" }, + ["S."] = { "SessionManager! load_current_dir_session", desc = "Load current directory session" }, + }, +} + +return M diff --git a/pkgs/nvchad/custom/plugins.lua b/pkgs/nvchad/custom/plugins.lua new file mode 100644 index 0000000..f969fbc --- /dev/null +++ b/pkgs/nvchad/custom/plugins.lua @@ -0,0 +1,59 @@ +local overrides = require "custom.configs.overrides" + +local plugins = { + { + "nvim-treesitter/nvim-treesitter", + opts = overrides.treesitter, + }, + { + "williamboman/mason.nvim", + opts = overrides.mason, + }, + { + "NvChad/nvterm", + opts = overrides.nvterm, + }, + { + "Shatur/neovim-session-manager", + dependencies = { + "nvim-lua/plenary.nvim", + "stevearc/dressing.nvim", + }, + event = "BufWritePost", + cmd = "SessionManager", + }, + { + "folke/noice.nvim", + event = "VeryLazy", + dependencies = { + "MunifTanjim/nui.nvim", + "rcarriga/nvim-notify", + }, + opts = function() + return require "custom.configs.noice" + end, + }, + { + "neovim/nvim-lspconfig", + config = function() + require "plugins.configs.lspconfig" + require "custom.configs.lspconfig" + end, + }, + { + "nvimtools/none-ls.nvim", + event = "VeryLazy", + opts = function() + return require "custom.configs.null-ls" + end, + }, + { + "windwp/nvim-ts-autotag", + ft = { "javascript", "javascriptreact", "typescript", "typescriptreact" }, + config = function() + require("nvim-ts-autotag").setup() + end, + }, +} + +return plugins diff --git a/pkgs/nvchad/default.nix b/pkgs/nvchad/default.nix new file mode 100644 index 0000000..f0cfda2 --- /dev/null +++ b/pkgs/nvchad/default.nix @@ -0,0 +1,30 @@ +{ lib, stdenv, pkgs }: + +let + custom = ./custom; +in +stdenv.mkDerivation { + pname = "nvchad"; + version = "2.0.0"; + + src = pkgs.fetchFromGitHub { + owner = "NvChad"; + repo = "NvChad"; + rev = "refs/heads/v2.0"; + # sha256 = "sha256-tKMvKdB3jPSvcyewaOe8oak3pXhjAcLyyxgGMiMeqeU="; + }; + + installPhase = '' + mkdir $out + cp -r * "$out/" + mkdir -p "$out/lua/custom" + cp -r ${custom}/* "$out/lua/custom/" + ''; + + meta = with lib; { + description = "NvChad"; + homepage = "https://github.com/NvChad/NvChad"; + platforms = platforms.all; + license = licenses.gpl3; + }; +} \ No newline at end of file