diff --git a/nvchad-config/README.md b/nvchad-config/README.md new file mode 100644 index 0000000..fb1035f --- /dev/null +++ b/nvchad-config/README.md @@ -0,0 +1,11 @@ +# Custom nvchad config + +## Prequisites + +* [neovim](https://neovim.io/) +* [nvchad](https://nvchad.com/) + +## Install + +Copy contents of this dir to `~/.config/nvim/custom`. + diff --git a/nvchad-config/chadrc.lua b/nvchad-config/chadrc.lua new file mode 100644 index 0000000..0cf2d9c --- /dev/null +++ b/nvchad-config/chadrc.lua @@ -0,0 +1,21 @@ +---@type ChadrcConfig +local M = {} + +-- Path to overriding theme and highlights files +local highlights = require "custom.highlights" + +M.ui = { + theme = "one_light", + theme_toggle = { "one_light", "onedark" }, + transparency = true, + + 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/nvchad-config/configs/conform.lua b/nvchad-config/configs/conform.lua new file mode 100644 index 0000000..76c6c30 --- /dev/null +++ b/nvchad-config/configs/conform.lua @@ -0,0 +1,25 @@ +--type conform.options +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/nvchad-config/configs/lspconfig.lua b/nvchad-config/configs/lspconfig.lua new file mode 100644 index 0000000..9a6a550 --- /dev/null +++ b/nvchad-config/configs/lspconfig.lua @@ -0,0 +1,33 @@ +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 = { + -- front-end + "html", + "cssls", + "tsserver", + -- back-end + "gopls", + -- static files + "jsonls", + "yamlls", + -- docker + "dockerls", + "docker_compose_language_service", +} + +for _, lsp in ipairs(servers) do + lspconfig[lsp].setup { + on_attach = on_attach, + capabilities = capabilities, + } +end + +lspconfig.intelephense.setup{ + filetypes = { 'php', 'ctp' } +} + +-- lspconfig.pyright.setup { blabla} + diff --git a/nvchad-config/configs/overrides.lua b/nvchad-config/configs/overrides.lua new file mode 100644 index 0000000..34290b4 --- /dev/null +++ b/nvchad-config/configs/overrides.lua @@ -0,0 +1,69 @@ +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", + "json-lsp", + "yaml-language-server", + -- c/cpp stuff + "clangd", + "clang-format", + -- golang stuff + "gopls", + "goimports", + -- php stuff + "intelephense", + -- docker + "docker-compose-language-service", + "dockerfile-language-server", + -- shell stuff + "shfmt", + }, +} + +-- git support in nvimtree +M.nvimtree = { + git = { + enable = true, + }, + + renderer = { + highlight_git = true, + icons = { + show = { + git = true, + }, + }, + }, +} + +return M diff --git a/nvchad-config/highlights.lua b/nvchad-config/highlights.lua new file mode 100644 index 0000000..ebf2dfb --- /dev/null +++ b/nvchad-config/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/nvchad-config/init.lua b/nvchad-config/init.lua new file mode 100644 index 0000000..094716f --- /dev/null +++ b/nvchad-config/init.lua @@ -0,0 +1,8 @@ +-- local autocmd = vim.api.nvim_create_autocmd + +-- Auto resize panes when resizing nvim window +-- autocmd("VimResized", { +-- pattern = "*", +-- command = "tabdo wincmd =", +-- }) + diff --git a/nvchad-config/mappings.lua b/nvchad-config/mappings.lua new file mode 100644 index 0000000..40c3f4e --- /dev/null +++ b/nvchad-config/mappings.lua @@ -0,0 +1,44 @@ +---@type MappingsTable +local M = {} + +M.general = { + n = { + [""] = { + function() + require("nvterm.terminal").toggle "vertical" + end, + }, + [""] = { + function() + require("nvterm.terminal").toggle "horizontal" + end, + }, + ["\\"] = { ":vsplit ", "Vertical split" }, + -- format with conform + ["fm"] = { + function() + require("conform").format() + end, + "formatting", + } + }, + v = { + [">"] = { ">gv", "indent"}, + }, + t = { + [""] = { + function() + require("nvterm.terminal").toggle "vertical" + end, + }, + [""] = { + function() + require("nvterm.terminal").toggle "horizontal" + end, + }, + }, +} + +-- more keybinds! + +return M diff --git a/nvchad-config/plugins.lua b/nvchad-config/plugins.lua new file mode 100644 index 0000000..9d09d71 --- /dev/null +++ b/nvchad-config/plugins.lua @@ -0,0 +1,65 @@ +local overrides = require("custom.configs.overrides") + +---@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 + }, + + { + "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, + }, + + { + "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, + -- } +} + +return plugins