Skip to content

Commit

Permalink
set shiftwidth to 2 | format all files
Browse files Browse the repository at this point in the history
 big thanks to @ghifarit53
  • Loading branch information
siduck committed Jul 22, 2022
1 parent ce027ef commit 6f0aa37
Show file tree
Hide file tree
Showing 22 changed files with 1,449 additions and 1,448 deletions.
2 changes: 1 addition & 1 deletion .stylua.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
column_width = 120
line_endings = "Unix"
indent_type = "Spaces"
indent_width = 3
indent_width = 2
quote_style = "AutoPreferDouble"
call_parentheses = "None"
2 changes: 1 addition & 1 deletion examples/chadrc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ local M = {}
-- example of changing theme:

M.ui = {
theme = "gruvchad",
theme = "gruvchad",
}

return M
2 changes: 1 addition & 1 deletion init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ require "core"
require "core.options"

vim.defer_fn(function()
require("core.utils").load_mappings()
require("core.utils").load_mappings()
end, 0)

-- setup packer + plugins
Expand Down
42 changes: 21 additions & 21 deletions lua/core/default_config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,34 @@
local M = {}

M.options = {
-- load your options here or load module with options
user = function() end,
-- load your options here or load module with options
user = function() end,

nvChad = {
update_url = "https://github.com/NvChad/NvChad",
update_branch = "main",
},
nvChad = {
update_url = "https://github.com/NvChad/NvChad",
update_branch = "main",
},
}

M.ui = {
-- hl = highlights
hl_add = {},
hl_override = {},
changed_themes = {},
theme_toggle = { "onedark", "one_light" },
theme = "onedark", -- default theme
transparency = false,
-- hl = highlights
hl_add = {},
hl_override = {},
changed_themes = {},
theme_toggle = { "onedark", "one_light" },
theme = "onedark", -- default theme
transparency = false,
}

M.plugins = {
override = {},
remove = {},
user = {},
options = {
lspconfig = {
setup_lspconf = "", -- path of lspconfig file
},
},
override = {},
remove = {},
user = {},
options = {
lspconfig = {
setup_lspconf = "", -- path of lspconfig file
},
},
}

-- check core.mappings for table structure
Expand Down
82 changes: 41 additions & 41 deletions lua/core/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,38 @@ local api = vim.api

-- dont list quickfix buffers
autocmd("FileType", {
pattern = "qf",
callback = function()
vim.opt_local.buflisted = false
end,
pattern = "qf",
callback = function()
vim.opt_local.buflisted = false
end,
})

-- wrap the PackerSync command to warn people before using it in NvChadSnapshots
autocmd("VimEnter", {
callback = function()
vim.cmd "command! -nargs=* -complete=customlist,v:lua.require'packer'.plugin_complete PackerSync lua require('core.utils').packer_sync(<f-args>)"
end,
callback = function()
vim.cmd "command! -nargs=* -complete=customlist,v:lua.require'packer'.plugin_complete PackerSync lua require('core.utils').packer_sync(<f-args>)"
end,
})

-- Disable statusline in dashboard
autocmd("FileType", {
pattern = "alpha",
callback = function()
vim.opt.laststatus = 0
end,
pattern = "alpha",
callback = function()
vim.opt.laststatus = 0
end,
})

autocmd("BufUnload", {
buffer = 0,
callback = function()
vim.opt.laststatus = 3
end,
buffer = 0,
callback = function()
vim.opt.laststatus = 3
end,
})

-- Don't auto commenting new lines
autocmd("BufEnter", {
pattern = "*",
command = "set fo-=c fo-=r fo-=o",
pattern = "*",
command = "set fo-=c fo-=r fo-=o",
})

-- store listed buffers in tab local var
Expand All @@ -50,34 +50,34 @@ vim.t.bufs = vim.api.nvim_list_bufs()
-- autocmds for tabufline -> store bufnrs on bufadd, bufenter events
-- thx to https://github.com/ii14 & stores buffer per tab -> table
autocmd({ "BufAdd", "BufEnter" }, {
callback = function(args)
if vim.t.bufs == nil then
vim.t.bufs = { args.buf }
else
local bufs = vim.t.bufs
callback = function(args)
if vim.t.bufs == nil then
vim.t.bufs = { args.buf }
else
local bufs = vim.t.bufs

-- check for duplicates
if not vim.tbl_contains(bufs, args.buf) and (args.event == "BufAdd" or vim.bo[args.buf].buflisted) then
table.insert(bufs, args.buf)
vim.t.bufs = bufs
end
-- check for duplicates
if not vim.tbl_contains(bufs, args.buf) and (args.event == "BufAdd" or vim.bo[args.buf].buflisted) then
table.insert(bufs, args.buf)
vim.t.bufs = bufs
end
end,
end
end,
})

