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=(
"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

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)
fg("NvimTreeEndOfBuffer", darker_black)
vim.cmd("hi NvimTreeRootFolder gui=underline guifg=" .. purple)
cmd("hi NvimTreeRootFolder gui=underline guifg=" .. purple)
bg("NvimTreeNormal", darker_black)
fg_bg("NvimTreeStatuslineNc", darker_black, darker_black)
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 options = {noremap = true, silent = true}
if opts then
@ -30,26 +36,31 @@ map("", "<Down>", 'v:count ? "j" : "gj"', {expr = true})
map("", "<Up>", 'v:count ? "k" : "gk"', {expr = true})
-- OPEN TERMINALS --
map("n", "<C-l>", ":vnew +terminal | setlocal nobuflisted <CR>", opt) -- term over right
map("n", "<C-x>", ":10new +terminal | setlocal nobuflisted <CR>", opt) -- term bottom
map("n", "<C-t>t", ":terminal <CR>", opt) -- term buffer
map("n", miscMap.openTerm_right, ":vnew +terminal | setlocal nobuflisted <CR>", opt) -- term over right
map("n", miscMap.openTerm_bottom, ":10new +terminal | setlocal nobuflisted <CR>", opt) -- term bottom
map("n", miscMap.openTerm_currentBuf, ":terminal <CR>", opt) -- term buffer
-- copy whole file content
map("n", "<C-a>", ":%y+<CR>", opt)
map("n", miscMap.copywhole_file, ":%y+<CR>", opt)
-- toggle numbers
map("n", "<leader>n", ":set nu!<CR>", opt)
map("n", miscMap.toggle_linenr, ":set nu!<CR>", opt)
-- Truezen.nvim
map("n", "<leader>zz", ":TZAtaraxis<CR>", opt)
map("n", "<leader>zm", ":TZMinimalist<CR>", opt)
map("n", "<leader>zf", ":TZFocus<CR>", opt)
M.truezen = function()
local m = user_map.truezen
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)
-- Commenter Keybinding
map("n", "<leader>/", ":CommentToggle<CR>", opt)
map("v", "<leader>/", ":CommentToggle<CR>", opt)
M.comment_nvim = function()
local m = user_map.comment_nvim.comment_toggle
map("n", m, ":CommentToggle<CR>", opt)
map("v", m, ":CommentToggle<CR>", opt)
end
-- compe stuff
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("i", "<CR>", "v:lua.completions()", {expr = true})
-- nvimtree
map("n", "<C-n>", ":NvimTreeToggle<CR>", opt)
M.nvimtree = function()
local m = user_map.nvimtree.treetoggle
-- format code
map("n", "<Leader>fm", ":Neoformat<CR>", opt)
map("n", m, ":NvimTreeToggle<CR>", opt)
end
-- dashboard stuff
map("n", "<Leader>db", ":Dashboard<CR>", opt)
map("n", "<Leader>fn", ":DashboardNewFile<CR>", opt)
map("n", "<Leader>bm", ":DashboardJumpMarks<CR>", opt)
map("n", "<C-s>l", ":SessionLoad<CR>", opt)
map("n", "<C-s>s", ":SessionSave<CR>", opt)
M.neoformat = function()
local m = user_map.neoformat.format
map("n", m, ":Neoformat<CR>", opt)
end
-- Telescope
map("n", "<Leader>fw", ":Telescope live_grep<CR>", opt)
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)
M.dashboard = function()
local m = user_map.dashboard
-- bufferline tab stuff
map("n", "<S-t>", ":enew<CR>", opt) -- new buffer
map("n", "<C-t>b", ":tabnew<CR>", opt) -- new tab
map("n", "<S-x>", ":bd!<CR>", opt) -- close tab
map("n", m.open, ":Dashboard<CR>", opt)
map("n", m.newfile, ":DashboardNewFile<CR>", opt)
map("n", m.bookmarks, ":DashboardJumpMarks<CR>", opt)
map("n", m.sessionload, ":SessionLoad<CR>", opt)
map("n", m.sessionsave, ":SessionSave<CR>", opt)
end
-- move between tabs
map("n", "<TAB>", ":BufferLineCycleNext<CR>", opt)
map("n", "<S-TAB>", ":BufferLineCyclePrev<CR>", opt)
M.telescope = function()
local m = user_map.telescope
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
map("n", "<Esc>", ":noh<CR>", opt)
-- 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
vim.cmd("silent! command PackerCompile lua require 'pluginList' require('packer').compile()")
vim.cmd("silent! command PackerInstall lua require 'pluginList' require('packer').install()")
vim.cmd("silent! command PackerStatus lua require 'pluginList' require('packer').status()")
vim.cmd("silent! command PackerSync lua require 'pluginList' require('packer').sync()")
vim.cmd("silent! command PackerUpdate lua require 'pluginList' require('packer').update()")
cmd("silent! command PackerCompile lua require 'pluginList' require('packer').compile()")
cmd("silent! command PackerInstall lua require 'pluginList' require('packer').install()")
cmd("silent! command PackerStatus lua require 'pluginList' require('packer').status()")
cmd("silent! command PackerSync lua require 'pluginList' require('packer').sync()")
cmd("silent! command PackerUpdate lua require 'pluginList' require('packer').update()")
-- Vim Fugitive
map("n", "<Leader>gs", ":Git<CR>", opt)
map("n", "<Leader>gh", ":diffget //2<CR>", opt)
map("n", "<Leader>gl", ":diffget //3<CR>", opt)
map("n", "<Leader>gb", ":Git blame<CR>", opt)
M.fugitive = function()
local m = user_map.fugitive
map("n", m.Git, ":Git<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 g = vim.g
opt.undofile = true
opt.ruler = false
opt.hidden = true
opt.ignorecase = true
opt.undofile = options.permanent_undo
opt.ruler = options.ruler
opt.hidden = options.hidden
opt.ignorecase = options.ignorecase
opt.splitbelow = true
opt.splitright = true
opt.termguicolors = true
opt.cul = true
opt.mouse = "a"
opt.mouse = options.mouse
opt.signcolumn = "yes"
opt.cmdheight = 1
opt.updatetime = 250 -- update interval for gitsigns
opt.timeoutlen = 400
opt.clipboard = "unnamedplus"
opt.cmdheight = options.cmdheight
opt.updatetime = options.updatetime -- update interval for gitsigns
opt.timeoutlen = options.timeoutlen
opt.clipboard = options.clipboard
-- disable nvim intro
opt.shortmess:append("sI")
@ -23,21 +24,21 @@ opt.shortmess:append("sI")
opt.fillchars = {eob = " "}
-- Numbers
opt.number = true
opt.numberwidth = 2
opt.number = options.number
opt.numberwidth = options.numberwidth
-- opt.relativenumber = true
-- Indenline
opt.expandtab = true
opt.shiftwidth = 2
opt.smartindent = true
opt.expandtab = options.expandtab
opt.shiftwidth = options.shiftwidth
opt.smartindent = options.smartindent
-- go to previous/next line with h,l,left arrow and right arrow
-- when cursor reaches end/beginning of line
opt.whichwrap:append("<>hl")
g.mapleader = " "
g.auto_save = false
g.mapleader = options.mapleader
g.auto_save = options.autosave
-- disable builtin vim plugins
local disabled_built_ins = {
@ -62,7 +63,7 @@ local disabled_built_ins = {
}
for _, plugin in pairs(disabled_built_ins) do
vim.g["loaded_" .. plugin] = 1
g["loaded_" .. plugin] = 1
end
-- 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")
@ -19,7 +21,7 @@ if not present then
}
)
vim.cmd("packadd packer.nvim")
cmd("packadd packer.nvim")
present, packer = pcall(require, "packer")
if present then
@ -33,9 +35,13 @@ return packer.init {
display = {
open_fn = function()
return require("packer.util").float {border = "single"}
end
end,
prompt_border = "single"
},
git = {
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 packer
@ -18,6 +20,7 @@ return packer.startup(
use {
"jdhao/better-escape.vim",
disable = plugin_status.better_esc,
event = "InsertEnter",
config = function()
require "plugins.others".escape()
@ -26,14 +29,19 @@ return packer.startup(
use {
"akinsho/nvim-bufferline.lua",
disable = plugin_status.nvim_bufferline,
after = "nvim-base16.lua",
config = function()
require "plugins.bufferline"
end,
setup = function()
require "mappings".bufferline()
end
}
use {
"glepnir/galaxyline.nvim",
disable = plugin_status.galaxyline,
after = "nvim-base16.lua",
config = function()
require "plugins.statusline"
@ -51,6 +59,7 @@ return packer.startup(
use {
"norcalli/nvim-colorizer.lua",
disable = plugin_status.nvim_colorizer,
event = "BufRead",
config = function()
require("plugins.others").colorizer()
@ -81,6 +90,7 @@ return packer.startup(
use {
"onsails/lspkind-nvim",
disable = plugin_status.lspkind,
event = "BufEnter",
config = function()
require("plugins.others").lspkind()
@ -89,6 +99,7 @@ return packer.startup(
use {
"ray-x/lsp_signature.nvim",
disable = plugin_status.lspsignature,
after = "nvim-lspconfig",
config = function()
require("plugins.others").signature()
@ -121,7 +132,11 @@ return packer.startup(
use {
"sbdchd/neoformat",
cmd = "Neoformat"
disable = plugin_status.neoformat,
cmd = "Neoformat",
setup = function()
require "mappings".neoformat()
end
}
-- file managing , picker etc
@ -130,6 +145,9 @@ return packer.startup(
cmd = "NvimTreeToggle",
config = function()
require "plugins.nvimtree"
end,
setup = function()
require "mappings".nvimtree()
end
}
@ -155,6 +173,9 @@ return packer.startup(
cmd = "Telescope",
config = function()
require "plugins.telescope"
end,
setup = function()
require "mappings".telescope()
end
}
@ -171,6 +192,7 @@ return packer.startup(
-- git stuff
use {
"lewis6991/gitsigns.nvim",
disable = plugin_status.gitsigns,
after = "plenary.nvim",
config = function()
require "plugins.gitsigns"
@ -188,19 +210,23 @@ return packer.startup(
use {
"andymass/vim-matchup",
disable = plugin_status.vim_matchup,
event = "CursorMoved"
}
use {
"terrortylor/nvim-comment",
disable = plugin_status.nvim_comment,
cmd = "CommentToggle",
config = function()
require("plugins.others").comment()
require "mappings".comment_nvim()
end
}
use {
"glepnir/dashboard-nvim",
disable = plugin_status.dashboard_nvim,
cmd = {
"Dashboard",
"DashboardNewFile",
@ -210,11 +236,13 @@ return packer.startup(
},
setup = function()
require "plugins.dashboard"
require "mappings".dashboard()
end
}
-- load autosave only if its globally enabled
use {
disable = plugin_status.autosave_nvim,
"Pocco81/AutoSave.nvim",
config = function()
require "plugins.autosave"
@ -227,6 +255,7 @@ return packer.startup(
-- smooth scroll
use {
"karb94/neoscroll.nvim",
disable = plugin_status.neoscroll_nvim,
event = "WinScrolled",
config = function()
require("plugins.others").neoscroll()
@ -235,6 +264,7 @@ return packer.startup(
use {
"Pocco81/TrueZen.nvim",
disable = plugin_status.truezen_nvim,
cmd = {
"TZAtaraxis",
"TZMinimalist",
@ -242,6 +272,9 @@ return packer.startup(
},
config = function()
require "plugins.zenmode"
end,
setup = function()
require "mappings".truezen()
end
}
@ -249,6 +282,7 @@ return packer.startup(
use {
"lukas-reineke/indent-blankline.nvim",
disable = plugin_status.blankline,
event = "BufRead",
setup = function()
require("plugins.others").blankline()
@ -257,9 +291,13 @@ return packer.startup(
use {
"tpope/vim-fugitive",
disable = plugin_status.vim_fugitive,
cmd = {
"Git"
}
},
setup = function()
require "mappings".fugitive()
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
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
end
local file = vim.fn.stdpath("config") .. "/lua/user_config.lua"
local file = vim.fn.stdpath("config") .. "/lua/chadrc.lua"
-- store in data variable
local data = assert(M.file("r", file))
local find = "theme = .?" .. current_theme .. ".?"