diff --git a/.gitignore b/.gitignore index c022b3f..b513d1c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,3 @@ -plugin -custom spell ftplugin coc-settings.json diff --git a/lua/core/default_config.lua b/lua/core/default_config.lua index a151df5..3fdbe5a 100644 --- a/lua/core/default_config.lua +++ b/lua/core/default_config.lua @@ -10,9 +10,9 @@ M.ui = { hl_add = {}, hl_override = {}, changed_themes = {}, - theme_toggle = { "onedark", "one_light" }, - theme = "onedark", -- default theme - transparency = false, + theme_toggle = { "gatekeeper", "one_light" }, + theme = "gatekeeper", -- default theme + transparency = true, lsp_semantic_tokens = false, -- needs nvim v0.9, just adds highlight groups for lsp semantic tokens -- https://github.com/NvChad/base46/tree/v2.0/lua/base46/extended_integrations diff --git a/lua/core/init.lua b/lua/core/init.lua index 8fe26e2..145655e 100644 --- a/lua/core/init.lua +++ b/lua/core/init.lua @@ -6,7 +6,7 @@ local config = require("core.utils").load_config() g.nvchad_theme = config.ui.theme g.base46_cache = vim.fn.stdpath "data" .. "/nvchad/base46/" g.toggle_theme_icon = "  " -g.transparency = config.ui.transparency +g.transparency = true -------------------------------------- options ------------------------------------------ opt.laststatus = 3 -- global statusline @@ -17,10 +17,10 @@ opt.cursorline = true -- Indenting opt.expandtab = true -opt.shiftwidth = 2 +opt.shiftwidth = 4 opt.smartindent = true -opt.tabstop = 2 -opt.softtabstop = 2 +opt.tabstop = 4 +opt.softtabstop = 4 opt.fillchars = { eob = " " } opt.ignorecase = true @@ -31,6 +31,7 @@ opt.mouse = "a" opt.number = true opt.numberwidth = 2 opt.ruler = false +opt.relativenumber = true -- disable nvim intro opt.shortmess:append "sI" @@ -92,6 +93,7 @@ vim.api.nvim_create_autocmd("BufWritePost", { vim.g.nvchad_theme = config.ui.theme vim.g.transparency = config.ui.transparency + vim.g.transparency = true -- statusline require("plenary.reload").reload_module("nvchad_ui.statusline." .. config.ui.statusline.theme) diff --git a/lua/core/mappings.lua b/lua/core/mappings.lua index 625d4fc..302c848 100644 --- a/lua/core/mappings.lua +++ b/lua/core/mappings.lua @@ -16,31 +16,41 @@ M.general = { }, n = { - [""] = { ":noh ", "Clear highlights" }, + ["n"] = { ":noh ", "Clear highlights" }, + ["rr"] = { ":source $MYVIMRC", "Reload config file" }, -- switch between windows [""] = { "h", "Window left" }, [""] = { "l", "Window right" }, [""] = { "j", "Window down" }, [""] = { "k", "Window up" }, + [""] = { " tab Git diff %", "Git diff this file" }, + [""] = { " tab Git diff", "Git diff global" }, + -- save [""] = { " w ", "Save file" }, -- Copy all - [""] = { " %y+ ", "Copy whole file" }, + -- [""] = { " %y+ ", "Copy whole file" }, + + -- Quit + [""] = { " q! ", "Force quit window" }, -- line numbers - ["n"] = { " set nu! ", "Toggle line number" }, - ["rn"] = { " set rnu! ", "Toggle relative number" }, + -- ["n"] = { " set nu! ", "Toggle line number" }, + -- ["rn"] = { " set rnu! ", "Toggle relative number" }, -- Allow moving the cursor through wrapped lines with j, k, and -- http://www.reddit.com/r/vim/comments/2k4cbr/problem_with_gj_and_gk/ -- empty mode is same as using :map -- also don't use g[j|k] when in operator pending mode, so it doesn't alter d, y or c behaviour - ["j"] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', "Move down", opts = { expr = true } }, - ["k"] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', "Move up", opts = { expr = true } }, - [""] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', "Move up", opts = { expr = true } }, - [""] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', "Move down", opts = { expr = true } }, + -- ["j"] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', "Move down", opts = { expr = true } }, + -- ["k"] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', "Move up", opts = { expr = true } }, + -- [""] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', "Move up", opts = { expr = true } }, + -- [""] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', "Move down", opts = { expr = true } }, + + ["y"] = {" :w! /tmp/vimtmp", "Save into a global tmp file"}, + ["p"] = {" :r! cat /tmp/vimtmp", "Restore from the global tmp file"}, -- new buffer ["b"] = { " enew ", "New buffer" }, @@ -52,19 +62,29 @@ M.general = { }, v = { - [""] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', "Move up", opts = { expr = true } }, - [""] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', "Move down", opts = { expr = true } }, + -- [""] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', "Move up", opts = { expr = true } }, + -- [""] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', "Move down", opts = { expr = true } }, }, x = { - ["j"] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', "Move down", opts = { expr = true } }, - ["k"] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', "Move up", opts = { expr = true } }, + -- ["j"] = { 'v:count || mode(1)[0:1] == "no" ? "j" : "gj"', "Move down", opts = { expr = true } }, + -- ["k"] = { 'v:count || mode(1)[0:1] == "no" ? "k" : "gk"', "Move up", opts = { expr = true } }, -- Don't copy the replaced text after pasting in visual mode -- https://vim.fandom.com/wiki/Replace_a_word_with_yanked_text#Alternative_mapping_for_paste ["p"] = { 'p:let @+=@0:let @"=@0', "Dont copy replaced text", opts = { silent = true } }, }, } +M.gitstuffs = { + + n = { + [""] = { " vertical topleft Git vertical resize 50", "Show Git status on a left pane" }, + [""] = { " Flog -all", "Show git tree" }, + [""] = { " TagbarToggle", "Show tagbar" }, + } + +} + M.tabufline = { plugin = true, @@ -259,10 +279,10 @@ M.telescope = { 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" }, + [""] = { " Telescope find_files ", "Find files" }, + [""] = { " Telescope find_files follow=true no_ignore=true hidden=true ", "Find all" }, + [""] = { " Telescope live_grep ", "Live grep" }, + [""] = { " 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" }, diff --git a/lua/custom/chadrc.lua b/lua/custom/chadrc.lua new file mode 100644 index 0000000..7633979 --- /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 = "gatekeeper", + theme_toggle = { "gatekeeper", "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/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/null-ls.lua b/lua/custom/configs/null-ls.lua new file mode 100644 index 0000000..cfdb3e0 --- /dev/null +++ b/lua/custom/configs/null-ls.lua @@ -0,0 +1,25 @@ +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, +} + +null_ls.setup { + debug = true, + sources = sources, +} 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..608a8d9 --- /dev/null +++ b/lua/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/lua/custom/mappings.lua b/lua/custom/mappings.lua new file mode 100644 index 0000000..9ce068a --- /dev/null +++ b/lua/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/lua/custom/plugins.lua b/lua/custom/plugins.lua new file mode 100644 index 0000000..2ed8db8 --- /dev/null +++ b/lua/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/lua/plugins/init.lua b/lua/plugins/init.lua index 2f711af..e7c8cbc 100644 --- a/lua/plugins/init.lua +++ b/lua/plugins/init.lua @@ -3,6 +3,14 @@ local default_plugins = { "nvim-lua/plenary.nvim", + {"tpope/vim-fugitive", lazy=false}, + {"rbong/vim-flog", lazy=false}, + {"tpope/vim-surround", lazy=false}, + {"tpope/vim-obsession", lazy=false}, + {"preservim/tagbar", lazy=false}, + {"ludovicchabant/vim-gutentags", lazy=false}, + + {"nvim-telescope/telescope-fzf-native.nvim", run="make", lazy=false}, -- nvchad plugins { "NvChad/extensions", branch = "v2.0" },