diff --git a/lua/custom b/lua/custom deleted file mode 160000 index 5195a38..0000000 --- a/lua/custom +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 5195a38b1dfbbe7831e3dfcd0e3e07ac6ff05b58 diff --git a/lua/custom/chadrc.lua b/lua/custom/chadrc.lua new file mode 100644 index 0000000..f22338e --- /dev/null +++ b/lua/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 = "kanagawa", + theme_toggle = { "kanagawa", "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/lua/custom/configs/conform.lua b/lua/custom/configs/conform.lua new file mode 100644 index 0000000..4b142bd --- /dev/null +++ b/lua/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/lua/custom/configs/lspconfig.lua b/lua/custom/configs/lspconfig.lua new file mode 100644 index 0000000..d6f7f2b --- /dev/null +++ b/lua/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/lua/custom/configs/overrides.lua b/lua/custom/configs/overrides.lua new file mode 100644 index 0000000..c4cd2c7 --- /dev/null +++ b/lua/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/lua/custom/highlights.lua b/lua/custom/highlights.lua new file mode 100644 index 0000000..ebf2dfb --- /dev/null +++ b/lua/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/lua/custom/init.lua b/lua/custom/init.lua new file mode 100644 index 0000000..ccb9501 --- /dev/null +++ b/lua/custom/init.lua @@ -0,0 +1,9 @@ +local opt = vim.opt +local g = vim.g +g.maplocalleader = ";" +opt.foldmethod = "indent" +opt.foldnestmax = 10 +opt.foldlevel = 4 +opt.signcolumn = "yes" +opt.spelllang = "en,de" +opt.clipboard = "" -- dont just use the system clipboard diff --git a/lua/custom/mappings.lua b/lua/custom/mappings.lua new file mode 100644 index 0000000..8edbd20 --- /dev/null +++ b/lua/custom/mappings.lua @@ -0,0 +1,176 @@ +---@type MappingsTable +local M = {} + +M.disabled = { + n = { + ["h"] = "", + ["ff"] = "", + [""] = "", + [""] = "", + }, +} + +M.lazygit = { + plugin = true, + n = { + ["gg"] = { " LazyGit ", "Open LazyGit" }, + }, +} + +M.clipboard = { + plugin = false, + n = { + ["y"] = { '"+y', "yank to system" }, + ["Y"] = { '"+Y', "yank to system" }, + ["yy"] = { '"+y', "yank to system" }, + }, + v = { + ["y"] = { '"+y', "yank to system" }, + ["Y"] = { '"+Y', "yank to system" }, + ["yy"] = { '"+y', "yank to system" }, + }, +} + +M.telescope = { + plugin = true, + n = { + -- find + ["ff"] = { " Telescope find_files ", "Find files" }, + ["fa"] = { " Telescope find_files follow=true no_ignore=true hidden=true ", "Find all" }, + ["fw"] = { " Telescope live_grep ", "Live grep" }, + ["fb"] = { " Telescope buffers ", "Find buffers" }, + ["fh"] = { " Telescope help_tags ", "Help page" }, + ["fo"] = { " Telescope oldfiles ", "Find oldfiles" }, + ["fz"] = { " Telescope current_buffer_fuzzy_find ", "Find in current buffer" }, + + -- git + ["cm"] = { " Telescope git_commits ", "Git commits" }, + ["gt"] = { " Telescope git_status ", "Git status" }, + + -- pick a hidden term + ["pt"] = { " Telescope terms ", "Pick hidden term" }, + + -- theme switcher + ["th"] = { " Telescope themes ", "Nvchad themes" }, + + ["ma"] = { " Telescope marks ", "telescope bookmarks" }, + }, +} + +M.nvimtree = { + plugin = true, + n = { + -- toggle + [""] = { " NvimTreeToggle ", "Toggle nvimtree" }, + [""] = { " NvimTreeToggle ", "Toggle nvimtree" }, + + -- focus + ["e"] = { " NvimTreeFocus ", "Focus nvimtree" }, + }, +} + +M.movements = { + plugin = false, + i = { + --big move + [""] = { "", "big step down" }, + [""] = { "", "big step down" }, + + -- go to beginning and end + [""] = { "", "Beginning of line" }, + [""] = { "", "End of line" }, + + -- navigate within insert mode + [""] = { "", "Move left" }, + [""] = { "", "Move right" }, + [""] = { "", "Move down" }, + [""] = { "", "Move up" }, + }, + n = { + --big move + [""] = { "", "big step down" }, + [""] = { "", "big step down" }, + + -- go to beginning and end + ["H"] = { "", "Beginning of line" }, + ["L"] = { "", "End of line" }, + }, + v = { + --big move + [""] = { "", "big step down" }, + [""] = { "", "big step down" }, + + -- go to beginning and end + ["H"] = { "", "Beginning of line" }, + ["L"] = { "", "End of line" }, + }, + t = { + [""] = { + vim.api.nvim_replace_termcodes("", true, true, true), + "Escape terminal mode", + }, + }, +} + +M.edit = { + plugin = false, + n = { + -- easy newline + ["OO"] = { "O", "insert a line above", opts = { nowait = false } }, + ["oo"] = { "o", "insert a line below", opts = { nowait = false } }, + + -- split and join lines + ["jj"] = { " join ", "join lines" }, + + -- do something useful with the arrows + [""] = { " move-2", "Move line up", opts = { expr = true } }, + [""] = { " move+", "Move line down", opts = { expr = true } }, + [""] = { "<<", "Less indentation", opts = { expr = true } }, + [""] = { ">>", "More indentation", opts = { expr = true } }, + + -- format with conform + ["ff"] = { + function() + require("conform").format() + end, + "formatting", + }, + }, + v = { + [""] = { ""] = { ">gv", "More indentation" }, + }, + x = { + [""] = { "move'<-2gv=gv", "Move line up", opts = { expr = true } }, + [""] = { "move'<-2gv=gv", "Move line down", opts = { expr = true } }, + }, + t = { + --big move + [""] = { "", "big step down" }, + [""] = { "", "big step down" }, + }, +} + +M.ui = { + plugin = false, + n = { + -- toggle wrap + ["tw"] = { + function() + vim.opt_local.wrap = not vim.wo.wrap + vim.opt_local.breakindent = not vim.wo.breakindent + + if vim.wo.colorcolumn == "" then + vim.opt_local.colorcolumn = tostring(vim.bo.textwidth) + else + vim.opt_local.colorcolumn = "" + end + end, + "toggle wrap", + }, + }, +} + +-- more keybinds! + +return M diff --git a/lua/custom/plugins.lua b/lua/custom/plugins.lua new file mode 100644 index 0000000..1ea2cbc --- /dev/null +++ b/lua/custom/plugins.lua @@ -0,0 +1,73 @@ +local overrides = require "custom.configs.overrides" +local utils = require "core.utils" + +---@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, + }, + { + "ggandor/leap.nvim", + config = function() + require("leap").create_default_mappings() + end, + }, + { + "kdheepak/lazygit.nvim", + keys = { "gg" }, + cmd = "LazyGit", + -- optional for floating window border decoration + dependencies = { + "nvim-lua/plenary.nvim", + }, + init = function() + require("core.utils").load_mappings "lazygit" + end, + }, + { + "folke/which-key.nvim", + keys = { "", "", "", "", '"', "'", "`", "c", "v", "g" }, + }, +} + +return plugins