diff --git a/CHANGELOG.md b/CHANGELOG.md index 7dadeb09..4e2899c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,25 @@ # Changelog +## [12.4.0](https://github.com/LazyVim/LazyVim/compare/v12.3.0...v12.4.0) (2024-06-04) + + +### Features + +* **hipatterns:** added vue/astro ([d6c59d9](https://github.com/LazyVim/LazyVim/commit/d6c59d9a411a96fab22df03368b16740ea19da04)) +* **lazydev:** new lazydev config based on trigger words ([39da851](https://github.com/LazyVim/LazyVim/commit/39da8514d32c9eba40efa045c2d12d2170e206cf)) + + +### Bug Fixes + +* fixup for nvim-snippets compat on 0.9. Fixes [#3426](https://github.com/LazyVim/LazyVim/issues/3426) ([83c0c94](https://github.com/LazyVim/LazyVim/commit/83c0c9405acf4682d473188dd2ce3126c1261ea9)) +* hack for dashboard.nvim so that it shows errors when exiting ([6c3fd9f](https://github.com/LazyVim/LazyVim/commit/6c3fd9fedfa83bac9e63c04d24ff2760569b845e)) +* **hipatterns:** update mini-hipatterns.lua config to add support for heex, rust and svelte files ([#3430](https://github.com/LazyVim/LazyVim/issues/3430)) ([1731e45](https://github.com/LazyVim/LazyVim/commit/1731e455d41a9baa6c80bbc9e89e23c104479431)) +* **lazydev:** easier way of defining library plugin paths ([bb66618](https://github.com/LazyVim/LazyVim/commit/bb66618f1fc265c7a702f3d13d704ffbb1066178)) +* **luasnip:** move mappings to cmp spec so that they dont conflict with native snippets ([da7b773](https://github.com/LazyVim/LazyVim/commit/da7b7738eb84b00c949f48afabebd39266e61d75)) +* **todo-comments:** use toggle for Trouble todo commands ([#3424](https://github.com/LazyVim/LazyVim/issues/3424)) ([028d5bc](https://github.com/LazyVim/LazyVim/commit/028d5bcac5b2a9b6ceb23e2df9c92bdc7d711674)) +* **todo-comments:** use trouble filters for showing only todo/fix/fixmes ([6da95ee](https://github.com/LazyVim/LazyVim/commit/6da95ee7d35f7eab4297c2229d8d79d43f5d12bc)) +* **ui:** fix incorrect colors on change colorscheme (lualine) ([#3431](https://github.com/LazyVim/LazyVim/issues/3431)) ([4d706f1](https://github.com/LazyVim/LazyVim/commit/4d706f1bdc687f1d4d4cd962ec166c65c453633e)) + ## [12.3.0](https://github.com/LazyVim/LazyVim/compare/v12.2.0...v12.3.0) (2024-06-02) diff --git a/doc/LazyVim.txt b/doc/LazyVim.txt index 63d911f6..c8522a17 100644 --- a/doc/LazyVim.txt +++ b/doc/LazyVim.txt @@ -1,4 +1,4 @@ -*LazyVim.txt* For Neovim >= 0.9.0 Last change: 2024 June 02 +*LazyVim.txt* For Neovim >= 0.9.0 Last change: 2024 June 05 ============================================================================== Table of Contents *LazyVim-table-of-contents* diff --git a/lua/lazyvim/config/options.lua b/lua/lazyvim/config/options.lua index 1531ef53..4480d5c5 100644 --- a/lua/lazyvim/config/options.lua +++ b/lua/lazyvim/config/options.lua @@ -19,6 +19,12 @@ vim.g.root_spec = { "lsp", { ".git", "lua" }, "cwd" } -- Set to false to disable. vim.g.lazygit_config = true +-- Options for the LazyVim statuscolumn +vim.g.lazyvim_statuscolumn = { + folds_open = false, -- show fold sign when fold is open + folds_githl = false, -- highlight fold sign with git sign color +} + -- Optionally setup the terminal to use -- This sets `vim.o.shell` and does some additional configuration for: -- * pwsh diff --git a/lua/lazyvim/plugins/coding.lua b/lua/lazyvim/plugins/coding.lua index b39976e3..0e903ba0 100644 --- a/lua/lazyvim/plugins/coding.lua +++ b/lua/lazyvim/plugins/coding.lua @@ -204,14 +204,14 @@ return { { "folke/lazydev.nvim", ft = "lua", - opts = function() - return { - library = { - uv = "luvit-meta/library", - lazyvim = "LazyVim", - }, - } - end, + cmd = "LazyDev", + opts = { + library = { + { path = "luvit-meta/library", words = { "vim%.uv" } }, + { path = "LazyVim", words = { "LazyVim" } }, + { path = "lazy.nvim", words = { "LazyVim" } }, + }, + }, }, -- Manage libuv types with lazy. Plugin will never be loaded { "Bilal2453/luvit-meta", lazy = true }, diff --git a/lua/lazyvim/plugins/compat/nvim-0_9.lua b/lua/lazyvim/plugins/compat/nvim-0_9.lua index fc56b925..6488952b 100644 --- a/lua/lazyvim/plugins/compat/nvim-0_9.lua +++ b/lua/lazyvim/plugins/compat/nvim-0_9.lua @@ -8,12 +8,22 @@ return { { "folke/ts-comments.nvim", enabled = false }, { import = "lazyvim.plugins.extras.coding.mini-comment" }, - -- Use neodev instead of lazydev - { "folke/lazydev.nvim", enabled = false }, + -- Use neodev-types with lazydev + { "folke/neodev.nvim", config = function() end }, + { + "folke/lazydev.nvim", + opts = function(_, opts) + opts.library = opts.library or {} + table.insert(opts.library, { "neodev.nvim/types/stable" }) + end, + config = function(_, opts) + -- force lazydev to load on Neovim 0.9 + require("lazydev.config").have_0_10 = true + require("lazydev").setup(opts) + end, + }, { "neovim/nvim-lspconfig", - dependencies = { - { "folke/neodev.nvim", opts = {} }, - }, + dependencies = {}, }, } diff --git a/lua/lazyvim/plugins/extras/editor/inc-rename.lua b/lua/lazyvim/plugins/extras/editor/inc-rename.lua new file mode 100644 index 00000000..a7c65243 --- /dev/null +++ b/lua/lazyvim/plugins/extras/editor/inc-rename.lua @@ -0,0 +1,38 @@ +return { + + -- Rename with cmdpreview + recommended = true, + desc = "Incremental LSP renaming based on Neovim's command-preview feature", + { + "smjonas/inc-rename.nvim", + cmd = "IncRename", + opts = {}, + }, + + -- LSP Keymaps + { + "neovim/nvim-lspconfig", + opts = function() + local keys = require("lazyvim.plugins.lsp.keymaps").get() + keys[#keys + 1] = { + "cr", + function() + local inc_rename = require("inc_rename") + return ":" .. inc_rename.config.cmd_name .. " " .. vim.fn.expand("") + end, + expr = true, + desc = "Rename (inc-rename.nvim)", + has = "rename", + } + end, + }, + + --- Noice integration + { + "folke/noice.nvim", + optional = true, + opts = { + presets = { inc_rename = true }, + }, + }, +} diff --git a/lua/lazyvim/plugins/extras/lang/angular.lua b/lua/lazyvim/plugins/extras/lang/angular.lua new file mode 100644 index 00000000..ce8a62e4 --- /dev/null +++ b/lua/lazyvim/plugins/extras/lang/angular.lua @@ -0,0 +1,56 @@ +return { + recommended = function() + return LazyVim.extras.wants({ + root = { + "angular.json", + "nx.json", --support for nx workspace + }, + }) + end, + + { + "nvim-treesitter", + opts = function(_, opts) + if type(opts.ensure_installed) == "table" then + vim.list_extend(opts.ensure_installed, { "angular", "scss" }) + end + end, + }, + + -- angularls depends on typescript + { import = "lazyvim.plugins.extras.lang.typescript" }, + + -- LSP Servers + { + "neovim/nvim-lspconfig", + opts = { + servers = { + angularls = {}, + }, + setup = { + angularls = function() + LazyVim.lsp.on_attach(function(client) + if client.name == "angularls" then + --HACK: disable angular renaming capability due to duplicate rename popping up + client.server_capabilities.renameProvider = false + end + end) + end, + }, + }, + }, + + -- Configure tsserver plugin + { + "neovim/nvim-lspconfig", + opts = function(_, opts) + LazyVim.extend(opts.servers.vtsls, "settings.vtsls.tsserver.globalPlugins", { + { + name = "@angular/language-server", + location = LazyVim.get_pkg_path("angular-language-server", "/node_modules/@angular/language-server"), + enableForWorkspaceTypeScriptVersions = false, + }, + }) + end, + }, +} diff --git a/lua/lazyvim/plugins/extras/lang/astro.lua b/lua/lazyvim/plugins/extras/lang/astro.lua index c4192e27..c0e8cfc0 100644 --- a/lua/lazyvim/plugins/extras/lang/astro.lua +++ b/lua/lazyvim/plugins/extras/lang/astro.lua @@ -39,11 +39,7 @@ return { LazyVim.extend(opts.servers.vtsls, "settings.vtsls.tsserver.globalPlugins", { { name = "@astrojs/ts-plugin", - location = LazyVim.get_pkg_path( - "astro-language-server", - "/node_modules/@astrojs/ts-plugin", - { warn = false } - ), + location = LazyVim.get_pkg_path("astro-language-server", "/node_modules/@astrojs/ts-plugin"), enableForWorkspaceTypeScriptVersions = true, }, }) diff --git a/lua/lazyvim/plugins/extras/lang/python-semshi.lua b/lua/lazyvim/plugins/extras/lang/python-semshi.lua deleted file mode 100644 index 2e6df6f9..00000000 --- a/lua/lazyvim/plugins/extras/lang/python-semshi.lua +++ /dev/null @@ -1,33 +0,0 @@ -return { - -- "numiras/semshi", - "wookayin/semshi", -- use a maintained fork - ft = "python", - build = ":UpdateRemotePlugins", - init = function() - -- Disabled these features better provided by LSP or other more general plugins - vim.g["semshi#error_sign"] = false - vim.g["semshi#simplify_markup"] = false - vim.g["semshi#mark_selected_nodes"] = false - vim.g["semshi#update_delay_factor"] = 0.001 - - -- This autocmd must be defined in init to take effect - vim.api.nvim_create_autocmd({ "VimEnter", "ColorScheme" }, { - group = vim.api.nvim_create_augroup("SemanticHighlight", {}), - callback = function() - -- Only add style, inherit or link to the LSP's colors - vim.cmd([[ - highlight! link semshiGlobal @none - highlight! link semshiImported @none - highlight! link semshiParameter @lsp.type.parameter - highlight! link semshiBuiltin @function.builtin - highlight! link semshiAttribute @field - highlight! link semshiSelf @lsp.type.selfKeyword - highlight! link semshiUnresolved @none - highlight! link semshiFree @none - highlight! link semshiAttribute @none - highlight! link semshiParameterUnused @none - ]]) - end, - }) - end, -} diff --git a/lua/lazyvim/plugins/extras/lang/scala.lua b/lua/lazyvim/plugins/extras/lang/scala.lua index 0722b8d6..2092b15c 100644 --- a/lua/lazyvim/plugins/extras/lang/scala.lua +++ b/lua/lazyvim/plugins/extras/lang/scala.lua @@ -1,7 +1,3 @@ --- NOTE: This setup does not define any lsp or dap specific key bindings --- It is recommended that the LazyVim extras dap-core is imported "lazyvim.plugins.extras.dap.core" --- If you like you can setup your own key bindings. --- For minimalistic setup have a look at https://github.com/scalameta/nvim-metals/discussions/39 return { recommended = function() return LazyVim.extras.wants({ @@ -10,44 +6,72 @@ return { }) end, { - "hrsh7th/nvim-cmp", - requires = { - { "hrsh7th/cmp-nvim-lsp" }, - { "hrsh7th/cmp-vsnip" }, - { "hrsh7th/vim-vsnip" }, - }, + "nvim-treesitter/nvim-treesitter", + opts = function(_, opts) + if type(opts.ensure_installed) == "table" then + vim.list_extend(opts.ensure_installed, { "scala" }) + end + end, }, { "scalameta/nvim-metals", - dependencies = { - "nvim-lua/plenary.nvim", - "mfussenegger/nvim-dap", - }, - ft = { "scala", "sbt", "java" }, - init = function() - local metals_config = require("metals").bare_config() - metals_config.init_options.statusBarProvider = "off" - metals_config.settings = { - showImplicitArguments = true, - excludedPackages = { "akka.actor.typed.javadsl", "com.github.swagger.akka.javadsl" }, - } - metals_config.capabilities = require("cmp_nvim_lsp").default_capabilities() - metals_config.on_attach = function(client, bufnr) - require("metals").setup_dap() - end + ft = { "scala", "sbt" }, + config = function() end, + }, + { + "neovim/nvim-lspconfig", + opts = { + servers = { + metals = { + keys = { + { + "me", + function() + require("telescope").extensions.metals.commands() + end, + desc = "Metals commands", + }, + { + "mc", + function() + require("metals").compile_cascade() + end, + desc = "Metals compile cascade", + }, + }, + init_options = { + statusBarProvider = "off", + }, + settings = { + showImplicitArguments = true, + excludedPackages = { "akka.actor.typed.javadsl", "com.github.swagger.akka.javadsl" }, + }, + }, + }, + setup = { + metals = function(_, opts) + local metals = require("metals") + local metals_config = vim.tbl_deep_extend("force", metals.bare_config(), opts) + metals_config.on_attach = LazyVim.has("nvim-dap") and metals.setup_dap or nil - local nvim_metals_group = vim.api.nvim_create_augroup("nvim-metals", { clear = true }) - vim.api.nvim_create_autocmd("FileType", { - -- NOTE: You may or may not want java included here. You will need it if you - -- want basic Java support but it may also conflict if you are using - -- something like nvim-jdtls which also works on a java filetype autocmd. - pattern = { "scala", "sbt", "java" }, - callback = function() - require("metals").initialize_or_attach(metals_config) + local nvim_metals_group = vim.api.nvim_create_augroup("nvim-metals", { clear = true }) + vim.api.nvim_create_autocmd("FileType", { + pattern = { "scala", "sbt" }, + callback = function() + metals.initialize_or_attach(metals_config) + end, + group = nvim_metals_group, + }) + return true end, - group = nvim_metals_group, - }) + }, + }, + }, + { + "mfussenegger/nvim-dap", + optional = true, + opts = function() -- Debug settings local dap = require("dap") dap.configurations.scala = { @@ -70,29 +94,5 @@ return { }, } end, - keys = { - { - "me", - function() - require("telescope").extensions.metals.commands() - end, - desc = "Metals commands", - ft = { "scala", "sbt", "java" }, - }, - { - "mc", - function() - require("metals").compile_cascade() - end, - desc = "Metals compile cascade", - ft = { "scala", "sbt", "java" }, - }, - }, - }, - { - "nvim-treesitter/nvim-treesitter", - opts = function(_, opts) - vim.list_extend(opts.ensure_installed, { "scala" }) - end, }, } diff --git a/lua/lazyvim/plugins/extras/lang/svelte.lua b/lua/lazyvim/plugins/extras/lang/svelte.lua index 7b0588d2..4319b509 100644 --- a/lua/lazyvim/plugins/extras/lang/svelte.lua +++ b/lua/lazyvim/plugins/extras/lang/svelte.lua @@ -39,11 +39,7 @@ return { LazyVim.extend(opts.servers.vtsls, "settings.vtsls.tsserver.globalPlugins", { { name = "typescript-svelte-plugin", - location = LazyVim.get_pkg_path( - "svelte-language-server", - "/node_modules/typescript-svelte-plugin", - { warn = false } - ), + location = LazyVim.get_pkg_path("svelte-language-server", "/node_modules/typescript-svelte-plugin"), enableForWorkspaceTypeScriptVersions = true, }, }) diff --git a/lua/lazyvim/plugins/extras/lang/tex.lua b/lua/lazyvim/plugins/extras/lang/tex.lua index 2d1bca56..5d667b40 100644 --- a/lua/lazyvim/plugins/extras/lang/tex.lua +++ b/lua/lazyvim/plugins/extras/lang/tex.lua @@ -20,7 +20,7 @@ return { "nvim-treesitter/nvim-treesitter", opts = function(_, opts) if type(opts.ensure_installed) == "table" then - vim.list_extend(opts.ensure_installed, { "bibtex", "latex" }) + vim.list_extend(opts.ensure_installed, { "bibtex" }) end if type(opts.highlight.disable) == "table" then vim.list_extend(opts.highlight.disable, { "latex" }) diff --git a/lua/lazyvim/plugins/extras/util/mini-hipatterns.lua b/lua/lazyvim/plugins/extras/util/mini-hipatterns.lua index 7c887088..287c0d77 100644 --- a/lua/lazyvim/plugins/extras/util/mini-hipatterns.lua +++ b/lua/lazyvim/plugins/extras/util/mini-hipatterns.lua @@ -14,7 +14,20 @@ M.plugin = { -- custom LazyVim option to enable the tailwind integration tailwind = { enabled = true, - ft = { "typescriptreact", "javascriptreact", "css", "javascript", "typescript", "html" }, + ft = { + "astro", + "css", + "heex", + "html", + "html-eex", + "javascript", + "javascriptreact", + "rust", + "svelte", + "typescript", + "typescriptreact", + "vue", + }, -- full: the whole css class will be highlighted -- compact: only the color will be highlighted style = "full", @@ -37,14 +50,6 @@ M.plugin = { } end, config = function(_, opts) - -- backward compatibility - if opts.tailwind == true then - opts.tailwind = { - enabled = true, - ft = { "typescriptreact", "javascriptreact", "css", "javascript", "typescript", "html" }, - style = "full", - } - end if type(opts.tailwind) == "table" and opts.tailwind.enabled then -- reset hl groups when colorscheme changes vim.api.nvim_create_autocmd("ColorScheme", { diff --git a/lua/lazyvim/plugins/lsp/init.lua b/lua/lazyvim/plugins/lsp/init.lua index 1df5f728..5066d393 100644 --- a/lua/lazyvim/plugins/lsp/init.lua +++ b/lua/lazyvim/plugins/lsp/init.lua @@ -244,8 +244,11 @@ return { if LazyVim.lsp.is_enabled("denols") and LazyVim.lsp.is_enabled("vtsls") then local is_deno = require("lspconfig.util").root_pattern("deno.json", "deno.jsonc") LazyVim.lsp.disable("vtsls", is_deno) - LazyVim.lsp.disable("denols", function(root_dir) - return not is_deno(root_dir) + LazyVim.lsp.disable("denols", function(root_dir, config) + if not is_deno(root_dir) then + config.settings.deno.enable = false + end + return false end) end end, diff --git a/lua/lazyvim/plugins/lsp/keymaps.lua b/lua/lazyvim/plugins/lsp/keymaps.lua index d56cee08..3f2bd690 100644 --- a/lua/lazyvim/plugins/lsp/keymaps.lua +++ b/lua/lazyvim/plugins/lsp/keymaps.lua @@ -26,6 +26,7 @@ function M.get() { "cc", vim.lsp.codelens.run, desc = "Run Codelens", mode = { "n", "v" }, has = "codeLens" }, { "cC", vim.lsp.codelens.refresh, desc = "Refresh & Display Codelens", mode = { "n" }, has = "codeLens" }, { "cR", LazyVim.lsp.rename_file, desc = "Rename File", mode ={"n"}, has = { "workspace/didRenameFiles", "workspace/willRenameFiles" } }, + { "cr", vim.lsp.buf.rename, desc = "Rename", has = "rename" }, { "cA", function() @@ -50,20 +51,7 @@ function M.get() { "", function() LazyVim.lsp.words.jump(-vim.v.count1, true) end, has = "documentHighlight", desc = "Prev Reference", cond = function() return LazyVim.lsp.words.enabled end }, } - if LazyVim.has("inc-rename.nvim") then - M._keys[#M._keys + 1] = { - "cr", - function() - local inc_rename = require("inc_rename") - return ":" .. inc_rename.config.cmd_name .. " " .. vim.fn.expand("") - end, - expr = true, - desc = "Rename", - has = "rename", - } - else - M._keys[#M._keys + 1] = { "cr", vim.lsp.buf.rename, desc = "Rename", has = "rename" } - end + return M._keys end diff --git a/lua/lazyvim/plugins/ui.lua b/lua/lazyvim/plugins/ui.lua index 6f371351..18aa5200 100644 --- a/lua/lazyvim/plugins/ui.lua +++ b/lua/lazyvim/plugins/ui.lua @@ -157,24 +157,25 @@ return { { function() return require("noice").api.status.command.get() end, cond = function() return package.loaded["noice"] and require("noice").api.status.command.has() end, - color = LazyVim.ui.fg("Statement"), + color = function() return LazyVim.ui.fg("Statement") end, }, -- stylua: ignore { function() return require("noice").api.status.mode.get() end, cond = function() return package.loaded["noice"] and require("noice").api.status.mode.has() end, - color = LazyVim.ui.fg("Constant"), + color = function() return LazyVim.ui.fg("Constant") end, }, -- stylua: ignore { function() return " " .. require("dap").status() end, - cond = function () return package.loaded["dap"] and require("dap").status() ~= "" end, - color = LazyVim.ui.fg("Debug"), + cond = function() return package.loaded["dap"] and require("dap").status() ~= "" end, + color = function() return LazyVim.ui.fg("Debug") end, }, + -- stylua: ignore { require("lazy.status").updates, cond = require("lazy.status").has_updates, - color = LazyVim.ui.fg("Special"), + color = function() return LazyVim.ui.fg("Special") end, }, { "diff", @@ -298,7 +299,6 @@ return { bottom_search = true, command_palette = true, long_message_to_split = true, - inc_rename = true, }, }, -- stylua: ignore @@ -354,7 +354,7 @@ return { { action = 'lua require("persistence").load()', desc = " Restore Session", icon = " ", key = "s" }, { action = "LazyExtras", desc = " Lazy Extras", icon = " ", key = "x" }, { action = "Lazy", desc = " Lazy", icon = "󰒲 ", key = "l" }, - { action = "qa", desc = " Quit", icon = " ", key = "q" }, + { action = function() vim.api.nvim_input("qa") end, desc = " Quit", icon = " ", key = "q" }, }, footer = function() local stats = require("lazy").stats() diff --git a/lua/lazyvim/util/init.lua b/lua/lazyvim/util/init.lua index 2417b597..e6927069 100644 --- a/lua/lazyvim/util/init.lua +++ b/lua/lazyvim/util/init.lua @@ -246,7 +246,9 @@ function M.get_pkg_path(pkg, path, opts) path = path or "" local ret = root .. "/packages/" .. pkg .. "/" .. path if opts.warn and not vim.loop.fs_stat(ret) then - M.warn(("Mason package path not found for **%s**:\n- `%s`"):format(pkg, path)) + M.warn( + ("Mason package path not found for **%s**:\n- `%s`\nYou may need to force update the package."):format(pkg, path) + ) end return ret end diff --git a/lua/lazyvim/util/plugin.lua b/lua/lazyvim/util/plugin.lua index 9886122b..f34527ac 100644 --- a/lua/lazyvim/util/plugin.lua +++ b/lua/lazyvim/util/plugin.lua @@ -15,6 +15,10 @@ M.deprecated_extras = { ["lazyvim.plugins.extras.coding.mini-ai"] = "`mini.ai` is now a core LazyVim plugin (again)", ["lazyvim.plugins.extras.lazyrc"] = "local spec files are now a lazy.nvim feature", ["lazyvim.plugins.extras.editor.trouble-v3"] = "Trouble v3 has been merged in main", + ["lazyvim.plugins.extras.lang.python-semshi"] = [[The python-semshi extra has been removed, + because it's causing too many issues. + Either use `basedpyright`, or copy the [old extra](https://github.com/LazyVim/LazyVim/blob/c1f5fcf9c7ed2659c9d5ac41b3bb8a93e0a3c6a0/lua/lazyvim/plugins/extras/lang/python-semshi.lua#L1) to your own config. + ]], } M.deprecated_modules = {} diff --git a/lua/lazyvim/util/toggle.lua b/lua/lazyvim/util/toggle.lua index b001798f..95bb3e76 100644 --- a/lua/lazyvim/util/toggle.lua +++ b/lua/lazyvim/util/toggle.lua @@ -73,21 +73,41 @@ function M.inlay_hints(buf, value) end end +---@type {k:string, v:any}[] M._maximized = nil -function M.maximize() +---@param state boolean? +function M.maximize(state) + if state == (M._maximized ~= nil) then + return + end if M._maximized then - vim.o.winwidth = M._maximized.width - vim.o.winheight = M._maximized.height + for _, opt in ipairs(M._maximized) do + vim.o[opt.k] = opt.v + end M._maximized = nil vim.cmd("wincmd =") else - M._maximized = { - width = vim.o.winwidth, - height = vim.o.winheight, - } - vim.o.winwidth = 999 - vim.o.winheight = 999 + M._maximized = {} + local function set(k, v) + table.insert(M._maximized, 1, { k = k, v = vim.o[k] }) + vim.o[k] = v + end + set("winwidth", 999) + set("winheight", 999) + set("winminwidth", 10) + set("winminheight", 4) + vim.cmd("wincmd =") end + -- `QuitPre` seems to be executed even if we quit a normal window, so we don't want that + -- `VimLeavePre` might be another consideration? Not sure about differences between the 2 + vim.api.nvim_create_autocmd("ExitPre", { + once = true, + group = vim.api.nvim_create_augroup("lazyvim_restore_max_exit_pre", { clear = true }), + desc = "Restore width/height when close Neovim while maximized", + callback = function() + M.maximize(false) + end, + }) end setmetatable(M, { diff --git a/lua/lazyvim/util/ui.lua b/lua/lazyvim/util/ui.lua index a7bdc700..5877fd7f 100644 --- a/lua/lazyvim/util/ui.lua +++ b/lua/lazyvim/util/ui.lua @@ -99,12 +99,18 @@ function M.statuscolumn() local components = { "", "", "" } -- left, middle, right + local show_open_folds = vim.g.lazyvim_statuscolumn and vim.g.lazyvim_statuscolumn.folds_open + local use_githl = vim.g.lazyvim_statuscolumn and vim.g.lazyvim_statuscolumn.folds_githl + if show_signs then ---@type Sign?,Sign?,Sign? - local left, right, fold + local left, right, fold, githl for _, s in ipairs(M.get_signs(buf, vim.v.lnum)) do if s.name and (s.name:find("GitSign") or s.name:find("MiniDiffSign")) then right = s + if use_githl then + githl = s["texthl"] + end else left = s end @@ -112,9 +118,16 @@ function M.statuscolumn() if vim.v.virtnum ~= 0 then left = nil end + vim.api.nvim_win_call(win, function() if vim.fn.foldclosed(vim.v.lnum) >= 0 then - fold = { text = vim.opt.fillchars:get().foldclose or "", texthl = "Folded" } + fold = { text = vim.opt.fillchars:get().foldclose or "", texthl = githl or "Folded" } + elseif + show_open_folds + and not LazyVim.ui.skip_foldexpr[buf] + and vim.treesitter.foldexpr(vim.v.lnum):sub(1, 1) == ">" + then -- fold start + fold = { text = vim.opt.fillchars:get().foldopen or "", texthl = githl } end end) -- Left: mark or non-git sign