diff --git a/README.md b/README.md index dc8db7e..57af95e 100755 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ *My Beast* +**nvim v0.9.5** + ## Installation Running the following script if you want to install Neovim at a specific version: diff --git a/lazy-lock.json b/lazy-lock.json index 95f404c..7596f6f 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -13,15 +13,14 @@ "conform.nvim": { "branch": "master", "commit": "9b26e81c4292106e68dda3e7b64473434fd5b3e0" }, "copilot-cmp": { "branch": "master", "commit": "72fbaa03695779f8349be3ac54fa8bd77eed3ee3" }, "copilot.lua": { "branch": "master", "commit": "f7612f5af4a7d7615babf43ab1e67a2d790c13a6" }, - "dashboard-nvim": { "branch": "master", "commit": "5182c09ac8085dc73b78ad0ea9f5479c9a866fc4" }, + "dashboard-nvim": { "branch": "master", "commit": "b5a2a4269babbcc23c2d50a859516199841714b9" }, "dressing.nvim": { "branch": "master", "commit": "572314728cb1ce012e825fd66331f52c94acac12" }, "emmet-vim": { "branch": "master", "commit": "def5d57a1ae5afb1b96ebe83c4652d1c03640f4d" }, - "flutter-tools.nvim": { "branch": "main", "commit": "e122657bfebe5d1f4a0c18a04dff3f5c0f486b74" }, - "friendly-snippets": { "branch": "main", "commit": "dd2fd1281d4b22e7b4a5bfafa3e142d958e251f2" }, + "friendly-snippets": { "branch": "main", "commit": "d0610077b6129cf9f7f78afbe3a1425d60f6e2f1" }, "gitsigns.nvim": { "branch": "main", "commit": "76927d14d3fbd4ba06ccb5246e79d93b5442c188" }, "img-clip.nvim": { "branch": "main", "commit": "fc30500c35663aa1762697f5aba31d43b86028f0" }, "indent-blankline.nvim": { "branch": "master", "commit": "d98f537c3492e87b6dc6c2e3f66ac517528f406f" }, - "lazy.nvim": { "branch": "main", "commit": "8f19915175395680808de529e4220da8dafc0759" }, + "lazy.nvim": { "branch": "main", "commit": "eab487c2520f0fe9e54eb5e3ea0606e20512492e" }, "llm.nvim": { "branch": "main", "commit": "32346410239bc8eb212d586131832833d301aed0" }, "lsp_signature.nvim": { "branch": "master", "commit": "e92b4e7073345b2a30a56b20db3d541a9aa2771e" }, "lualine.nvim": { "branch": "master", "commit": "0a5a66803c7407767b799067986b4dc3036e1983" }, @@ -32,24 +31,24 @@ "mini.comment": { "branch": "main", "commit": "a4b7e46deb9ad2feb8902cc5dbf087eced112ee5" }, "mini.hipatterns": { "branch": "main", "commit": "0a72439dbded766af753a3e7ec0a5b21d0f8ada0" }, "mini.pairs": { "branch": "main", "commit": "04f58f2545ed80ac3b52dd4826e93f33e15b2af6" }, - "monokai-pro.nvim": { "branch": "master", "commit": "8940b2f87343db96ee2c62404a4e4ff9257ed514" }, + "monokai-pro.nvim": { "branch": "master", "commit": "2bad2a92fe0ff6c8581d33a853a1b17592b83239" }, "neo-tree-diagnostics.nvim": { "branch": "main", "commit": "e00434c3cf8637bcaf70f65c2b9d82b0cc9bd7dc" }, "neo-tree.nvim": { "branch": "main", "commit": "8c75e8a2949cd6cd35525799200a8d34471ee9eb" }, - "noice.nvim": { "branch": "main", "commit": "278578720a62787aa5893043f2007792a685a443" }, - "none-ls.nvim": { "branch": "main", "commit": "60f5f80686f5a272ed3281a7d4962cb54dc5348e" }, + "noice.nvim": { "branch": "main", "commit": "69c6ad5c1f1c0777125d0275f9871d8609cb0521" }, + "none-ls.nvim": { "branch": "main", "commit": "f5b960a73418249aebcdae3455de320360509253" }, "nui.nvim": { "branch": "main", "commit": "a0fd35fcbb4cb479366f1dc5f20145fd718a3733" }, "nvim": { "branch": "main", "commit": "a1439ad7c584efb3d0ce14ccb835967f030450fe" }, "nvim-cmp": { "branch": "main", "commit": "5260e5e8ecadaf13e6b82cf867a909f54e15fd07" }, "nvim-jdtls": { "branch": "master", "commit": "a5c6f38f8151d7b4f5b32c005a95022fa66f4c9d" }, "nvim-lightbulb": { "branch": "master", "commit": "02aacd93b9b2367e6dbdd20f43b525f701faf834" }, - "nvim-lint": { "branch": "master", "commit": "e19842a05aae484957ad20710444757bc0a61d63" }, - "nvim-lspconfig": { "branch": "master", "commit": "b972e7154bc94ab4ecdbb38c8edbccac36f83996" }, + "nvim-lint": { "branch": "master", "commit": "2f90fe977ef21db3bf3b7a1ceaf4a1e3aafb2b26" }, + "nvim-lspconfig": { "branch": "master", "commit": "710a8fa7379db32199545f30ea01dd8446b9302f" }, "nvim-navic": { "branch": "master", "commit": "8649f694d3e76ee10c19255dece6411c29206a54" }, "nvim-notify": { "branch": "master", "commit": "d333b6f167900f6d9d42a59005d82919830626bf" }, "nvim-scrollbar": { "branch": "main", "commit": "35f99d559041c7c0eff3a41f9093581ceea534e8" }, - "nvim-treesitter": { "branch": "master", "commit": "78e11ab7cedabe5dfb3b600c6682712271c59acf" }, + "nvim-treesitter": { "branch": "master", "commit": "f9773e4a5e0dbeda0d6f8a78d7d61eb802b6d0e1" }, "nvim-treesitter-context": { "branch": "master", "commit": "f62bfe19e0fbc13ae95649dfb3cf22f4ff85b683" }, - "nvim-ts-autotag": { "branch": "main", "commit": "8ae54b90e36ef1fc5267214b30c2cbff71525fe4" }, + "nvim-ts-autotag": { "branch": "main", "commit": "bcf3146864262ef2d3c877beba3e222b5c73780d" }, "nvim-ts-context-commentstring": { "branch": "main", "commit": "cb064386e667def1d241317deed9fd1b38f0dc2e" }, "nvim-ufo": { "branch": "main", "commit": "a5390706f510d39951dd581f6d2a972741b3fa26" }, "nvim-web-devicons": { "branch": "master", "commit": "5b9067899ee6a2538891573500e8fd6ff008440f" }, @@ -58,12 +57,11 @@ "promise-async": { "branch": "main", "commit": "38a4575da9497326badd3995e768b4ccf0bb153e" }, "rainbow-delimiters.nvim": { "branch": "master", "commit": "12b1a1e095d968887a17ef791c2edb78d7595d46" }, "statuscol.nvim": { "branch": "main", "commit": "483b9a596dfd63d541db1aa51ee6ee9a1441c4cc" }, - "tailwindcss-colorizer-cmp.nvim": { "branch": "main", "commit": "3d3cd95e4a4135c250faf83dd5ed61b8e5502b86" }, - "telescope.nvim": { "branch": "master", "commit": "c2ce039188e22288449e43b77710036e69a45a70" }, + "telescope.nvim": { "branch": "master", "commit": "dfa230be84a044e7f546a6c2b0a403c739732b86" }, "tokyonight.nvim": { "branch": "main", "commit": "67c6050e1ca41260c919236a098ba278472c7520" }, "vim-bbye": { "branch": "master", "commit": "903f5eb17f72ebf7b0b1524bbb792c0b36761af6" }, "vim-illuminate": { "branch": "master", "commit": "5eeb7951fc630682c322e88a9bbdae5c224ff0aa" }, "vim-visual-multi": { "branch": "master", "commit": "1c9207b28c8898ab01b54e6d6b61b0b820a814bc" }, - "which-key.nvim": { "branch": "main", "commit": "ce741eb559c924d72e3a67d2189ad3771a231414" }, + "which-key.nvim": { "branch": "main", "commit": "4b7167f8fb2dba3d01980735e3509e172c024c29" }, "windows.nvim": { "branch": "main", "commit": "c7492552b23d0ab30325e90b56066ec51242adc8" } } \ No newline at end of file diff --git a/lua/beastvim/features/lualine/components.lua b/lua/beastvim/features/lualine/components.lua index e07bb1b..1f090c0 100644 --- a/lua/beastvim/features/lualine/components.lua +++ b/lua/beastvim/features/lualine/components.lua @@ -34,7 +34,7 @@ function cpn.branch(sep_type) return Utils.lualine.build_component(config, { { text = " ", color = palette.white }, { text = text, color = palette.green }, - }, sep_type or "fill") + }, sep_type or "fill", nil, nil) end, } end @@ -95,7 +95,7 @@ function cpn.diff(sep_type) end) return Utils.lualine.build_component(config, { { text = text, color = palette.red }, - }, sep_type) + }, sep_type, nil, nil) end, cond = Utils.lualine.hide_width, } @@ -109,7 +109,7 @@ function cpn.position(sep_type) local text = "Ln " .. current_line .. ", Col " .. current_column return Utils.lualine.build_component(config, { { text = text, color = palette.magenta }, - }, sep_type or "fill") + }, sep_type or "fill", nil, nil) end end @@ -158,7 +158,7 @@ function cpn.filetype(sep_type) ft_text = Utils.string.capitalize(ft_text) return Utils.lualine.build_component(config, { { text = ft_text, color = palette.blue }, - }, sep_type or "fill") + }, sep_type or "fill", nil, nil) end, } end @@ -169,7 +169,7 @@ function cpn.spaces(sep_type) local text = "Spaces: " .. vim.api.nvim_buf_get_option(0, "shiftwidth") return Utils.lualine.build_component(config, { { text = text, color = palette.yellow }, - }, sep_type or "fill") + }, sep_type or "fill", nil, nil, "space") end end diff --git a/lua/beastvim/features/lualine/init.lua b/lua/beastvim/features/lualine/init.lua index 74d71af..d2843f0 100644 --- a/lua/beastvim/features/lualine/init.lua +++ b/lua/beastvim/features/lualine/init.lua @@ -6,6 +6,10 @@ local M = {} M.setup = config.setup function M._load() + -- PERF: we don't need this lualine require madness 🤷 + local lualine_require = require("lualine_require") + lualine_require.require = require + local theme = require("beastvim.features.lualine.theme")(config) local _ = require("beastvim.features.lualine.palette")(config) local cpn = require("beastvim.features.lualine.components") @@ -26,8 +30,8 @@ function M._load() globalstatus = true, refresh = { statusline = 1000, - tabline = 1000, - winbar = 100, + tabline = 1000000, + winbar = 1000000, }, }, sections = { diff --git a/lua/beastvim/lazy.lua b/lua/beastvim/lazy.lua index a0133ac..577ba05 100644 --- a/lua/beastvim/lazy.lua +++ b/lua/beastvim/lazy.lua @@ -30,6 +30,11 @@ require("lazy").setup({ }, install = { colorscheme = { "monokai-pro", "habamax" } }, checker = { enabled = false, notify = false }, + change_detection = { + -- automatically check for config file changes and reload the ui + enabled = false, + notify = false, -- get a notification when changes are found + }, ui = { icons = { ft = Icons.lazy.ft, diff --git a/lua/beastvim/plugins/colorscheme.lua b/lua/beastvim/plugins/colorscheme.lua index 6cbc42e..83b466d 100644 --- a/lua/beastvim/plugins/colorscheme.lua +++ b/lua/beastvim/plugins/colorscheme.lua @@ -27,7 +27,7 @@ return { inc_search = "background", -- underline | background background_clear = { "nvim-tree", - "neo-tree", + -- "neo-tree", "bufferline", -- "telescope", "toggleterm", diff --git a/lua/beastvim/plugins/treesitter.lua b/lua/beastvim/plugins/treesitter.lua index 8ac526e..80f8325 100644 --- a/lua/beastvim/plugins/treesitter.lua +++ b/lua/beastvim/plugins/treesitter.lua @@ -15,30 +15,107 @@ return { require("nvim-treesitter.query_predicates") end, cmd = { "TSUpdateSync", "TSUpdate", "TSInstall" }, - opts = { - ensure_installed = { - "vimdoc", - "bash", - "html", - "json", - "lua", - "markdown", - "markdown_inline", - "query", - "regex", - "vim", - "yaml", - "scss", - "graphql", - }, - highlight = { enable = true }, - indent = { enable = true, disable = { "yaml", "python", "html" } }, - rainbow = { - enable = true, - query = "rainbow-parens", - disable = { "jsx", "html" }, - }, - }, + opts = function() + local ts_hl = require("nvim-treesitter.highlight") + + local function begin_ts_highlight(bufnr, lang, owner) + if not vim.api.nvim_buf_is_valid(bufnr) then + return + end + vim.treesitter.start(bufnr, lang) + end + + local vim_enter = true + function ts_hl.attach(bufnr, lang) + if vim_enter then + vim.treesitter.start(bufnr, lang) + vim_enter = false + return + end + local timer = vim.loop.new_timer() + vim.defer_fn(function() + local is_active = timer:is_active() + if is_active then + vim.notify("Timer haven't been closed!", vim.log.levels.ERROR) + end + end, 2000) + local has_start = false + local timout = function(opts) + local force = opts.force + local time = opts.time + if not vim.api.nvim_buf_is_valid(bufnr) then + if timer:is_active() then + timer:close() + end + return + end + if (not force) and has_start then + return + end + if timer:is_active() then + timer:close() + -- haven't start + has_start = true + begin_ts_highlight(bufnr, lang, "highligter") + end + end + vim.defer_fn(function() + timout({ force = false, time = 100 }) + end, 100) + vim.defer_fn(function() + timout({ force = true, time = 1000 }) + end, 1000) + local col = vim.fn.screencol() + local row = vim.fn.screenrow() + timer:start(5, 2, function() + vim.schedule(function() + if not vim.api.nvim_buf_is_valid(bufnr) then + if timer:is_active() then + timer:close() + end + return + end + if has_start then + return + end + local new_col = vim.fn.screencol() + local new_row = vim.fn.screenrow() + if new_row ~= row and new_col ~= col then + if timer:is_active() then + timer:close() + has_start = true + begin_ts_highlight(bufnr, lang, "highligter") + end + end + end) + end) + end + + return { + ensure_installed = { + "vimdoc", + "bash", + "html", + "json", + "lua", + "markdown", + "markdown_inline", + "query", + "regex", + "vim", + "yaml", + "scss", + "graphql", + }, + highlight = { enable = true }, + indent = { enable = true, disable = { "yaml", "python", "html" } }, + rainbow = { + enable = true, + query = "rainbow-parens", + disable = { "jsx", "html" }, + }, + } + end, config = function(_, opts) require("nvim-treesitter.configs").setup(opts) end, diff --git a/lua/beastvim/tweaks/autocmds.lua b/lua/beastvim/tweaks/autocmds.lua index 245d23f..cbc1477 100644 --- a/lua/beastvim/tweaks/autocmds.lua +++ b/lua/beastvim/tweaks/autocmds.lua @@ -133,3 +133,24 @@ vim.api.nvim_create_autocmd({ "BufWritePre" }, { vim.fn.mkdir(vim.fn.fnamemodify(file, ":p:h"), "p") end, }) + +-- sync system clipboard while yanking +vim.api.nvim_create_autocmd("TextYankPost", { + callback = function() + local v = vim.v.event + local regcontents = v.regcontents + vim.defer_fn(function() + vim.fn.setreg("+", regcontents) + end, 100) + end, +}) + +-- sync system clipboard to vim clipboard +vim.api.nvim_create_autocmd("FocusGained", { + callback = function() + local loaded_content = vim.fn.getreg("+") + if loaded_content ~= "" then + vim.fn.setreg('"', loaded_content) + end + end, +}) diff --git a/lua/beastvim/tweaks/keymaps.lua b/lua/beastvim/tweaks/keymaps.lua index 40b3f40..0935739 100644 --- a/lua/beastvim/tweaks/keymaps.lua +++ b/lua/beastvim/tweaks/keymaps.lua @@ -66,6 +66,9 @@ end, { desc = "Toggle pin scrolloff" }) ------------------- Select all -------------------------------- map("n", "", "ggG", { desc = "Select all" }) +map({"n", "i", "v"}, "", "") +map({"n", "i", "v"}, "", "") + ------------------ Fuzzy Search -------------------------------- vim.keymap.set("n", "", function() -- You can pass additional configuration to telescope to change theme, layout, etc. diff --git a/lua/beastvim/tweaks/options.lua b/lua/beastvim/tweaks/options.lua index 0e328a6..47a61c4 100644 --- a/lua/beastvim/tweaks/options.lua +++ b/lua/beastvim/tweaks/options.lua @@ -44,7 +44,7 @@ opt.numberwidth = 4 -- set number column width to 2 {default 4} opt.signcolumn = "yes" -- always show the sign column, otherwise it would shift the text each time opt.wrap = false -- display lines as one long line opt.sidescrolloff = 0 -opt.smoothscroll = true +-- opt.smoothscroll = true opt.laststatus = 3 opt.list = true -- Show some invisible characters (tabs... opt.guicursor = "n-v-c-sm:block,i-ci-ve:ver25,r-cr-o:hor20" diff --git a/lua/beastvim/utils/lualine.lua b/lua/beastvim/utils/lualine.lua index 6fca1cd..5daeca7 100644 --- a/lua/beastvim/utils/lualine.lua +++ b/lua/beastvim/utils/lualine.lua @@ -3,15 +3,16 @@ local Utils = require("beastvim.utils") ---@class beastvim.utils.lualine local M = {} -local context = {} +local highlight_context = {} +local component_context = {} local counter = 0 ---@param key string The key of the highlight group function M.get_hl_gr(key) - if context[key] ~= nil then - return context[key] + if highlight_context[key] ~= nil then + return highlight_context[key] end local hl_gr = ("SL" .. counter):gsub("%s+", "") - context[key] = hl_gr + highlight_context[key] = hl_gr counter = counter + 1 return hl_gr end @@ -54,7 +55,12 @@ end ---@param type LualineSeparatorType Type of the component (fill, thin) ---@param bg? HexColor Background of a component ---@param text_sep? string Separator between texts -function M.build_component(config, texts, type, bg, text_sep) +---@param cache_key? string Cache key +function M.build_component(config, texts, type, bg, text_sep, cache_key) + if cache_key ~= nil and component_context[cache_key] ~= nil then + return component_context[cache_key] + end + local BAR_BG = Utils.theme.highlight("lualine_c_normal").bg local SEP_GROUP = "SLSeparator" bg = bg or M.get_component_bg(type) @@ -81,13 +87,20 @@ function M.build_component(config, texts, type, bg, text_sep) end, texts), text_sep or "" ) + + local final if config.float then - return M.hl_str(config.separator[type].left, SEP_GROUP) + final = M.hl_str(config.separator[type].left, SEP_GROUP) .. merged_text .. M.hl_str(config.separator[type].right, SEP_GROUP, SEP_GROUP) else - return merged_text + final = merged_text + end + + if cache_key ~= nil then + component_context[cache_key] = final end + return final end ---Hide the component if the current window width is less than the specified minimum width