autocmd("BufDelete", {
callback = function(args)
for _, tab in ipairs(api.nvim_list_tabpages()) do
local bufs = vim.t[tab].bufs
if bufs then
for i, bufnr in ipairs(bufs) do
if bufnr == args.buf then
table.remove(bufs, i)
vim.t[tab].bufs = bufs
break
end
end
end
callback = function(args)
for _, tab in ipairs(api.nvim_list_tabpages()) do
local bufs = vim.t[tab].bufs
if bufs then
for i, bufnr in ipairs(bufs) do
if bufnr == args.buf then
table.remove(bufs, i)
vim.t[tab].bufs = bufs
break
end
end
end
end,
end
end,
})
150 changes: 75 additions & 75 deletions lua/core/lazy_load.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,103 +4,103 @@ local autocmd = vim.api.nvim_create_autocmd
-- This must be used for plugins that need to be loaded just after a file
-- ex : treesitter, lspconfig etc
M.lazy_load = function(tb)
autocmd(tb.events, {
pattern = "*",
group = vim.api.nvim_create_augroup(tb.augroup_name, {}),
callback = function()
if tb.condition() then
vim.api.nvim_del_augroup_by_name(tb.augroup_name)
autocmd(tb.events, {
pattern = "*",
group = vim.api.nvim_create_augroup(tb.augroup_name, {}),
callback = function()
if tb.condition() then
vim.api.nvim_del_augroup_by_name(tb.augroup_name)

-- dont defer for treesitter as it will show slow highlighting
-- This deferring only happens only when we do "nvim filename"
if tb.plugins ~= "nvim-treesitter" then
vim.defer_fn(function()
vim.cmd("PackerLoad " .. tb.plugins)
end, 0)
else
vim.cmd("PackerLoad " .. tb.plugins)
end
end
end,
})
-- dont defer for treesitter as it will show slow highlighting
-- This deferring only happens only when we do "nvim filename"
if tb.plugins ~= "nvim-treesitter" then
vim.defer_fn(function()
vim.cmd("PackerLoad " .. tb.plugins)
end, 0)
else
vim.cmd("PackerLoad " .. tb.plugins)
end
end
end,
})
end

M.colorizer = function()
M.lazy_load {
events = { "BufRead", "BufNewFile" },
augroup_name = "ColorizerLazy",
plugins = "nvim-colorizer.lua",
M.lazy_load {
events = { "BufRead", "BufNewFile" },
augroup_name = "ColorizerLazy",
plugins = "nvim-colorizer.lua",

condition = function()
return true
end,
}
condition = function()
return true
end,
}
end

-- load certain plugins only when there's a file opened in the buffer
-- if "nvim filename" is executed -> load the plugin after nvim gui loads
-- This gives an instant preview of nvim with the file opened

M.on_file_open = function(plugin_name)
M.lazy_load {
events = { "BufRead", "BufWinEnter", "BufNewFile" },
augroup_name = "BeLazyOnFileOpen" .. plugin_name,
plugins = plugin_name,
condition = function()
local file = vim.fn.expand "%"
return file ~= "NvimTree_1" and file ~= "[packer]" and file ~= ""
end,
}
M.lazy_load {
events = { "BufRead", "BufWinEnter", "BufNewFile" },
augroup_name = "BeLazyOnFileOpen" .. plugin_name,
plugins = plugin_name,
condition = function()
local file = vim.fn.expand "%"
return file ~= "NvimTree_1" and file ~= "[packer]" and file ~= ""
end,
}
end

-- lspinstaller & lspconfig cmds for lazyloading
M.lsp_cmds = {
"LspInfo",
"LspStart",
"LspRestart",
"LspStop",
"LspInstall",
"LspUnInstall",
"LspUnInstallAll",
"LspInstall",
"LspInstallInfo",
"LspInstallLog",
"LspLog",
"LspPrintInstalled",
"LspInfo",
"LspStart",
"LspRestart",
"LspStop",
"LspInstall",
"LspUnInstall",
"LspUnInstallAll",
"LspInstall",
"LspInstallInfo",
"LspInstallLog",
"LspLog",
"LspPrintInstalled",
}

M.treesitter_cmds = {
"TSInstall",
"TSBufEnable",
"TSBufDisable",
"TSEnable",
"TSDisable",
"TSModuleInfo",
"TSInstall",
"TSBufEnable",
"TSBufDisable",
"TSEnable",
"TSDisable",
"TSModuleInfo",
}

M.gitsigns = function()
-- taken from https://github.com/max397574
autocmd({ "BufRead" }, {
callback = function()
local function onexit(code, _)
if code == 0 then
vim.schedule(function()
require("packer").loader "gitsigns.nvim"
end)
end
end
local lines = vim.api.nvim_buf_get_lines(0, 0, -1, false)
if lines ~= { "" } then
vim.loop.spawn("git", {
args = {
"ls-files",
"--error-unmatch",
vim.fn.expand "%:p:h",
},
}, onexit)
end
end,
})
-- taken from https://github.com/max397574
autocmd({ "BufRead" }, {
callback = function()
local function onexit(code, _)
if code == 0 then
vim.schedule(function()
require("packer").loader "gitsigns.nvim"
end)
end
end
local lines = vim.api.nvim_buf_get_lines(0, 0, -1, false)
if lines ~= { "" } then
vim.loop.spawn("git", {
args = {
"ls-files",
"--error-unmatch",
vim.fn.expand "%:p:h",
},
}, onexit)
end
end,
})
end

return M
Loading

0 comments on commit 6f0aa37

Please sign in to comment.