add user_config

This commit is contained in:
siduck76 2021-08-12 17:28:03 +05:30
parent d5c64d335e
commit 0efa21c9c9
10 changed files with 253 additions and 84 deletions

View file

@ -18,7 +18,7 @@ dependencies=(
) )
preserved_files=( preserved_files=(
"lua/mappings.lua" "lua/mappings.lua"
"lua/user_config.lua" "lua/chadrc.lua"
) )
# https://stackoverflow.com/questions/5947742/how-to-change-the-output-color-of-echo-in-linux # https://stackoverflow.com/questions/5947742/how-to-change-the-output-color-of-echo-in-linux

100
lua/chadrc.lua Normal file
View file

@ -0,0 +1,100 @@
local M = {
ui = {
theme = "onedark"
},
options = {
permanent_undo = true,
ruler = false,
hidden = true,
ignorecase = true,
mouse = "a",
cmdheight = 1,
updatetime = 250,
timeoutlen = 400,
clipboard = "unnamedplus",
number = true,
numberwidth = 2,
expandtab = true,
shiftwidth = 2,
smartindent = true,
mapleader = " ",
autosave = false
},
-- enable / disable plugins (true for disable)
plugin_status = {
better_esc = false,
nvim_bufferline = false,
galaxyline = false,
nvim_colorizer = false,
lspkind = false,
lspsignature = false,
neoformat = false,
gitsigns = false,
vim_matchup = false,
dashboard_nvim = false,
autosave_nvim = false,
truezen_nvim = false,
blankline = false,
vim_fugitive = false,
nvim_comment = false,
neoscroll_nvim = false
},
-- make sure you dont use same keys twice
mappings = {
truezen = {
ataraxisMode = "<leader>zz",
minimalisticmode = "<leader>zm",
focusmode = "<leader>zf"
},
comment_nvim = {
comment_toggle = "<leader>/"
},
nvimtree = {
treetoggle = "<C-n>"
},
neoformat = {
format = "<leader>fm"
},
dashboard = {
open = "<leader>db",
newfile = "<leader>fn",
bookmarks = "<leader>bm",
sessionload = "<leader>l",
sessionsave = "<leader>s"
},
telescope = {
live_grep = "<leader>fw",
git_status = "<leader>gt",
git_commits = "<leader>cm",
find_files = "<leader>ff",
media_files = "<leader>fp",
buffers = "<leader>fb",
help_tags = "<leader>fh",
oldfiles = "<leader>fo",
themes = "<leader>th"
},
bufferline = {
new_buffer = "<S-t>",
newtab = "<C-t>b",
close = "<S-x>",
cycleNext = "<TAB>",
cyclePrev = "<S-Tab>"
},
fugitive = {
Git = "<leader>gs",
diffget_2 = "<leader>gh",
diffget_3 = "<leader>gl",
git_blame = "<leader>gb"
},
misc = {
openTerm_right = "<C-l>",
openTerm_bottom = "<C-x>",
openTerm_currentBuf = "<C-t>t",
copywhole_file = "<C-a>",
toggle_linenr = "<leader>n",
esc_Termmode = "jk"
}
}
}
return M

View file

@ -76,7 +76,7 @@ fg("NvimTreeVertSplit", darker_black)
bg("NvimTreeVertSplit", darker_black) bg("NvimTreeVertSplit", darker_black)
fg("NvimTreeEndOfBuffer", darker_black) fg("NvimTreeEndOfBuffer", darker_black)
vim.cmd("hi NvimTreeRootFolder gui=underline guifg=" .. purple) cmd("hi NvimTreeRootFolder gui=underline guifg=" .. purple)
bg("NvimTreeNormal", darker_black) bg("NvimTreeNormal", darker_black)
fg_bg("NvimTreeStatuslineNc", darker_black, darker_black) fg_bg("NvimTreeStatuslineNc", darker_black, darker_black)
fg_bg("NvimTreeWindowPicker", red, black2) fg_bg("NvimTreeWindowPicker", red, black2)

