Skip to content

Commit

Permalink
add user_config
Browse files Browse the repository at this point in the history
  • Loading branch information
siduck76 committed Aug 12, 2021
1 parent d5c64d3 commit 0efa21c
Show file tree
Hide file tree
Showing 10 changed files with 259 additions and 90 deletions.
2 changes: 1 addition & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
100 changes: 100 additions & 0 deletions lua/chadrc.lua
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion lua/highlights.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
143 changes: 87 additions & 56 deletions lua/mappings.lua
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)

M.truezen = function()
local m = user_map.truezen

-- Truezen.nvim
map("n", "<leader>zz", ":TZAtaraxis<CR>", opt)
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)

-- 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)
Expand Down Expand Up @@ -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)

-- format code
map("n", "<Leader>fm", ":Neoformat<CR>", opt)

-- 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)

-- 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)

-- 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

-- move between tabs
map("n", "<TAB>", ":BufferLineCycleNext<CR>", opt)
map("n", "<S-TAB>", ":BufferLineCyclePrev<CR>", opt)
M.nvimtree = function()
local m = user_map.nvimtree.treetoggle

map("n", m, ":NvimTreeToggle<CR>", opt)
end

M.neoformat = function()
local m = user_map.neoformat.format
map("n", m, ":Neoformat<CR>", opt)
end

M.dashboard = function()
local m = user_map.dashboard

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

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

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

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
35 changes: 18 additions & 17 deletions lua/options.lua
Original file line number Diff line number Diff line change
@@ -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")
Expand All @@ -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 = {
Expand All @@ -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
Expand Down
14 changes: 10 additions & 4 deletions lua/packerInit.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
vim.cmd("packadd packer.nvim")
local cmd = vim.cmd

cmd("packadd packer.nvim")

local present, packer = pcall(require, "packer")

Expand All @@ -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
Expand All @@ -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
}

0 comments on commit 0efa21c

Please sign in to comment.