diff --git a/init.lua b/init.lua index 670dbf0..a2564b8 100644 --- a/init.lua +++ b/init.lua @@ -2,6 +2,7 @@ require("mappings") require("options") require("autocommands") require("config.lazy") +require("health") if vim.fn.has("mac") == 1 then require("config.mac") diff --git a/lua/autocommands.lua b/lua/autocommands.lua index 766813f..16f3138 100644 --- a/lua/autocommands.lua +++ b/lua/autocommands.lua @@ -1,12 +1,8 @@ --- Highlight yanked text -local highlight_group = vim.api.nvim_create_augroup("YankHighlight", { clear = true }) - vim.api.nvim_set_hl(0, "YankHighlight", { bg = "#2d3f5f" }) - vim.api.nvim_create_autocmd("TextYankPost", { callback = function() vim.highlight.on_yank { higroup = "YankHighlight", timeout = 250 } end, - group = highlight_group, + group = vim.api.nvim_create_augroup("YankHighlight", { clear = true }), pattern = "*", }) diff --git a/lua/health.lua b/lua/health.lua new file mode 100644 index 0000000..e1f5e97 --- /dev/null +++ b/lua/health.lua @@ -0,0 +1,41 @@ +local check_version = function() + local verstr = tostring(vim.version()) + if not vim.version.ge then + vim.health.error(string.format("Neovim out of date: '%s'. Upgrade to latest stable or nightly", verstr)) + return + end + + if vim.version.ge(vim.version(), "0.12-dev") then + vim.health.ok(string.format("Neovim version is: '%s'", verstr)) + else + vim.health.error(string.format("Neovim out of date: '%s'. Upgrade to latest stable or nightly", verstr)) + end +end + +local check_external_reqs = function() + -- Basic utils: `git`, `make`, `unzip` + for _, exe in ipairs { "git", "make", "unzip", "rg" } do + local is_executable = vim.fn.executable(exe) == 1 + if is_executable then + vim.health.ok(string.format("Found executable: '%s'", exe)) + else + vim.health.warn(string.format("Could not find executable: '%s'", exe)) + end + end + + return true +end + +return { + check = function() + vim.health.info([[NOTE: Not every warning is a 'must-fix' in `:checkhealth` + + Fix only warnings for plugins and languages you intend to use.]]) + + local uv = vim.uv or vim.loop + vim.health.info("System Information: " .. vim.inspect(uv.os_uname())) + + check_version() + check_external_reqs() + end, +} diff --git a/lua/mappings.lua b/lua/mappings.lua index 8a40ad0..66ac97b 100644 --- a/lua/mappings.lua +++ b/lua/mappings.lua @@ -32,6 +32,10 @@ map("x", "", "gc", { remap = true }) -- clearing highlights map("n", "h", "nohlsearch") +-- diagnostics +map("n", "[d", vim.diagnostic.goto_prev, { desc = "Go to previous [D]iagnostic message" }) +map("n", "]d", vim.diagnostic.goto_next, { desc = "Go to next [D]iagnostic message" }) + -- toggle diff mode local function toggle_diff() if vim.wo.diff then diff --git a/lua/options.lua b/lua/options.lua index c2e26c8..912d4b0 100644 --- a/lua/options.lua +++ b/lua/options.lua @@ -8,6 +8,7 @@ local options = { hidden = true, -- required to keep multiple buffers and open multiple buffers hlsearch = true, -- highlight all matches on previous search pattern ignorecase = true, -- required for smartcase to work + inccommand = 'split', -- show incremental substitution mouse = "a", -- enable mouse in all modes pumheight = 10, -- pop up menu height showmode = false, -- included in statusline @@ -36,6 +37,8 @@ local options = { whichwrap = "<,>,[,],h,l" -- which "horizontal" keys should wrap to next/previous line } +vim.g.have_nerd_font = true + vim.opt.shortmess:append("c") -- don't give |ins-completion-menu| messages vim.opt.iskeyword:append("-") -- hyphenated words recognized by searches -- stylua: ignore end