View file

@ -1,3 +1,9 @@
local user_map = require("chadrc").mappings
local miscMap = user_map.misc
local M = {}
local cmd = vim.cmd
local function map(mode, lhs, rhs, opts) local function map(mode, lhs, rhs, opts)
local options = {noremap = true, silent = true} local options = {noremap = true, silent = true}
if opts then if opts then
@ -30,26 +36,31 @@ map("", "<Down>", 'v:count ? "j" : "gj"', {expr = true})
map("", "<Up>", 'v:count ? "k" : "gk"', {expr = true}) map("", "<Up>", 'v:count ? "k" : "gk"', {expr = true})
-- OPEN TERMINALS -- -- OPEN TERMINALS --
map("n", "<C-l>", ":vnew +terminal | setlocal nobuflisted <CR>", opt) -- term over right map("n", miscMap.openTerm_right, ":vnew +terminal | setlocal nobuflisted <CR>", opt) -- term over right
map("n", "<C-x>", ":10new +terminal | setlocal nobuflisted <CR>", opt) -- term bottom map("n", miscMap.openTerm_bottom, ":10new +terminal | setlocal nobuflisted <CR>", opt) -- term bottom
map("n", "<C-t>t", ":terminal <CR>", opt) -- term buffer map("n", miscMap.openTerm_currentBuf, ":terminal <CR>", opt) -- term buffer
-- copy whole file content -- copy whole file content
map("n", "<C-a>", ":%y+<CR>", opt) map("n", miscMap.copywhole_file, ":%y+<CR>", opt)
-- toggle numbers -- toggle numbers
map("n", "<leader>n", ":set nu!<CR>", opt) map("n", miscMap.toggle_linenr, ":set nu!<CR>", opt)
-- Truezen.nvim M.truezen = function()
map("n", "<leader>zz", ":TZAtaraxis<CR>", opt) local m = user_map.truezen
map("n", "<leader>zm", ":TZMinimalist<CR>", opt)
map("n", "<leader>zf", ":TZFocus<CR>", opt) map("n", m.ataraxisMode, ":TZAtaraxis<CR>", opt)
map("n", m.minimalisticmode, ":TZMinimalist<CR>", opt)
map("n", m.focusmode, ":TZFocus<CR>", opt)
end
map("n", "<C-s>", ":w <CR>", opt) map("n", "<C-s>", ":w <CR>", opt)
-- Commenter Keybinding M.comment_nvim = function()
map("n", "<leader>/", ":CommentToggle<CR>", opt) local m = user_map.comment_nvim.comment_toggle
map("v", "<leader>/", ":CommentToggle<CR>", opt) map("n", m, ":CommentToggle<CR>", opt)
map("v", m, ":CommentToggle<CR>", opt)
end
-- compe stuff -- compe stuff
local t = function(str) local t = function(str)
@ -112,54 +123,74 @@ map("i", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true})
map("s", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true}) map("s", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true})
map("i", "<CR>", "v:lua.completions()", {expr = true}) map("i", "<CR>", "v:lua.completions()", {expr = true})
-- nvimtree M.nvimtree = function()
map("n", "<C-n>", ":NvimTreeToggle<CR>", opt) local m = user_map.nvimtree.treetoggle
-- format code map("n", m, ":NvimTreeToggle<CR>", opt)
map("n", "<Leader>fm", ":Neoformat<CR>", opt) end
-- dashboard stuff M.neoformat = function()
map("n", "<Leader>db", ":Dashboard<CR>", opt) local m = user_map.neoformat.format
map("n", "<Leader>fn", ":DashboardNewFile<CR>", opt) map("n", m, ":Neoformat<CR>", opt)
map("n", "<Leader>bm", ":DashboardJumpMarks<CR>", opt) end
map("n", "<C-s>l", ":SessionLoad<CR>", opt)
map("n", "<C-s>s", ":SessionSave<CR>", opt)
-- Telescope M.dashboard = function()
map("n", "<Leader>fw", ":Telescope live_grep<CR>", opt) local m = user_map.dashboard
map("n", "<Leader>gt", ":Telescope git_status <CR>", opt)
map("n", "<Leader>cm", ":Telescope git_commits <CR>", opt)
map("n", "<Leader>ff", ":Telescope find_files <CR>", opt)
map("n", "<Leader>fp", ":Telescope media_files <CR>", opt)
map("n", "<Leader>fb", ":Telescope buffers<CR>", opt)
map("n", "<Leader>fh", ":Telescope help_tags<CR>", opt)
map("n", "<Leader>fo", ":Telescope oldfiles<CR>", opt)
map("n", "<Leader>th", ":Telescope themes<CR>", opt)
-- bufferline tab stuff map("n", m.open, ":Dashboard<CR>", opt)
map("n", "<S-t>", ":enew<CR>", opt) -- new buffer map("n", m.newfile, ":DashboardNewFile<CR>", opt)
map("n", "<C-t>b", ":tabnew<CR>", opt) -- new tab map("n", m.bookmarks, ":DashboardJumpMarks<CR>", opt)
map("n", "<S-x>", ":bd!<CR>", opt) -- close tab map("n", m.sessionload, ":SessionLoad<CR>", opt)
map("n", m.sessionsave, ":SessionSave<CR>", opt)
end
-- move between tabs M.telescope = function()
map("n", "<TAB>", ":BufferLineCycleNext<CR>", opt) local m = user_map.telescope
map("n", "<S-TAB>", ":BufferLineCyclePrev<CR>", opt)
map("n", m.live_grep, ":Telescope live_grep<CR>", opt)
map("n", m.git_status, ":Telescope git_status <CR>", opt)
map("n", m.git_commits, ":Telescope git_commits <CR>", opt)
map("n", m.find_files, ":Telescope find_files <CR>", opt)
map("n", m.media_files, ":Telescope media_files <CR>", opt)
map("n", m.buffers, ":Telescope buffers<CR>", opt)
map("n", m.help_tags, ":Telescope help_tags<CR>", opt)
map("n", m.oldfiles, ":Telescope oldfiles<CR>", opt)
map("n", m.themes, ":Telescope themes<CR>", opt)
end
M.bufferline = function()
local m = user_map.bufferline
map("n", m.new_buffer, ":enew<CR>", opt) -- new buffer
map("n", m.newtab, ":tabnew<CR>", opt) -- new tab
map("n", m.close, ":bd!<CR>", opt) -- close buffer
-- move between tabs
map("n", m.cycleNext, ":BufferLineCycleNext<CR>", opt)
map("n", m.cyclePrev, ":BufferLineCyclePrev<CR>", opt)
end
-- use ESC to turn off search highlighting -- use ESC to turn off search highlighting
map("n", "<Esc>", ":noh<CR>", opt) map("n", "<Esc>", ":noh<CR>", opt)
-- get out of terminal with jk -- get out of terminal with jk
map("t", "jk", "<C-\\><C-n>", opt) map("t", miscMap.esc_Termmode, "<C-\\><C-n>", opt)
-- Packer commands till because we are not loading it at startup -- Packer commands till because we are not loading it at startup
vim.cmd("silent! command PackerCompile lua require 'pluginList' require('packer').compile()") cmd("silent! command PackerCompile lua require 'pluginList' require('packer').compile()")
vim.cmd("silent! command PackerInstall lua require 'pluginList' require('packer').install()") cmd("silent! command PackerInstall lua require 'pluginList' require('packer').install()")
vim.cmd("silent! command PackerStatus lua require 'pluginList' require('packer').status()") cmd("silent! command PackerStatus lua require 'pluginList' require('packer').status()")
vim.cmd("silent! command PackerSync lua require 'pluginList' require('packer').sync()") cmd("silent! command PackerSync lua require 'pluginList' require('packer').sync()")
vim.cmd("silent! command PackerUpdate lua require 'pluginList' require('packer').update()") cmd("silent! command PackerUpdate lua require 'pluginList' require('packer').update()")
-- Vim Fugitive M.fugitive = function()
map("n", "<Leader>gs", ":Git<CR>", opt) local m = user_map.fugitive
map("n", "<Leader>gh", ":diffget //2<CR>", opt)
map("n", "<Leader>gl", ":diffget //3<CR>", opt) map("n", m.Git, ":Git<CR>", opt)
map("n", "<Leader>gb", ":Git blame<CR>", opt) map("n", m.diffget_2, ":diffget //2<CR>", opt)
map("n", m.diffget_3, ":diffget //3<CR>", opt)
map("n", m.git_blame, ":Git blame<CR>", opt)
end
return M

