Compare commits

..

8 Commits

9 changed files with 56 additions and 53 deletions

@ -1,5 +1,20 @@
# Changelog
## [8.1.0](https://github.com/LazyVim/LazyVim/compare/v8.0.0...v8.1.0) (2023-10-01)
### Features
* **conform:** set vim.opt.formatexpr ([766d5e5](https://github.com/LazyVim/LazyVim/commit/766d5e5bf7a8e40910a00aef4dc30f36376e5652))
* **elixir:** Add credo if none-ls is used ([#1546](https://github.com/LazyVim/LazyVim/issues/1546)) ([2ffd629](https://github.com/LazyVim/LazyVim/commit/2ffd629cc7a68e6e4a721ac8babe6b7cf612868e))
* **format:** show warning when no formatter ran when using the format keymap ([e36f7d8](https://github.com/LazyVim/LazyVim/commit/e36f7d811c396b60bcbf65f962b3f52d2f75b0b3))
* **go:** add goimports ([#1549](https://github.com/LazyVim/LazyVim/issues/1549)) ([e8ab2ff](https://github.com/LazyVim/LazyVim/commit/e8ab2ff5b6a75952943d3ba44586c7de5588be33))
### Bug Fixes
* **format:** moved formatting keymap to lua/lazyvim/config/keymaps.lua ([9b16770](https://github.com/LazyVim/LazyVim/commit/9b1677057377400ab292c51bbc085c82637a39d4))
## [8.0.0](https://github.com/LazyVim/LazyVim/compare/v7.0.3...v8.0.0) (2023-10-01)

@ -54,7 +54,7 @@ LazyVim 提供了两全其美的方式 - 根据需要调整配置的灵活性,
## ⚡️ 要求
- Neovim >= **0.8.0** (需要用 **LuaJIT** 构建)
- Neovim >= **0.9.0** (需要用 **LuaJIT** 构建)
- Git >= **2.19.0** (用于部分克隆支持)
- 一个 [Nerd Font](https://www.nerdfonts.com/) 字体 **_(可选)_**
- 一个用于 `nvim-treesitter`**C** 编译器。看 [这里](https://github.com/nvim-treesitter/nvim-treesitter#requirements)

@ -103,6 +103,11 @@ if not Util.has("trouble.nvim") then
map("n", "]q", vim.cmd.cnext, { desc = "Next quickfix" })
end
-- formatting
map({ "n", "v" }, "<leader>cf", function()
require("lazyvim.plugins.lsp.format").format({ force = true })
end, { desc = "Format" })
-- stylua: ignore start
-- toggle options

@ -5,6 +5,7 @@ return {
lazy = true,
cmd = "ConformInfo",
init = function()
vim.o.formatexpr = "v:lua.require'conform'.formatexpr()"
-- Install the conform formatter on VeryLazy
require("lazyvim.util").on_very_lazy(function()
require("lazyvim.plugins.lsp.format").custom_format = function(buf)

@ -29,4 +29,24 @@ return {
},
},
},
{
"nvimtools/none-ls.nvim",
optional = true,
opts = function(_, opts)
local nls = require("null-ls")
opts.sources = opts.sources or {}
vim.list_extend(opts.sources, {
nls.builtins.diagnostics.credo,
})
end,
},
{
"mfussenegger/nvim-lint",
optional = true,
opts = {
linters_by_ft = {
elixir = { "credo" },
},
},
},
}

@ -91,10 +91,20 @@ return {
vim.list_extend(opts.sources, {
nls.builtins.code_actions.gomodifytags,
nls.builtins.code_actions.impl,
nls.builtins.formatting.goimports,
})
end
end,
},
{
"stevearc/conform.nvim",
optional = true,
opts = {
formatters_by_ft = {
go = { "goimports" },
},
},
},
{
"mfussenegger/nvim-dap",
optional = true,
@ -103,7 +113,7 @@ return {
"mason.nvim",
opts = function(_, opts)
opts.ensure_installed = opts.ensure_installed or {}
vim.list_extend(opts.ensure_installed, { "gomodifytags", "impl", "delve" })
vim.list_extend(opts.ensure_installed, { "gomodifytags", "impl", "goimports", "delve" })
end,
},
{

@ -50,13 +50,12 @@ function M.format(opts)
end, formatters.active)
if #client_ids == 0 then
if opts and opts.force then
Util.warn("No formatter available", { title = "LazyVim" })
end
return
end
if M.opts.format_notify then
M.notify(formatters)
end
vim.lsp.buf.format(vim.tbl_deep_extend("force", {
bufnr = buf,
filter = function(client)
@ -65,45 +64,6 @@ function M.format(opts)
}, require("lazyvim.util").opts("nvim-lspconfig").format or {}))
end
---@param formatters LazyVimFormatters
function M.notify(formatters)
local lines = { "# Active:" }
for _, client in ipairs(formatters.active) do
local line = "- **" .. client.name .. "**"
if client.name == "null-ls" then
line = line
.. " ("
.. table.concat(
vim.tbl_map(function(f)
return "`" .. f.name .. "`"
end, formatters.null_ls),
", "
)
.. ")"
end
table.insert(lines, line)
end
if #formatters.available > 0 then
table.insert(lines, "")
table.insert(lines, "# Disabled:")
for _, client in ipairs(formatters.available) do
table.insert(lines, "- **" .. client.name .. "**")
end
end
vim.notify(table.concat(lines, "\n"), vim.log.levels.INFO, {
title = "Formatting",
on_open = function(win)
vim.api.nvim_win_set_option(win, "conceallevel", 3)
vim.api.nvim_win_set_option(win, "spell", false)
local buf = vim.api.nvim_win_get_buf(win)
vim.treesitter.start(buf, "markdown")
end,
})
end
-- Gets all lsp clients that support formatting.
-- When a null-ls formatter is available for the current filetype,
-- only null-ls formatters are returned.

@ -41,9 +41,6 @@ return {
capabilities = {},
-- Automatically format on save
autoformat = true,
-- Enable this to show formatters used in a notification
-- Useful for debugging formatter issues
format_notify = false,
-- options for vim.lsp.buf.format
-- `bufnr` and `filter` is handled by the LazyVim formatter,
-- but can be also overridden when specified

@ -5,9 +5,6 @@ M._keys = nil
---@return (LazyKeys|{has?:string})[]
function M.get()
local format = function()
require("lazyvim.plugins.lsp.format").format({ force = true })
end
if not M._keys then
---@class PluginLspKeys
-- stylua: ignore
@ -28,8 +25,6 @@ function M.get()
{ "[e", M.diagnostic_goto(false, "ERROR"), desc = "Prev Error" },
{ "]w", M.diagnostic_goto(true, "WARN"), desc = "Next Warning" },
{ "[w", M.diagnostic_goto(false, "WARN"), desc = "Prev Warning" },
{ "<leader>cf", format, desc = "Format Document", has = "formatting" },
{ "<leader>cf", format, desc = "Format Range", mode = "v", has = "rangeFormatting" },
{ "<leader>ca", vim.lsp.buf.code_action, desc = "Code Action", mode = { "n", "v" }, has = "codeAction" },
{
"<leader>cA",