diff --git a/.dotfiles/bootstrap/85_nvim.sh b/.dotfiles/bootstrap/85_nvim.sh index 7691dc5..fcb6c15 100755 --- a/.dotfiles/bootstrap/85_nvim.sh +++ b/.dotfiles/bootstrap/85_nvim.sh @@ -5,3 +5,9 @@ if [ ! -d "$HOME/.config/nvim" ]; then echo "Installing nvchad" git clone https://github.com/NvChad/NvChad ~/.config/nvim --depth 1 fi + +# Check if .config/nvim/custom is a symlink, and if not, symlink to .dotfiles/nvchad/custom +if [[ -d "$HOME/.config/nvim/lua/custom" && ! -L "$HOME/.config/nvim/lua/custom" ]]; then + mv $HOME/.config/nvim/lua/custom $HOME/.config/nvim/lua/custom_2 + ln -s $HOME/.dotfiles/nvchad/custom/ $HOME/.config/nvim/lua/ +fi diff --git a/.dotfiles/nvchad/custom/README.md b/.dotfiles/nvchad/custom/README.md new file mode 100644 index 0000000..0cc616c --- /dev/null +++ b/.dotfiles/nvchad/custom/README.md @@ -0,0 +1,3 @@ +# Example_config + +This can be used as an example custom config for NvChad. Do check the https://github.com/NvChad/nvcommunity diff --git a/.dotfiles/nvchad/custom/chadrc.lua b/.dotfiles/nvchad/custom/chadrc.lua new file mode 100644 index 0000000..e873d62 --- /dev/null +++ b/.dotfiles/nvchad/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 = "tokyodark", + theme_toggle = { "tokyodark", "tokyodark" }, + + 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/.dotfiles/nvchad/custom/configs/auto-dark-mode.lua b/.dotfiles/nvchad/custom/configs/auto-dark-mode.lua new file mode 100644 index 0000000..c85c908 --- /dev/null +++ b/.dotfiles/nvchad/custom/configs/auto-dark-mode.lua @@ -0,0 +1,4 @@ +return { + light_theme = "ayu_light", + dark_theme = "ayu_dark", +} diff --git a/.dotfiles/nvchad/custom/configs/conform.lua b/.dotfiles/nvchad/custom/configs/conform.lua new file mode 100644 index 0000000..4b142bd --- /dev/null +++ b/.dotfiles/nvchad/custom/configs/conform.lua @@ -0,0 +1,24 @@ +local options = { + lsp_fallback = true, + + formatters_by_ft = { + lua = { "stylua" }, + + javascript = { "prettier" }, + css = { "prettier" }, + html = { "prettier" }, + + sh = { "shfmt" }, + }, + + -- adding same formatter for multiple filetypes can look too much work for some + -- instead of the above code you could just use a loop! the config is just a table after all! + + -- format_on_save = { + -- -- These options will be passed to conform.format() + -- timeout_ms = 500, + -- lsp_fallback = true, + -- }, +} + +require("conform").setup(options) diff --git a/.dotfiles/nvchad/custom/configs/copilot.lua b/.dotfiles/nvchad/custom/configs/copilot.lua new file mode 100644 index 0000000..77ecdd4 --- /dev/null +++ b/.dotfiles/nvchad/custom/configs/copilot.lua @@ -0,0 +1,12 @@ +-- local copilot = require "copilot" + +local opts = { + suggestion = { + auto_trigger = true, + keymap = { + accept = "", + } + } +} + +return opts diff --git a/.dotfiles/nvchad/custom/configs/lspconfig.lua b/.dotfiles/nvchad/custom/configs/lspconfig.lua new file mode 100644 index 0000000..ae65699 --- /dev/null +++ b/.dotfiles/nvchad/custom/configs/lspconfig.lua @@ -0,0 +1,40 @@ +local on_attach = require("plugins.configs.lspconfig").on_attach +local capabilities = require("plugins.configs.lspconfig").capabilities + +local lspconfig = require "lspconfig" +local util = require "lspconfig/util" + +-- if you just want default config for the servers then put them in a table +local servers = { "html", "cssls", "tsserver", "clangd", "lua_ls"} + +for _, lsp in ipairs(servers) do + lspconfig[lsp].setup { + on_attach = on_attach, + capabilities = capabilities, + } +end + +-- setup gopls manually +lspconfig.gopls.setup { + -- use defaults from lspconfig + on_attach = on_attach, + capabilities = capabilities, + -- server to use + cmd = {"gopls"}, + -- files to run this server on + filetypes = {"go", "gomod", "gowork", "gotmpl"}, + -- how to define the root directory + root_dir = util.root_pattern("go.work", "go.mod", ".git"), + -- settings + settings = { + gopls = { + -- complete imports automatically + completeUnimported = true, + -- use placeholders during autocompletion + usePlaceholders = true, + } + }, +} + +-- +-- lspconfig.pyright.setup { blabla} diff --git a/.dotfiles/nvchad/custom/configs/none-ls.lua b/.dotfiles/nvchad/custom/configs/none-ls.lua new file mode 100644 index 0000000..06e438c --- /dev/null +++ b/.dotfiles/nvchad/custom/configs/none-ls.lua @@ -0,0 +1,34 @@ +local none_ls = require("null-ls") + +local augroup = vim.api.nvim_create_augroup("LspFormatting", {}) + +local opts = { + sources = { + -- gomft + none_ls.builtins.formatting.gofmt, + -- goimports-reviser (https://github.com/incu6us/goimports-reviser) + none_ls.builtins.formatting.goimports_reviser, + -- golangci-lint + none_ls.builtins.diagnostics.golangci_lint, + }, + on_attach = function(client, bufnr) + -- check if there's any commands pre-running on the current buffer, + -- clear those and then run out own format command + 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/.dotfiles/nvchad/custom/configs/overrides.lua b/.dotfiles/nvchad/custom/configs/overrides.lua new file mode 100644 index 0000000..7a404dd --- /dev/null +++ b/.dotfiles/nvchad/custom/configs/overrides.lua @@ -0,0 +1,62 @@ +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", + + -- golang + "gopls", + }, +} + +-- git support in nvimtree +M.nvimtree = { + git = { + enable = true, + }, + + renderer = { + highlight_git = true, + icons = { + show = { + git = true, + }, + }, + }, +} + +return M diff --git a/.dotfiles/nvchad/custom/highlights.lua b/.dotfiles/nvchad/custom/highlights.lua new file mode 100644 index 0000000..ebf2dfb --- /dev/null +++ b/.dotfiles/nvchad/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/.dotfiles/nvchad/custom/init.lua b/.dotfiles/nvchad/custom/init.lua new file mode 100644 index 0000000..608a8d9 --- /dev/null +++ b/.dotfiles/nvchad/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/.dotfiles/nvchad/custom/mappings.lua b/.dotfiles/nvchad/custom/mappings.lua new file mode 100644 index 0000000..76dc57b --- /dev/null +++ b/.dotfiles/nvchad/custom/mappings.lua @@ -0,0 +1,34 @@ +---@type MappingsTable +local M = {} + +M.general = { + n = { + [";"] = { ":", "enter command mode", opts = { nowait = true } }, + + -- format with conform + ["fm"] = { + function() + require("conform").format() + end, + "formatting", + } + + }, + v = { + [">"] = { ">gv", "indent"}, + }, +} + +M.lsp = { + n = { + ["ts"] = {":Telescope lsp_document_symbols", "Find symbols in document"} + } +} + +M.neogit = { + n = { + ["gs"] = {":Neogit", "Open Neogit"} + } +} + +return M diff --git a/.dotfiles/nvchad/custom/plugins.lua b/.dotfiles/nvchad/custom/plugins.lua new file mode 100644 index 0000000..0eb2a3a --- /dev/null +++ b/.dotfiles/nvchad/custom/plugins.lua @@ -0,0 +1,134 @@ +local overrides = require("custom.configs.overrides") +-- local auto_dark_mode = require("custom.configs.auto-dark-mode") + +---@type NvPluginSpec[] +local plugins = { + + -- Override plugin definition options + + { + "neovim/nvim-lspconfig", + 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 + }, + + { + "nvimtools/none-ls.nvim", + ft = "go", + opts = function () + return require "custom.configs.none-ls" + end + }, + + { + "nvim-treesitter/nvim-treesitter", + opts = overrides.treesitter, + }, + + { + "nvim-tree/nvim-tree.lua", + opts = overrides.nvimtree, + }, + + { + "zbirenbaum/copilot.lua", + lazy = false, + enabled = true, + config = true, + opts = function () + return require "custom.configs.copilot" + end, + }, + + -- Install a plugin + -- { + -- "max397574/better-escape.nvim", + -- event = "InsertEnter", + -- config = function() + -- require("better_escape").setup() + -- end, + -- }, + -- + -- { + -- "stevearc/conform.nvim", + -- -- for users those who want auto-save conform + lazyloading! + -- -- event = "BufWritePre" + -- config = function() + -- require "custom.configs.conform" + -- 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, + -- } + -- + + { + "NeogitOrg/neogit", + enabled = true, + lazy = false, + dependencies = { + "nvim-lua/plenary.nvim", + + "sindrets/diffview.nvim", -- optional - Diff integration + + "nvim-telescope/telescope.nvim", -- optional + }, + opts = function (_, opts) + opts.kind = "auto" + end, + config = true + }, + -- + -- { + -- "folke/trouble.nvim", + -- lazy = false, + -- dependencies = { "nvim-tree/nvim-web-devicons" }, + -- opts = { + -- -- your configuration comes here + -- -- or leave it empty to use the default settings + -- -- refer to the configuration section below + -- }, + -- } + + -- { + -- "f-person/auto-dark-mode.nvim", + -- lazy = false, + -- enabled = true, + -- config = { + -- update_interval = 1000, + -- set_dark_mode = function() + -- vim.api.nvim_set_option("background", "dark") + -- -- vim.cmd("colorscheme gruvbox") + -- local M = require("base46") + -- M.override_theme(M, auto_dark_mode.dark_theme) + -- end, + -- set_light_mode = function() + -- vim.api.nvim_set_option("background", "light") + -- -- vim.cmd("colorscheme gruvbox") + -- local M = require("base46") + -- M.override_theme(auto_dark_mode.light_theme) + -- end, + -- }, + -- } +} + +return plugins