View file

@ -1,20 +1,21 @@
local options = require("chadrc").options
local opt = vim.opt local opt = vim.opt
local g = vim.g local g = vim.g
opt.undofile = true opt.undofile = options.permanent_undo
opt.ruler = false opt.ruler = options.ruler
opt.hidden = true opt.hidden = options.hidden
opt.ignorecase = true opt.ignorecase = options.ignorecase
opt.splitbelow = true opt.splitbelow = true
opt.splitright = true opt.splitright = true
opt.termguicolors = true opt.termguicolors = true
opt.cul = true opt.cul = true
opt.mouse = "a" opt.mouse = options.mouse
opt.signcolumn = "yes" opt.signcolumn = "yes"
opt.cmdheight = 1 opt.cmdheight = options.cmdheight
opt.updatetime = 250 -- update interval for gitsigns opt.updatetime = options.updatetime -- update interval for gitsigns
opt.timeoutlen = 400 opt.timeoutlen = options.timeoutlen
opt.clipboard = "unnamedplus" opt.clipboard = options.clipboard
-- disable nvim intro -- disable nvim intro
opt.shortmess:append("sI") opt.shortmess:append("sI")
@ -23,21 +24,21 @@ opt.shortmess:append("sI")
opt.fillchars = {eob = " "} opt.fillchars = {eob = " "}
-- Numbers -- Numbers
opt.number = true opt.number = options.number
opt.numberwidth = 2 opt.numberwidth = options.numberwidth
-- opt.relativenumber = true -- opt.relativenumber = true
-- Indenline -- Indenline
opt.expandtab = true opt.expandtab = options.expandtab
opt.shiftwidth = 2 opt.shiftwidth = options.shiftwidth
opt.smartindent = true opt.smartindent = options.smartindent
-- go to previous/next line with h,l,left arrow and right arrow -- go to previous/next line with h,l,left arrow and right arrow
-- when cursor reaches end/beginning of line -- when cursor reaches end/beginning of line
opt.whichwrap:append("<>hl") opt.whichwrap:append("<>hl")
g.mapleader = " " g.mapleader = options.mapleader
g.auto_save = false g.auto_save = options.autosave
-- disable builtin vim plugins -- disable builtin vim plugins
local disabled_built_ins = { local disabled_built_ins = {
@ -62,7 +63,7 @@ local disabled_built_ins = {
} }
for _, plugin in pairs(disabled_built_ins) do for _, plugin in pairs(disabled_built_ins) do
vim.g["loaded_" .. plugin] = 1 g["loaded_" .. plugin] = 1
end end
-- Don't show status line on vim terminals -- Don't show status line on vim terminals

View file

@ -1,4 +1,6 @@
vim.cmd("packadd packer.nvim") local cmd = vim.cmd
cmd("packadd packer.nvim")
local present, packer = pcall(require, "packer") local present, packer = pcall(require, "packer")
@ -19,7 +21,7 @@ if not present then
} }
) )
vim.cmd("packadd packer.nvim") cmd("packadd packer.nvim")
present, packer = pcall(require, "packer") present, packer = pcall(require, "packer")
if present then if present then
@ -33,9 +35,13 @@ return packer.init {
display = { display = {
open_fn = function() open_fn = function()
return require("packer.util").float {border = "single"} return require("packer.util").float {border = "single"}
end end,
prompt_border = "single"
}, },
git = { git = {
clone_timeout = 600 -- Timeout, in seconds, for git clones clone_timeout = 600 -- Timeout, in seconds, for git clones
} },
auto_clean = true,
compile_on_sync = true
-- auto_reload_compiled = true
} }

