From 731c0a3b1dc3947f83a15e0fb3d4e68ba9965d44 Mon Sep 17 00:00:00 2001 From: Ivan Dimitrov Date: Sun, 2 Jul 2023 18:50:25 +0300 Subject: [PATCH] adding nvchad in a different way --- .gitmodules | 3 -- cfg/nvim/custom/README.md | 3 ++ cfg/nvim/custom/chadrc.lua | 20 +++++++++ cfg/nvim/custom/configs/lspconfig.lua | 17 +++++++ cfg/nvim/custom/configs/null-ls.lua | 27 +++++++++++ cfg/nvim/custom/configs/overrides.lua | 59 ++++++++++++++++++++++++ cfg/nvim/custom/highlights.lua | 19 ++++++++ cfg/nvim/custom/init.lua | 7 +++ cfg/nvim/custom/mappings.lua | 12 +++++ cfg/nvim/custom/plugins.lua | 65 +++++++++++++++++++++++++++ config/nvim | 1 - configuration.nix | 7 ++- 12 files changed, 235 insertions(+), 5 deletions(-) delete mode 100644 .gitmodules create mode 100644 cfg/nvim/custom/README.md create mode 100644 cfg/nvim/custom/chadrc.lua create mode 100644 cfg/nvim/custom/configs/lspconfig.lua create mode 100644 cfg/nvim/custom/configs/null-ls.lua create mode 100644 cfg/nvim/custom/configs/overrides.lua create mode 100644 cfg/nvim/custom/highlights.lua create mode 100644 cfg/nvim/custom/init.lua create mode 100644 cfg/nvim/custom/mappings.lua create mode 100644 cfg/nvim/custom/plugins.lua delete mode 160000 config/nvim diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 10518e2..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "config/nvim"] - path = config/nvim - url = https://github.com/NvChad/NvChad diff --git a/cfg/nvim/custom/README.md b/cfg/nvim/custom/README.md new file mode 100644 index 0000000..a6ef0d1 --- /dev/null +++ b/cfg/nvim/custom/README.md @@ -0,0 +1,3 @@ +# Example_config + +This can be used as an example custom config for NvChad, this branch is a minimal one. Do check the feature_full branch if you need all the ease in your config. diff --git a/cfg/nvim/custom/chadrc.lua b/cfg/nvim/custom/chadrc.lua new file mode 100644 index 0000000..154c455 --- /dev/null +++ b/cfg/nvim/custom/chadrc.lua @@ -0,0 +1,20 @@ +---@type ChadrcConfig +local M = {} + +-- Path to overriding theme and highlights files +local highlights = require "custom.highlights" + +M.ui = { + theme = "onedark", + theme_toggle = { "onedark", "one_light" }, + + hl_override = highlights.override, + hl_add = highlights.add, +} + +M.plugins = "custom.plugins" + +-- check core.mappings for table structure +M.mappings = require "custom.mappings" + +return M diff --git a/cfg/nvim/custom/configs/lspconfig.lua b/cfg/nvim/custom/configs/lspconfig.lua new file mode 100644 index 0000000..d6f7f2b --- /dev/null +++ b/cfg/nvim/custom/configs/lspconfig.lua @@ -0,0 +1,17 @@ +local on_attach = require("plugins.configs.lspconfig").on_attach +local capabilities = require("plugins.configs.lspconfig").capabilities + +local lspconfig = require "lspconfig" + +-- if you just want default config for the servers then put them in a table +local servers = { "html", "cssls", "tsserver", "clangd" } + +for _, lsp in ipairs(servers) do + lspconfig[lsp].setup { + on_attach = on_attach, + capabilities = capabilities, + } +end + +-- +-- lspconfig.pyright.setup { blabla} diff --git a/cfg/nvim/custom/configs/null-ls.lua b/cfg/nvim/custom/configs/null-ls.lua new file mode 100644 index 0000000..8f15ecc --- /dev/null +++ b/cfg/nvim/custom/configs/null-ls.lua @@ -0,0 +1,27 @@ +local present, null_ls = pcall(require, "null-ls") + +if not present then + return +end + +local b = null_ls.builtins + +local sources = { + + -- webdev stuff + b.formatting.deno_fmt, -- choosed deno for ts/js files cuz its very fast! + b.formatting.prettier.with { filetypes = { "html", "markdown", "css" } }, -- so prettier works only on these filetypes + + -- Lua + b.formatting.stylua, + + -- cpp + b.formatting.clang_format, + + b.formatting.alejandra +} + +null_ls.setup { + debug = true, + sources = sources, +} diff --git a/cfg/nvim/custom/configs/overrides.lua b/cfg/nvim/custom/configs/overrides.lua new file mode 100644 index 0000000..c4cd2c7 --- /dev/null +++ b/cfg/nvim/custom/configs/overrides.lua @@ -0,0 +1,59 @@ +local M = {} + +M.treesitter = { + ensure_installed = { + "vim", + "lua", + "html", + "css", + "javascript", + "typescript", + "tsx", + "c", + "markdown", + "markdown_inline", + }, + indent = { + enable = true, + -- disable = { + -- "python" + -- }, + }, +} + +M.mason = { + ensure_installed = { + -- lua stuff + "lua-language-server", + "stylua", + + -- web dev stuff + "css-lsp", + "html-lsp", + "typescript-language-server", + "deno", + "prettier", + + -- c/cpp stuff + "clangd", + "clang-format", + }, +} + +-- git support in nvimtree +M.nvimtree = { + git = { + enable = true, + }, + + renderer = { + highlight_git = true, + icons = { + show = { + git = true, + }, + }, + }, +} + +return M diff --git a/cfg/nvim/custom/highlights.lua b/cfg/nvim/custom/highlights.lua new file mode 100644 index 0000000..ebf2dfb --- /dev/null +++ b/cfg/nvim/custom/highlights.lua @@ -0,0 +1,19 @@ +-- To find any highlight groups: " Telescope highlights" +-- Each highlight group can take a table with variables fg, bg, bold, italic, etc +-- base30 variable names can also be used as colors + +local M = {} + +---@type Base46HLGroupsList +M.override = { + Comment = { + italic = true, + }, +} + +---@type HLTable +M.add = { + NvimTreeOpenedFolderName = { fg = "green", bold = true }, +} + +return M diff --git a/cfg/nvim/custom/init.lua b/cfg/nvim/custom/init.lua new file mode 100644 index 0000000..608a8d9 --- /dev/null +++ b/cfg/nvim/custom/init.lua @@ -0,0 +1,7 @@ +-- local autocmd = vim.api.nvim_create_autocmd + +-- Auto resize panes when resizing nvim window +-- autocmd("VimResized", { +-- pattern = "*", +-- command = "tabdo wincmd =", +-- }) diff --git a/cfg/nvim/custom/mappings.lua b/cfg/nvim/custom/mappings.lua new file mode 100644 index 0000000..9ce068a --- /dev/null +++ b/cfg/nvim/custom/mappings.lua @@ -0,0 +1,12 @@ +---@type MappingsTable +local M = {} + +M.general = { + n = { + [";"] = { ":", "enter command mode", opts = { nowait = true } }, + }, +} + +-- more keybinds! + +return M diff --git a/cfg/nvim/custom/plugins.lua b/cfg/nvim/custom/plugins.lua new file mode 100644 index 0000000..2ed8db8 --- /dev/null +++ b/cfg/nvim/custom/plugins.lua @@ -0,0 +1,65 @@ +local overrides = require("custom.configs.overrides") + +---@type NvPluginSpec[] +local plugins = { + + -- Override plugin definition options + + { + "neovim/nvim-lspconfig", + dependencies = { + -- format & linting + { + "jose-elias-alvarez/null-ls.nvim", + config = function() + require "custom.configs.null-ls" + end, + }, + }, + config = function() + require "plugins.configs.lspconfig" + require "custom.configs.lspconfig" + end, -- Override to setup mason-lspconfig + }, + + -- override plugin configs + { + "williamboman/mason.nvim", + opts = overrides.mason + }, + + { + "nvim-treesitter/nvim-treesitter", + opts = overrides.treesitter, + }, + + { + "nvim-tree/nvim-tree.lua", + opts = overrides.nvimtree, + }, + + -- Install a plugin + { + "max397574/better-escape.nvim", + event = "InsertEnter", + config = function() + require("better_escape").setup() + end, + }, + + -- To make a plugin not be loaded + -- { + -- "NvChad/nvim-colorizer.lua", + -- enabled = false + -- }, + + -- All NvChad plugins are lazy-loaded by default + -- For a plugin to be loaded, you will need to set either `ft`, `cmd`, `keys`, `event`, or set `lazy = false` + -- If you want a plugin to load on startup, add `lazy = false` to a plugin spec, for example + -- { + -- "mg979/vim-visual-multi", + -- lazy = false, + -- } +} + +return plugins diff --git a/config/nvim b/config/nvim deleted file mode 160000 index 10b668d..0000000 --- a/config/nvim +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 10b668d98aba6bce9b494d028174207e59e5c59a diff --git a/configuration.nix b/configuration.nix index 5c23780..a9af03e 100644 --- a/configuration.nix +++ b/configuration.nix @@ -48,6 +48,7 @@ gnome.cheese gnumake home-manager + vimPlugins.nvchad jmtpfs libgccjit libmtp @@ -170,7 +171,11 @@ }; xdg.configFile = { nvim = { - source = ./config/nvim; + source = pkgs.vimPlugins.nvchad; + recursive = true; + }; + "nvim/lua/custom" = { + source = ./cfg/nvim/custom; recursive = true; }; "user-dirs.dirs" = {