clean config | fix (#1225) (#1226)

This commit is contained in:
siduck 2022-06-18 09:57:17 +05:30
parent 349ee96a20
commit 9bca3eacae
16 changed files with 69 additions and 165 deletions

View file

@ -1,8 +1,10 @@
-- commands
vim.cmd "silent! command! NvChadUpdate lua require('nvchad').update_nvchad()"
vim.cmd "silent! command! NvChadSnapshotCreate lua require('nvchad').snap_create()"
vim.cmd "silent! command! NvChadSnapshotDelete lua require('nvchad').snap_delete()"
vim.cmd "silent! command! NvChadSnapshotCheckout lua require('nvchad').snap_checkout()"
-- autocmds
local autocmd = vim.api.nvim_create_autocmd
-- Disable statusline in dashboard

View file

@ -1,5 +1,7 @@
-- https://github.com/max397574/omega-nvim/blob/master/lua/omega/modules/ui/bufferline.lua
local lazy_load = function(tb)
-- thx to https://github.com/max397574/omega-nvim/blob/master/lua/omega/modules/ui/bufferline.lua
local M = {}
M.lazy_load = function(tb)
vim.api.nvim_create_autocmd(tb.events, {
pattern = "*",
group = vim.api.nvim_create_augroup(tb.augroup_name, {}),
@ -21,12 +23,8 @@ local lazy_load = function(tb)
})
end
local M = {}
M.lazy_load = lazy_load
M.bufferline = function()
lazy_load {
M.lazy_load {
events = { "BufNewFile", "BufRead", "TabEnter" },
augroup_name = "BufferLineLazy",
plugins = "bufferline.nvim",
@ -38,13 +36,13 @@ M.bufferline = function()
end
M.colorizer = function()
lazy_load {
M.lazy_load {
events = { "BufRead", "BufNewFile" },
augroup_name = "ColorizerLazy",
plugins = "nvim-colorizer.lua",
condition = function()
local items = { "#", "rgb", "hsl" }
local items = { "#", "rgb", "hsl", "rgba", "hsla" }
for _, val in ipairs(items) do
if vim.fn.search(val) ~= 0 then
@ -56,28 +54,14 @@ M.colorizer = function()
end
-- load certain plugins only when there's a file opened in the buffer
-- if "nvim-file" is executed -> load the plugin after nvim gui loads
-- 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()
lazy_load {
M.on_file_open = function(plugin_name)
M.lazy_load {
events = { "BufRead", "BufWinEnter", "BufNewFile" },
augroup_name = "BeLazyOnFileOpen",
plugins = "nvim-lsp-installer indent-blankline.nvim",
condition = function()
local file = vim.fn.expand "%"
return file ~= "NvimTree_1" and file ~= "[packer]" and file ~= ""
end,
}
end
M.treesitter = function()
lazy_load {
events = { "BufRead", "BufWinEnter", "BufNewFile" },
augroup_name = "Treesitter_lazy",
plugins = "nvim-treesitter",
augroup_name = "BeLazyOnFileOpen" .. plugin_name,
plugins = plugin_name,
condition = function()
local file = vim.fn.expand "%"
return file ~= "NvimTree_1" and file ~= "[packer]" and file ~= ""

View file

@ -1,4 +1,4 @@
-- n, v, i are mode names
-- n, v, i, tare mode names
local function termcodes(str)
return vim.api.nvim_replace_termcodes(str, true, true, true)
@ -147,7 +147,7 @@ M.lspconfig = {
["<leader>ra"] = {
function()
require("ui.renamer").open()
require("nvchad.ui.renamer").open()
end,
" lsp rename",
},
@ -342,4 +342,24 @@ M.whichkey = {
},
}
M.blankline = {
n = {
["<leader>bc"] = {
function()
local ok, start = require("indent_blankline.utils").get_current_context(
vim.g.indent_blankline_context_patterns,
vim.g.indent_blankline_use_treesitter_scope
)
if ok then
vim.api.nvim_win_set_cursor(vim.api.nvim_get_current_win(), { start, 0 })
vim.cmd [[normal! _]]
end
end,
" Jump to current_context",
},
},
}
return M

View file

@ -19,14 +19,12 @@ opt.title = true
opt.clipboard = "unnamedplus"
opt.cul = true -- cursor line
-- Indentline
-- Indenting
opt.expandtab = true
opt.shiftwidth = 2
opt.smartindent = true
-- disable tilde on end of buffer: https://github.com/neovim/neovim/pull/8546#issuecomment-643643758
opt.fillchars = { eob = " " }
opt.ignorecase = true
opt.smartcase = true
opt.mouse = "a"
@ -53,10 +51,10 @@ opt.updatetime = 250
-- 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 = " "
-- disable some builtin vim plugins
local default_plugins = {
"2html_plugin",
"getscript",
@ -101,5 +99,5 @@ vim.schedule(function()
vim.cmd [[ silent! rsh ]]
end)
-- load user options if the file exists
-- load user options
config.options.user()

View file

@ -8,7 +8,6 @@ M.bootstrap = function()
if fn.empty(fn.glob(install_path)) > 0 then
print "Cloning packer .."
fn.system { "git", "clone", "--depth", "1", "https://github.com/wbthomason/packer.nvim", install_path }
-- install plugins + compile their configs
@ -23,7 +22,7 @@ M.options = {
compile_on_sync = true,
git = { clone_timeout = 6000 },
display = {
working_sym = " ",
working_sym = "",
error_sym = "",
done_sym = "",
removed_sym = "",

View file

@ -21,6 +21,7 @@ M.close_buffer = function(force)
end
force = force or not vim.bo.buflisted or vim.bo.buftype == "nofile"
-- if not force, change to prev buf and then close current
local close_cmd = force and ":bd!" or ":bp | bd" .. fn.bufnr()
vim.cmd(close_cmd)
@ -150,9 +151,7 @@ M.load_override = function(default_table, plugin_name)
if type(user_table) == "function" then
user_table = user_table()
end
if type(user_table) == "table" then
elseif type(user_table) == "table" then
default_table = merge_tb("force", default_table, user_table)
else
default_table = default_table