feat: added NEWS.md and option to automatically show when changed (enabled by default)
This commit is contained in:
65
NEWS.md
Normal file
65
NEWS.md
Normal file
@ -0,0 +1,65 @@
|
||||
# What's new?
|
||||
|
||||
## 10.x
|
||||
|
||||
- `nvim-ts-autotag` is now included by default
|
||||
|
||||
- `nvim-treesitter-context` is now included by default
|
||||
|
||||
- Added extra for `symbols-outline.nvim`
|
||||
|
||||
- Added extra for `aerial.nvim`
|
||||
|
||||
- `nvim-navic` has been removed. If you want to keep using `nvim-navic`,
|
||||
you can enable the **editor.navic** extra
|
||||
|
||||
- New `:LazyExtras` command for managing **LazyVim** extras
|
||||
|
||||
- Improved **formatting**:
|
||||
|
||||
- **LazyVim** can now work with multiple formatters. Types:
|
||||
|
||||
- **primary**: only one primary formatter can be active at a time.
|
||||
_(conform, none-ls, LSP)_
|
||||
- **secondary**: multiple secondary formatters can be active _(eslint, ...)_
|
||||
|
||||
- **LazyVim** automatically selects the primary formatter based on the
|
||||
current available sources and priorities.
|
||||
|
||||
- New `:LazyFormat` command for formatting the current selection or buffer
|
||||
- New `:LazyFormatInfo` command for displaying the active formatters
|
||||
for the current buffer
|
||||
- Auto-formatting can be disabled with:
|
||||
|
||||
```lua
|
||||
vim.g.autoformat = false -- globally
|
||||
vim.b.autoformat = false -- buffer-local
|
||||
```
|
||||
|
||||
- `none-ls.nvim` is no longer installed by default
|
||||
|
||||
- `conform.nvim` is now the default formatter
|
||||
- `nvim-lint` is now the default linter
|
||||
- If you want to keep using `none-ls.nvim`,
|
||||
you can enable the **lsp.none-ls** extra
|
||||
|
||||
- `dashboard.nvim` is the new default dashboard plugin
|
||||
|
||||
- If you want to keep using `alpha.nvim`, you can enable the **ui.alpha** extra
|
||||
|
||||
- Improved **root detection**:
|
||||
|
||||
- New `:LazyRoot` command that shows info about the root dir detection
|
||||
- Configurable with `vim.g.root_spec`
|
||||
|
||||
```lua
|
||||
-- LazyVim root dir detection
|
||||
-- Each entry can be:
|
||||
-- * the name of a detector function like `lsp` or `cwd`
|
||||
-- * a pattern or array of patterns like `.git` or `lua`.
|
||||
-- * a function with signature `function(buf) -> string|string[]`
|
||||
vim.g.root_spec = { "lsp", { ".git", "lua" }, "cwd" }
|
||||
|
||||
-- To disable root detection set to just "cwd"
|
||||
vim.g.root_spec = { "cwd" }
|
||||
```
|
@ -19,6 +19,13 @@ local defaults = {
|
||||
-- lazyvim.config.options can't be configured here since that's loaded before lazyvim setup
|
||||
-- if you want to disable loading options, add `package.loaded["lazyvim.config.options"] = true` to the top of your init.lua
|
||||
},
|
||||
news = {
|
||||
-- When enabled, NEWS.md will be shown when changed.
|
||||
-- This only contains big new features and breaking changes.
|
||||
lazyvim = true,
|
||||
-- Same but for Neovim's news.txt
|
||||
neovim = false,
|
||||
},
|
||||
-- icons used by other plugins
|
||||
-- stylua: ignore
|
||||
icons = {
|
||||
@ -123,6 +130,7 @@ local defaults = {
|
||||
M.json = {
|
||||
data = {
|
||||
version = nil, ---@type string?
|
||||
hashes = {}, ---@type table<string, string>
|
||||
extras = {}, ---@type string[]
|
||||
},
|
||||
}
|
||||
@ -173,6 +181,7 @@ function M.setup(opts)
|
||||
M.load("keymaps")
|
||||
|
||||
Util.format.setup()
|
||||
Util.news.setup()
|
||||
|
||||
vim.api.nvim_create_user_command("LazyRoot", function()
|
||||
Util.root.info()
|
||||
|
@ -125,7 +125,7 @@ map("n", "<leader>qq", "<cmd>qa<cr>", { desc = "Quit all" })
|
||||
map("n", "<leader>ui", vim.show_pos, { desc = "Inspect Pos" })
|
||||
|
||||
-- LazyVim Changelog
|
||||
map("n", "<leader>L", Util.changelog, {desc = "LazyVim Changelog"})
|
||||
map("n", "<leader>L", function() Util.news.changelog() end, { desc = "LazyVim Changelog" })
|
||||
|
||||
-- floating terminal
|
||||
local lazyterm = function() Util.terminal(nil, { cwd = Util.root() }) end
|
||||
|
@ -11,6 +11,7 @@ local LazyUtil = require("lazy.core.util")
|
||||
---@field plugin lazyvim.util.plugin
|
||||
---@field extras lazyvim.util.extras
|
||||
---@field inject lazyvim.util.inject
|
||||
---@field news lazyvim.util.news
|
||||
local M = {}
|
||||
|
||||
---@type table<string, string|string[]>
|
||||
@ -137,14 +138,6 @@ function M.on_load(name, fn)
|
||||
end
|
||||
end
|
||||
|
||||
function M.changelog()
|
||||
local lv = require("lazy.core.config").plugins.LazyVim
|
||||
local float = require("lazy.util").open(lv.dir .. "/CHANGELOG.md")
|
||||
vim.wo[float.win].spell = false
|
||||
vim.wo[float.win].wrap = false
|
||||
vim.diagnostic.disable(float.buf)
|
||||
end
|
||||
|
||||
-- Wrapper around vim.keymap.set that will
|
||||
-- not create a keymap if a lazy key handler exists.
|
||||
-- It will also set `silent` to true by default.
|
||||
|
77
lua/lazyvim/util/news.lua
Normal file
77
lua/lazyvim/util/news.lua
Normal file
@ -0,0 +1,77 @@
|
||||
local Config = require("lazyvim.config")
|
||||
local Util = require("lazyvim.util")
|
||||
|
||||
---@class lazyvim.util.news
|
||||
local M = {}
|
||||
|
||||
function M.hash(file)
|
||||
local stat = vim.loop.fs_stat(file)
|
||||
if not stat then
|
||||
return
|
||||
end
|
||||
return stat.size .. ""
|
||||
end
|
||||
|
||||
function M.setup()
|
||||
vim.schedule(function()
|
||||
if Config.news.lazyvim then
|
||||
M.lazyvim(true)
|
||||
end
|
||||
if Config.news.neovim then
|
||||
M.neovim(true)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
function M.changelog()
|
||||
M.open("CHANGELOG.md", { plugin = "LazyVim" })
|
||||
end
|
||||
|
||||
function M.lazyvim(when_changed)
|
||||
M.open("NEWS.md", { plugin = "LazyVim", when_changed = when_changed })
|
||||
end
|
||||
|
||||
function M.neovim(when_changed)
|
||||
M.open("doc/news.txt", { rtp = true, when_changed = when_changed })
|
||||
end
|
||||
|
||||
---@param file string
|
||||
---@param opts? {plugin?:string, rtp?:boolean, when_changed?:boolean}
|
||||
function M.open(file, opts)
|
||||
opts = opts or {}
|
||||
if opts.plugin then
|
||||
local plugin = require("lazy.core.config").plugins[opts.plugin] --[[@as LazyPlugin?]]
|
||||
if not plugin then
|
||||
return Util.error("plugin not found: " .. opts.plugin)
|
||||
end
|
||||
file = plugin.dir .. "/" .. file
|
||||
elseif opts.rtp then
|
||||
file = vim.api.nvim_get_runtime_file(file, false)[1]
|
||||
end
|
||||
|
||||
if not file then
|
||||
return Util.error("File not found")
|
||||
end
|
||||
|
||||
if opts.when_changed then
|
||||
local hash = M.hash(file)
|
||||
if hash == Config.json.data.hashes[file] then
|
||||
return
|
||||
end
|
||||
Config.json.data.hashes[file] = hash
|
||||
Config.json.save()
|
||||
end
|
||||
|
||||
local float = require("lazy.util").float({
|
||||
file = file,
|
||||
size = { width = 0.6, height = 0.6 },
|
||||
})
|
||||
vim.wo[float.win].spell = false
|
||||
vim.wo[float.win].wrap = false
|
||||
vim.wo[float.win].signcolumn = "yes"
|
||||
vim.wo[float.win].statuscolumn = " "
|
||||
vim.wo[float.win].conceallevel = 3
|
||||
vim.diagnostic.disable(float.buf)
|
||||
end
|
||||
|
||||
return M
|
Reference in New Issue
Block a user