diff --git a/init.lua b/init.lua index 23322bd..d53453a 100644 --- a/init.lua +++ b/init.lua @@ -1,8 +1,5 @@ -local userconf = pcall(require, "custom") - -if userconf then - require "custom" -end +-- try to call cuatom init +pcall(require, "custom") local core_modules = { "core.options", diff --git a/lua/colors/init.lua b/lua/colors/init.lua index 1de4a62..9630d75 100644 --- a/lua/colors/init.lua +++ b/lua/colors/init.lua @@ -19,7 +19,7 @@ M.init = function(theme) package.loaded["colors.highlights" or false] = nil -- then load the highlights require "colors.highlights" - end + end end -- returns a table of colors for givem or current theme diff --git a/lua/core/hooks.lua b/lua/core/hooks.lua index 02394a1..9f394ce 100644 --- a/lua/core/hooks.lua +++ b/lua/core/hooks.lua @@ -1,31 +1,23 @@ local hooks, M = {}, {} local allowed_hooks = { - "install_plugins", - "setup_mappings", - "ready", + ["install_plugins"] = true, + ["setup_mappings"] = true, + ["ready"] = true, } -local function has_value(tab, val) - for _, value in ipairs(tab) do - if value == val then - return true - end - end -end - M.add = function(name, fn) - if not (has_value(allowed_hooks, name)) then + if not allowed_hooks[name] then print("Custom lua uses unallowed hook " .. name) end - if hooks[name] == nil then + if not hooks[name] then hooks[name] = {} end table.insert(hooks[name], fn) end M.run = function(name, args) - if hooks[name] ~= nil then + if hooks[name] then for _, hook in pairs(hooks[name]) do hook(args) end diff --git a/lua/core/options.lua b/lua/core/options.lua index 01b3a39..b9509a4 100644 --- a/lua/core/options.lua +++ b/lua/core/options.lua @@ -14,7 +14,7 @@ opt.shiftwidth = options.shiftwidth opt.smartindent = options.smartindent -- disable tilde on end of buffer: https://github.com/neovim/neovim/pull/8546#issuecomment-643643758 -opt.fillchars = options.fillchars +opt.fillchars = options.fillchars opt.hidden = options.hidden opt.ignorecase = options.ignorecase diff --git a/lua/core/utils.lua b/lua/core/utils.lua index 41c70e1..c1fcd3e 100644 --- a/lua/core/utils.lua +++ b/lua/core/utils.lua @@ -1,7 +1,7 @@ local M = {} local cmd = vim.cmd -M.close_buffer = function(bufexpr, force) +M.close_buffer = function(force) -- This is a modification of a NeoVim plugin from -- Author: ojroques - Olivier Roques -- Src: https://github.com/ojroques/nvim-bufdel @@ -63,7 +63,7 @@ M.close_buffer = function(bufexpr, force) return end - local chad_term, type = pcall(function() + local chad_term, _ = pcall(function() return vim.api.nvim_buf_get_var(buf, "term_type") end) @@ -140,21 +140,18 @@ end M.load_config = function() local conf = require "core.default_config" - local chadrcExists, _ = pcall(require, "custom.chadrc") + local chadrcExists, change = pcall(require, "custom.chadrc") -- if chadrc exists , then merge its table into the default config's if chadrcExists then - local change = require "custom.chadrc" conf = vim.tbl_deep_extend("force", conf, change) - return conf end - -- or load default config return conf end -M.map = function(mode, keys, cmd, opt) +M.map = function(mode, keys, command, opt) local options = { noremap = true, silent = true } if opt then options = vim.tbl_extend("force", options, opt) @@ -178,28 +175,30 @@ M.map = function(mode, keys, cmd, opt) -- helper function for M.map -- can gives multiple modes and keys - local function map_wrapper(mode, lhs, rhs, options) + local function map_wrapper(sub_mode, lhs, rhs, sub_options) if type(lhs) == "table" then for _, key in ipairs(lhs) do - map_wrapper(mode, key, rhs, options) + map_wrapper(sub_mode, key, rhs, sub_options) end else - if type(mode) == "table" then - for _, m in ipairs(mode) do - map_wrapper(m, lhs, rhs, options) + if type(sub_mode) == "table" then + for _, m in ipairs(sub_mode) do + map_wrapper(m, lhs, rhs, sub_options) end else - if valid_modes[mode] and lhs and rhs then - vim.api.nvim_set_keymap(mode, lhs, rhs, options) + if valid_modes[sub_mode] and lhs and rhs then + vim.api.nvim_set_keymap(sub_mode, lhs, rhs, sub_options) else - mode, lhs, rhs = mode or "", lhs or "", rhs or "" - print("Cannot set mapping [ mode = '" .. mode .. "' | key = '" .. lhs .. "' | cmd = '" .. rhs .. "' ]") + sub_mode, lhs, rhs = sub_mode or "", lhs or "", rhs or "" + print( + "Cannot set mapping [ mode = '" .. sub_mode .. "' | key = '" .. lhs .. "' | cmd = '" .. rhs .. "' ]" + ) end end end end - map_wrapper(mode, keys, cmd, options) + map_wrapper(mode, keys, command, options) end -- load plugin after entering vim ui diff --git a/lua/plugins/configs/nvimtree.lua b/lua/plugins/configs/nvimtree.lua index 282641e..58c89d4 100644 --- a/lua/plugins/configs/nvimtree.lua +++ b/lua/plugins/configs/nvimtree.lua @@ -13,7 +13,7 @@ g.nvim_tree_highlight_opened_files = 0 g.nvim_tree_indent_markers = 1 g.nvim_tree_quit_on_open = 0 -- closes tree when file's opened g.nvim_tree_root_folder_modifier = table.concat { ":t:gs?$?/..", string.rep(" ", 1000), "?:gs?^??" } - + g.nvim_tree_window_picker_exclude = { filetype = { "notify", "packer", "qf" }, buftype = { "terminal" }, diff --git a/lua/plugins/configs/others.lua b/lua/plugins/configs/others.lua index 5a851cc..df25ef5 100644 --- a/lua/plugins/configs/others.lua +++ b/lua/plugins/configs/others.lua @@ -132,7 +132,7 @@ M.lsp_handlers = function() }) -- suppress error messages from lang servers - vim.notify = function(msg, log_level, _opts) + vim.notify = function(msg, log_level) if msg:match "exit code" then return end