View file

@ -1,3 +1,5 @@
local plugin_status = require("chadrc").plugin_status
local present, _ = pcall(require, "packerInit") local present, _ = pcall(require, "packerInit")
local packer local packer
@ -18,6 +20,7 @@ return packer.startup(
use { use {
"jdhao/better-escape.vim", "jdhao/better-escape.vim",
disable = plugin_status.better_esc,
event = "InsertEnter", event = "InsertEnter",
config = function() config = function()
require "plugins.others".escape() require "plugins.others".escape()
@ -26,14 +29,19 @@ return packer.startup(
use { use {
"akinsho/nvim-bufferline.lua", "akinsho/nvim-bufferline.lua",
disable = plugin_status.nvim_bufferline,
after = "nvim-base16.lua", after = "nvim-base16.lua",
config = function() config = function()
require "plugins.bufferline" require "plugins.bufferline"
end,
setup = function()
require "mappings".bufferline()
end end
} }
use { use {
"glepnir/galaxyline.nvim", "glepnir/galaxyline.nvim",
disable = plugin_status.galaxyline,
after = "nvim-base16.lua", after = "nvim-base16.lua",
config = function() config = function()
require "plugins.statusline" require "plugins.statusline"
@ -51,6 +59,7 @@ return packer.startup(
use { use {
"norcalli/nvim-colorizer.lua", "norcalli/nvim-colorizer.lua",
disable = plugin_status.nvim_colorizer,
event = "BufRead", event = "BufRead",
config = function() config = function()
require("plugins.others").colorizer() require("plugins.others").colorizer()
@ -81,6 +90,7 @@ return packer.startup(
use { use {
"onsails/lspkind-nvim", "onsails/lspkind-nvim",
disable = plugin_status.lspkind,
event = "BufEnter", event = "BufEnter",
config = function() config = function()
require("plugins.others").lspkind() require("plugins.others").lspkind()
@ -89,6 +99,7 @@ return packer.startup(
use { use {
"ray-x/lsp_signature.nvim", "ray-x/lsp_signature.nvim",
disable = plugin_status.lspsignature,
after = "nvim-lspconfig", after = "nvim-lspconfig",
config = function() config = function()
require("plugins.others").signature() require("plugins.others").signature()
@ -121,7 +132,11 @@ return packer.startup(
use { use {
"sbdchd/neoformat", "sbdchd/neoformat",
cmd = "Neoformat" disable = plugin_status.neoformat,
cmd = "Neoformat",
setup = function()
require "mappings".neoformat()
end
} }
-- file managing , picker etc -- file managing , picker etc
@ -130,6 +145,9 @@ return packer.startup(
cmd = "NvimTreeToggle", cmd = "NvimTreeToggle",
config = function() config = function()
require "plugins.nvimtree" require "plugins.nvimtree"
end,
setup = function()
require "mappings".nvimtree()
end end
} }
@ -155,6 +173,9 @@ return packer.startup(
cmd = "Telescope", cmd = "Telescope",
config = function() config = function()
require "plugins.telescope" require "plugins.telescope"
end,
setup = function()
require "mappings".telescope()
end end
} }
@ -171,6 +192,7 @@ return packer.startup(
-- git stuff -- git stuff
use { use {
"lewis6991/gitsigns.nvim", "lewis6991/gitsigns.nvim",
disable = plugin_status.gitsigns,
after = "plenary.nvim", after = "plenary.nvim",
config = function() config = function()
require "plugins.gitsigns" require "plugins.gitsigns"
@ -188,19 +210,23 @@ return packer.startup(
use { use {
"andymass/vim-matchup", "andymass/vim-matchup",
disable = plugin_status.vim_matchup,
event = "CursorMoved" event = "CursorMoved"
} }
use { use {
"terrortylor/nvim-comment", "terrortylor/nvim-comment",
disable = plugin_status.nvim_comment,
cmd = "CommentToggle", cmd = "CommentToggle",
config = function() config = function()
require("plugins.others").comment() require("plugins.others").comment()
require "mappings".comment_nvim()
end end
} }
use { use {
"glepnir/dashboard-nvim", "glepnir/dashboard-nvim",
disable = plugin_status.dashboard_nvim,
cmd = { cmd = {
"Dashboard", "Dashboard",
"DashboardNewFile", "DashboardNewFile",
@ -210,11 +236,13 @@ return packer.startup(
}, },
setup = function() setup = function()
require "plugins.dashboard" require "plugins.dashboard"
require "mappings".dashboard()
end end
} }
-- load autosave only if its globally enabled -- load autosave only if its globally enabled
use { use {
disable = plugin_status.autosave_nvim,
"Pocco81/AutoSave.nvim", "Pocco81/AutoSave.nvim",
config = function() config = function()
require "plugins.autosave" require "plugins.autosave"
@ -227,6 +255,7 @@ return packer.startup(
-- smooth scroll -- smooth scroll
use { use {
"karb94/neoscroll.nvim", "karb94/neoscroll.nvim",
disable = plugin_status.neoscroll_nvim,
event = "WinScrolled", event = "WinScrolled",
config = function() config = function()
require("plugins.others").neoscroll() require("plugins.others").neoscroll()
@ -235,6 +264,7 @@ return packer.startup(
use { use {
"Pocco81/TrueZen.nvim", "Pocco81/TrueZen.nvim",
disable = plugin_status.truezen_nvim,
cmd = { cmd = {
"TZAtaraxis", "TZAtaraxis",
"TZMinimalist", "TZMinimalist",
@ -242,6 +272,9 @@ return packer.startup(
}, },
config = function() config = function()
require "plugins.zenmode" require "plugins.zenmode"
end,
setup = function()
require "mappings".truezen()
end end
} }
@ -249,6 +282,7 @@ return packer.startup(
use { use {
"lukas-reineke/indent-blankline.nvim", "lukas-reineke/indent-blankline.nvim",
disable = plugin_status.blankline,
event = "BufRead", event = "BufRead",
setup = function() setup = function()
require("plugins.others").blankline() require("plugins.others").blankline()
@ -257,9 +291,13 @@ return packer.startup(
use { use {
"tpope/vim-fugitive", "tpope/vim-fugitive",
disable = plugin_status.vim_fugitive,
cmd = { cmd = {
"Git" "Git"
} },
setup = function()
require "mappings".fugitive()
end
} }
end end
) )

View file

@ -1,4 +1,4 @@
local chad_theme = require("user_config").ui.theme local chad_theme = require("chadrc").ui.theme
vim.g.nvchad_theme = chad_theme vim.g.nvchad_theme = chad_theme
local present, base16 = pcall(require, "base16") local present, base16 = pcall(require, "base16")

View file

@ -1,7 +0,0 @@
local M = {
ui = {
theme = "onedark"
}
}
return M

View file

@ -84,7 +84,7 @@ M.change_theme = function(current_theme, new_theme)
return return
end end
local file = vim.fn.stdpath("config") .. "/lua/user_config.lua" local file = vim.fn.stdpath("config") .. "/lua/chadrc.lua"
-- store in data variable -- store in data variable
local data = assert(M.file("r", file)) local data = assert(M.file("r", file))
local find = "theme = .?" .. current_theme .. ".?" local find = "theme = .?" .. current_theme .. ".?"