Compare commits

..

13 Commits

37 changed files with 1104 additions and 330 deletions

View File

@ -1,3 +1,3 @@
{
".": "12.44.0"
".": "12.43.0"
}

View File

@ -1,28 +1,5 @@
# Changelog
## [12.44.0](https://github.com/LazyVim/LazyVim/compare/v12.43.0...v12.44.0) (2024-11-02)
### Features
* **blink:** use vim.o.pumblend as winblend option for autocomplete menu in blink ([28da1eb](https://github.com/LazyVim/LazyVim/commit/28da1eb073f99abda9ea9b2349e5d8b8087ffcce))
* **extras:** blink ([#4680](https://github.com/LazyVim/LazyVim/issues/4680)) ([ad52bf9](https://github.com/LazyVim/LazyVim/commit/ad52bf91bc8f1821bbb0b7218d03768eec9a9e42))
* **extras:** enable crates.nvim in-process lsp server ([#4684](https://github.com/LazyVim/LazyVim/issues/4684)) ([db8895b](https://github.com/LazyVim/LazyVim/commit/db8895b518278331fb73bbd81975cbe5012c8f71))
### Bug Fixes
* **autocmds:** `vim.highlight` is deprecated ([a7b4c43](https://github.com/LazyVim/LazyVim/commit/a7b4c4391bccc894f56847ead7abe4ae7a8e4fc0))
* **autocmds:** change mapping for `lazyvim_close_with_q` ([#4638](https://github.com/LazyVim/LazyVim/issues/4638)) ([5f432d9](https://github.com/LazyVim/LazyVim/commit/5f432d997e397790cea39d9bb8826c1d4ca14afb))
* **autocmds:** close window and force delete buf on q. See [#4638](https://github.com/LazyVim/LazyVim/issues/4638) ([cb40a09](https://github.com/LazyVim/LazyVim/commit/cb40a09538dc0c417a7ffbbacdbdec90be4a792c))
* **autocmds:** force close buffers with q. See [#4638](https://github.com/LazyVim/LazyVim/issues/4638) ([0eb4009](https://github.com/LazyVim/LazyVim/commit/0eb400908d17f4116f02c6464d7ef81456ca303c))
* **blink:** explicetely set version=false for now ([ec616a3](https://github.com/LazyVim/LazyVim/commit/ec616a3cecaf1e5de1687223575ff019ad688e55))
* **catppuccin:** fix bufferline integration when no colorscheme is set. Closes [#4641](https://github.com/LazyVim/LazyVim/issues/4641) ([6570a14](https://github.com/LazyVim/LazyVim/commit/6570a141c0de30fccee38e2b10dcd14830624e16))
* **copilot:** create undo point before accepting copilot suggestion when using blink ([6e1d099](https://github.com/LazyVim/LazyVim/commit/6e1d0994d99e63a46c3eff737c44ca47e3ecbe28))
* **dap:** remove explicit `load_launchjs` call ([#4634](https://github.com/LazyVim/LazyVim/issues/4634)) ([2f6c1f6](https://github.com/LazyVim/LazyVim/commit/2f6c1f60834108359b3404748453a65843909a03))
* **lazygit:** file history when cwd is outside the repo ([#4666](https://github.com/LazyVim/LazyVim/issues/4666)) ([4ee6be4](https://github.com/LazyVim/LazyVim/commit/4ee6be4499008db458089fb2573b13f6b5ec5d3b))
* **rust:** disable rust_analyzer in the rust extra. Fixes [#4685](https://github.com/LazyVim/LazyVim/issues/4685) ([1d3d64f](https://github.com/LazyVim/LazyVim/commit/1d3d64fd1ae26581b71f39091c816e568b7a3b39))
## [12.43.0](https://github.com/LazyVim/LazyVim/compare/v12.42.0...v12.43.0) (2024-10-23)

14
NEWS.md
View File

@ -1,19 +1,5 @@
# What's new?
## 13.x
- Big new release with a lot of changes and improvements!
- The biggest change is the move of a bunch of core features to
[snacks.nvim](https://github.com/folke/snacks.nvim) and fully
integrating it into **LazyVim**.
- I highly suggest having a look at the **snacks.nvim** documentation
to see all the new features and improvements. Most important changes:
- `Snacks.notifier` for notifications instead of `nvim-notify`
- `Snacks.terminal` is similar to `lazyterm`, but has more features
and creates bottom splits by default (similar to the `edgy` integrating)
## 12.x
- **Markdown Extra**: [headlines.nvim](https://github.com/lukas-reineke/headlines.nvim) has been removed in favor of [markdown.nvim](https://github.com/MeanderingProgrammer/markdown.nvim)

View File

@ -1,4 +1,4 @@
*LazyVim.txt* For Neovim Last change: 2024 November 03
*LazyVim.txt* For Neovim Last change: 2024 November 02
==============================================================================
Table of Contents *LazyVim-table-of-contents*

View File

@ -18,7 +18,7 @@ vim.api.nvim_create_autocmd({ "FocusGained", "TermClose", "TermLeave" }, {
vim.api.nvim_create_autocmd("TextYankPost", {
group = augroup("highlight_yank"),
callback = function()
(vim.hl or vim.highlight).on_yank()
vim.highlight.on_yank()
end,
})
@ -55,22 +55,20 @@ vim.api.nvim_create_autocmd("FileType", {
group = augroup("close_with_q"),
pattern = {
"PlenaryTestPopup",
"checkhealth",
"dbout",
"gitsigns-blame",
"grug-far",
"help",
"lspinfo",
"neotest-output",
"neotest-output-panel",
"neotest-summary",
"notify",
"qf",
"snacks_win",
"snacks_notif",
"spectre_panel",
"startuptime",
"tsplayground",
"neotest-output",
"checkhealth",
"neotest-summary",
"neotest-output-panel",
"dbout",
"gitsigns-blame",
},
callback = function(event)
vim.bo[event.buf].buflisted = false
@ -126,3 +124,29 @@ vim.api.nvim_create_autocmd({ "BufWritePre" }, {
vim.fn.mkdir(vim.fn.fnamemodify(file, ":p:h"), "p")
end,
})
vim.filetype.add({
pattern = {
[".*"] = {
function(path, buf)
return vim.bo[buf]
and vim.bo[buf].filetype ~= "bigfile"
and path
and vim.fn.getfsize(path) > vim.g.bigfile_size
and "bigfile"
or nil
end,
},
},
})
vim.api.nvim_create_autocmd({ "FileType" }, {
group = augroup("bigfile"),
pattern = "bigfile",
callback = function(ev)
vim.b.minianimate_disable = true
vim.schedule(function()
vim.bo[ev.buf].syntax = vim.filetype.match({ buf = ev.buf }) or ""
end)
end,
})

View File

@ -3,7 +3,7 @@ _G.LazyVim = require("lazyvim.util")
---@class LazyVimConfig: LazyVimOptions
local M = {}
M.version = "12.44.0" -- x-release-please-version
M.version = "12.43.0" -- x-release-please-version
LazyVim.config = M
---@class LazyVimOptions

View File

@ -37,9 +37,7 @@ map("n", "[b", "<cmd>bprevious<cr>", { desc = "Prev Buffer" })
map("n", "]b", "<cmd>bnext<cr>", { desc = "Next Buffer" })
map("n", "<leader>bb", "<cmd>e #<cr>", { desc = "Switch to Other Buffer" })
map("n", "<leader>`", "<cmd>e #<cr>", { desc = "Switch to Other Buffer" })
map("n", "<leader>bd", function()
Snacks.bufdelete()
end, { desc = "Delete Buffer" })
map("n", "<leader>bd", LazyVim.ui.bufremove, { desc = "Delete Buffer" })
map("n", "<leader>bD", "<cmd>:bd<cr>", { desc = "Delete Buffer and Window" })
-- Clear search with <esc>
@ -117,28 +115,37 @@ map("n", "[w", diagnostic_goto(false, "WARN"), { desc = "Prev Warning" })
-- stylua: ignore start
-- toggle options
LazyVim.format.snacks_toggle():map("<leader>uf")
LazyVim.format.snacks_toggle(true):map("<leader>uF")
Snacks.toggle.option("spell", { name = "Spelling"}):map("<leader>us")
Snacks.toggle.option("wrap", {name = "Wrap"}):map("<leader>uw")
Snacks.toggle.option("relativenumber", { name = "Relative Number"}):map("<leader>uL")
Snacks.toggle.diagnostics():map("<leader>ud")
Snacks.toggle.line_number():map("<leader>ul")
Snacks.toggle.option("conceallevel", {off = 0, on = vim.o.conceallevel > 0 and vim.o.conceallevel or 2}):map("<leader>uc")
Snacks.toggle.treesitter():map("<leader>uT")
Snacks.toggle.option("background", { off = "light", on = "dark" , name = "Dark Background"}):map("<leader>ub")
LazyVim.toggle.map("<leader>uf", LazyVim.toggle.format())
LazyVim.toggle.map("<leader>uF", LazyVim.toggle.format(true))
LazyVim.toggle.map("<leader>us", LazyVim.toggle("spell", { name = "Spelling" }))
LazyVim.toggle.map("<leader>uw", LazyVim.toggle("wrap", { name = "Wrap" }))
LazyVim.toggle.map("<leader>uL", LazyVim.toggle("relativenumber", { name = "Relative Number" }))
LazyVim.toggle.map("<leader>ud", LazyVim.toggle.diagnostics)
LazyVim.toggle.map("<leader>ul", LazyVim.toggle.number)
LazyVim.toggle.map( "<leader>uc", LazyVim.toggle("conceallevel", { values = { 0, vim.o.conceallevel > 0 and vim.o.conceallevel or 2 } }))
LazyVim.toggle.map("<leader>uT", LazyVim.toggle.treesitter)
LazyVim.toggle.map("<leader>ub", LazyVim.toggle("background", { values = { "light", "dark" }, name = "Background" }))
if vim.lsp.inlay_hint then
Snacks.toggle.inlay_hints():map("<leader>uh")
LazyVim.toggle.map("<leader>uh", LazyVim.toggle.inlay_hints)
end
-- lazygit
map("n", "<leader>gg", function() Snacks.lazygit( { cwd = LazyVim.root.git() }) end, { desc = "Lazygit (Root Dir)" })
map("n", "<leader>gG", function() Snacks.lazygit() end, { desc = "Lazygit (cwd)" })
map("n", "<leader>gb", function() Snacks.git.blame_line() end, { desc = "Git Blame Line" })
map("n", "<leader>gB", function() Snacks.gitbrowse() end, { desc = "Git Browse" })
map("n", "<leader>gf", function() Snacks.lazygit.log_file() end, { desc = "Lazygit Current File History" })
map("n", "<leader>gl", function() Snacks.lazygit.log({ cwd = LazyVim.root.git() }) end, { desc = "Lazygit Log" })
map("n", "<leader>gL", function() Snacks.lazygit.log() end, { desc = "Lazygit Log (cwd)" })
map("n", "<leader>gg", function() LazyVim.lazygit( { cwd = LazyVim.root.git() }) end, { desc = "Lazygit (Root Dir)" })
map("n", "<leader>gG", function() LazyVim.lazygit() end, { desc = "Lazygit (cwd)" })
map("n", "<leader>gb", LazyVim.lazygit.blame_line, { desc = "Git Blame Line" })
map("n", "<leader>gB", LazyVim.lazygit.browse, { desc = "Git Browse" })
map("n", "<leader>gf", function()
local git_path = vim.api.nvim_buf_get_name(0)
LazyVim.lazygit({args = { "-f", vim.trim(git_path) }, cwd = LazyVim.root.git()})
end, { desc = "Lazygit Current File History" })
map("n", "<leader>gl", function()
LazyVim.lazygit({ args = { "log" }, cwd = LazyVim.root.git() })
end, { desc = "Lazygit Log" })
map("n", "<leader>gL", function()
LazyVim.lazygit({ args = { "log" } })
end, { desc = "Lazygit Log (cwd)" })
-- quit
map("n", "<leader>qq", "<cmd>qa<cr>", { desc = "Quit All" })
@ -151,12 +158,18 @@ map("n", "<leader>uI", "<cmd>InspectTree<cr>", { desc = "Inspect Tree" })
map("n", "<leader>L", function() LazyVim.news.changelog() end, { desc = "LazyVim Changelog" })
-- floating terminal
map("n", "<leader>fT", function() Snacks.terminal() end, { desc = "Terminal (cwd)" })
map("n", "<leader>ft", function() Snacks.terminal(nil, { cwd = LazyVim.root() }) end, { desc = "Terminal (Root Dir)" })
map("n", "<c-/>", function() Snacks.terminal(nil, { cwd = LazyVim.root() }) end, { desc = "Terminal (Root Dir)" })
map("n", "<c-_>", function() Snacks.terminal(nil, { cwd = LazyVim.root() }) end, { desc = "which_key_ignore" })
local lazyterm = function() LazyVim.terminal(nil, { cwd = LazyVim.root() }) end
map("n", "<leader>ft", lazyterm, { desc = "Terminal (Root Dir)" })
map("n", "<leader>fT", function() LazyVim.terminal() end, { desc = "Terminal (cwd)" })
map("n", "<c-/>", lazyterm, { desc = "Terminal (Root Dir)" })
map("n", "<c-_>", lazyterm, { desc = "which_key_ignore" })
-- Terminal Mappings
map("t", "<esc><esc>", "<c-\\><c-n>", { desc = "Enter Normal Mode" })
map("t", "<C-h>", "<cmd>wincmd h<cr>", { desc = "Go to Left Window" })
map("t", "<C-j>", "<cmd>wincmd j<cr>", { desc = "Go to Lower Window" })
map("t", "<C-k>", "<cmd>wincmd k<cr>", { desc = "Go to Upper Window" })
map("t", "<C-l>", "<cmd>wincmd l<cr>", { desc = "Go to Right Window" })
map("t", "<C-/>", "<cmd>close<cr>", { desc = "Hide Terminal" })
map("t", "<c-_>", "<cmd>close<cr>", { desc = "which_key_ignore" })
@ -165,7 +178,7 @@ map("n", "<leader>w", "<c-w>", { desc = "Windows", remap = true })
map("n", "<leader>-", "<C-W>s", { desc = "Split Window Below", remap = true })
map("n", "<leader>|", "<C-W>v", { desc = "Split Window Right", remap = true })
map("n", "<leader>wd", "<C-W>c", { desc = "Delete Window", remap = true })
LazyVim.ui.maximize():map("<leader>wm")
LazyVim.toggle.map("<leader>wm", LazyVim.toggle.maximize)
-- tabs
map("n", "<leader><tab>l", "<cmd>tablast<cr>", { desc = "Last Tab" })

View File

@ -107,6 +107,7 @@ opt.spelloptions:append("noplainbuffer")
opt.splitbelow = true -- Put new windows below current
opt.splitkeep = "screen"
opt.splitright = true -- Put new windows right of current
opt.statuscolumn = [[%!v:lua.require'lazyvim.util'.ui.statuscolumn()]]
opt.tabstop = 2 -- Number of spaces tabs count for
opt.termguicolors = true -- True color support
opt.timeoutlen = vim.g.vscode and 1000 or 300 -- Lower than default (1000) to quickly trigger which-key

View File

@ -201,7 +201,6 @@ return {
library = {
{ path = "luvit-meta/library", words = { "vim%.uv" } },
{ path = "LazyVim", words = { "LazyVim" } },
{ path = "snacks.nvim", words = { "Snacks" } },
{ path = "lazy.nvim", words = { "LazyVim" } },
},
},

View File

@ -105,7 +105,7 @@ return {
},
config = function(_, opts)
local function on_move(data)
Snacks.rename.on_rename_file(data.source, data.destination)
LazyVim.lsp.on_rename(data.source, data.destination)
end
local events = require("neo-tree.events")

View File

@ -7,7 +7,6 @@ return {
"saghen/blink.cmp",
-- TODO: use release version
-- version = "*",
version = false,
opts_extend = { "sources.completion.enabled_providers" },
dependencies = {
"rafamadriz/friendly-snippets",
@ -37,7 +36,6 @@ return {
windows = {
autocomplete = {
draw = "reversed",
winblend = vim.o.pumblend,
},
documentation = {
auto_show = true,

View File

@ -109,9 +109,7 @@ return {
if cmp.is_in_snippet() then
return cmp.accept()
elseif require("copilot.suggestion").is_visible() then
LazyVim.create_undo()
require("copilot.suggestion").accept()
return true
else
return cmp.select_and_accept()
end

View File

@ -1,17 +1,11 @@
---@param config {type?:string, args?:string[]|fun():string[]?}
---@param config {args?:string[]|fun():string[]?}
local function get_args(config)
local args = type(config.args) == "function" and (config.args() or {}) or config.args or {} --[[@as string[] | string ]]
local args_str = type(args) == "table" and table.concat(args, " ") or args --[[@as string]]
local args = type(config.args) == "function" and (config.args() or {}) or config.args or {}
config = vim.deepcopy(config)
---@cast args string[]
config.args = function()
local new_args = vim.fn.expand(vim.fn.input("Run with args: ", args_str))
if config.type and config.type == "java" then
---@diagnostic disable-next-line: return-type-mismatch
return new_args
end
return vim.split(new_args, " ")
local new_args = vim.fn.input("Run with args: ", table.concat(args, " ")) --[[@as string]]
return vim.split(vim.fn.expand(new_args) --[[@as string]], " ")
end
return config
end

View File

@ -104,7 +104,7 @@ return {
vim.api.nvim_create_autocmd("User", {
pattern = "MiniFilesActionRename",
callback = function(event)
Snacks.rename.on_rename_file(event.data.from, event.data.to)
LazyVim.lsp.on_rename(event.data.from, event.data.to)
end,
})
end,

View File

@ -108,7 +108,7 @@ return {
ft = { "markdown", "norg", "rmd", "org" },
config = function(_, opts)
require("render-markdown").setup(opts)
Snacks.toggle({
LazyVim.toggle.map("<leader>um", {
name = "Render Markdown",
get = function()
return require("render-markdown.state").enabled
@ -121,7 +121,7 @@ return {
m.disable()
end
end,
}):map("<leader>um")
})
end,
},
}

View File

@ -6,23 +6,26 @@ return {
})
end,
-- LSP for Cargo.toml
-- Extend auto completion
{
"Saecki/crates.nvim",
event = { "BufRead Cargo.toml" },
opts = {
completion = {
crates = {
enabled = true,
"hrsh7th/nvim-cmp",
optional = true,
dependencies = {
{
"Saecki/crates.nvim",
event = { "BufRead Cargo.toml" },
opts = {
completion = {
cmp = { enabled = true },
},
},
},
lsp = {
enabled = true,
actions = true,
completion = true,
hover = true,
},
},
---@param opts cmp.ConfigSchema
opts = function(_, opts)
opts.sources = opts.sources or {}
table.insert(opts.sources, { name = "crates" })
end,
},
-- Add Rust & related to treesitter
@ -93,6 +96,21 @@ return {
opts = {
servers = {
rust_analyzer = { enabled = false },
taplo = {
keys = {
{
"K",
function()
if vim.fn.expand("%:t") == "Cargo.toml" and require("crates").popup_available() then
require("crates").show_popup()
else
vim.lsp.buf.hover()
end
end,
desc = "Show Crate Documentation",
},
},
},
},
},
},

View File

@ -31,6 +31,14 @@ return {
return vim.api.nvim_win_get_config(win).relative == ""
end,
},
{
ft = "lazyterm",
title = "LazyTerm",
size = { height = 0.4 },
filter = function(buf)
return not vim.b[buf].lazyterm_cmd
end,
},
"Trouble",
{ ft = "qf", title = "QuickFix" },
{
@ -95,7 +103,6 @@ return {
end
end
-- trouble
for _, pos in ipairs({ "top", "bottom", "left", "right" }) do
opts[pos] = opts[pos] or {}
table.insert(opts[pos], {
@ -109,22 +116,6 @@ return {
end,
})
end
-- snacks terminal
for _, pos in ipairs({ "top", "bottom", "left", "right" }) do
opts[pos] = opts[pos] or {}
table.insert(opts[pos], {
ft = "snacks_terminal",
size = { height = 0.4 },
title = "%{b:snacks_terminal.id}: %{b:term_title}",
filter = function(_buf, win)
return vim.w[win].snacks_win
and vim.w[win].snacks_win.position == pos
and vim.w[win].snacks_win.relative == "editor"
and not vim.w[win].trouble_preview
end,
})
end
return opts
end,
},

View File

@ -21,7 +21,7 @@ return {
end,
})
Snacks.toggle({
LazyVim.toggle.map("<leader>ua", {
name = "Mini Animate",
get = function()
return not vim.g.minianimate_disable
@ -29,7 +29,7 @@ return {
set = function(state)
vim.g.minianimate_disable = not state
end,
}):map("<leader>ua")
})
local animate = require("mini.animate")
return {

View File

@ -14,19 +14,17 @@ return {
init = function()
vim.api.nvim_create_autocmd("FileType", {
pattern = {
"Trouble",
"alpha",
"dashboard",
"fzf",
"help",
"lazy",
"lazyterm",
"mason",
"neo-tree",
"notify",
"snacks_notif",
"snacks_terminal",
"snacks_win",
"toggleterm",
"Trouble",
"trouble",
},
callback = function()

View File

@ -4,7 +4,8 @@ return {
event = "VeryLazy",
opts = function()
local tsc = require("treesitter-context")
Snacks.toggle({
LazyVim.toggle.map("<leader>ut", {
name = "Treesitter Context",
get = tsc.enabled,
set = function(state)
@ -14,7 +15,8 @@ return {
tsc.disable()
end
end,
}):map("<leader>ut")
})
return { mode = "cursor", max_lines = 3 }
end,
}

View File

@ -8,14 +8,14 @@ return {
{
"<leader>gG",
function()
Snacks.terminal({ "gitui" })
LazyVim.terminal.open({ "gitui" }, { esc_esc = false, ctrl_hjkl = false })
end,
desc = "GitUi (cwd)",
},
{
"<leader>gg",
function()
Snacks.terminal({ "gitui" }, { cwd = LazyVim.root.get() })
LazyVim.terminal.open({ "gitui" }, { cwd = LazyVim.root.get(), esc_esc = false, ctrl_hjkl = false })
end,
desc = "GitUi (Root Dir)",
},

View File

@ -10,48 +10,7 @@ end
require("lazyvim.config").init()
-- Terminal Mappings
local function term_nav(dir)
---@param self snacks.terminal
return function(self)
return self:is_floating() and "<c-" .. dir .. ">" or vim.schedule(function()
vim.cmd.wincmd(dir)
end)
end
end
return {
{ "folke/lazy.nvim", version = "*" },
{ "LazyVim/LazyVim", priority = 10000, lazy = false, opts = {}, cond = true, version = "*" },
{
"folke/snacks.nvim",
priority = 1000,
lazy = false,
opts = function()
---@type snacks.Config
return {
toggle = { map = LazyVim.safe_keymap_set },
notifier = { enabled = not LazyVim.has("noice.nvim") },
terminal = {
win = {
keys = {
nav_h = { "<C-h>", term_nav("h"), desc = "Go to Left Window", expr = true, mode = "t" },
nav_j = { "<C-j>", term_nav("j"), desc = "Go to Lower Window", expr = true, mode = "t" },
nav_k = { "<C-k>", term_nav("k"), desc = "Go to Upper Window", expr = true, mode = "t" },
nav_l = { "<C-l>", term_nav("l"), desc = "Go to Right Window", expr = true, mode = "t" },
},
},
},
}
end,
keys = {
{
"<leader>un",
function()
Snacks.notifier.hide()
end,
desc = "Dismiss All Notifications",
},
},
},
}

View File

@ -129,6 +129,8 @@ return {
LazyVim.lsp.setup()
LazyVim.lsp.on_dynamic_capability(require("lazyvim.plugins.lsp.keymaps").on_attach)
LazyVim.lsp.words.setup(opts.document_highlight)
-- diagnostics signs
if vim.fn.has("nvim-0.10.0") == 0 then
if type(opts.diagnostics.signs) ~= "boolean" then

View File

@ -25,17 +25,17 @@ function M.get()
{ "<leader>ca", vim.lsp.buf.code_action, desc = "Code Action", mode = { "n", "v" }, has = "codeAction" },
{ "<leader>cc", vim.lsp.codelens.run, desc = "Run Codelens", mode = { "n", "v" }, has = "codeLens" },
{ "<leader>cC", vim.lsp.codelens.refresh, desc = "Refresh & Display Codelens", mode = { "n" }, has = "codeLens" },
{ "<leader>cR", function() Snacks.rename.rename_file() end, desc = "Rename File", mode ={"n"}, has = { "workspace/didRenameFiles", "workspace/willRenameFiles" } },
{ "<leader>cR", LazyVim.lsp.rename_file, desc = "Rename File", mode ={"n"}, has = { "workspace/didRenameFiles", "workspace/willRenameFiles" } },
{ "<leader>cr", vim.lsp.buf.rename, desc = "Rename", has = "rename" },
{ "<leader>cA", LazyVim.lsp.action.source, desc = "Source Action", has = "codeAction" },
{ "]]", function() Snacks.words.jump(vim.v.count1) end, has = "documentHighlight",
desc = "Next Reference", cond = function() return Snacks.words.is_enabled() end },
{ "[[", function() Snacks.words.jump(-vim.v.count1) end, has = "documentHighlight",
desc = "Prev Reference", cond = function() return Snacks.words.is_enabled() end },
{ "<a-n>", function() Snacks.words.jump(vim.v.count1, true) end, has = "documentHighlight",
desc = "Next Reference", cond = function() return Snacks.words.is_enabled() end },
{ "<a-p>", function() Snacks.words.jump(-vim.v.count1, true) end, has = "documentHighlight",
desc = "Prev Reference", cond = function() return Snacks.words.is_enabled() end },
{ "]]", function() LazyVim.lsp.words.jump(vim.v.count1) end, has = "documentHighlight",
desc = "Next Reference", cond = function() return LazyVim.lsp.words.enabled end },
{ "[[", function() LazyVim.lsp.words.jump(-vim.v.count1) end, has = "documentHighlight",
desc = "Prev Reference", cond = function() return LazyVim.lsp.words.enabled end },
{ "<a-n>", function() LazyVim.lsp.words.jump(vim.v.count1, true) end, has = "documentHighlight",
desc = "Next Reference", cond = function() return LazyVim.lsp.words.enabled end },
{ "<a-p>", function() LazyVim.lsp.words.jump(-vim.v.count1, true) end, has = "documentHighlight",
desc = "Prev Reference", cond = function() return LazyVim.lsp.words.enabled end },
}
return M._keys

View File

@ -1,4 +1,39 @@
return {
-- Better `vim.notify()`
{
"rcarriga/nvim-notify",
keys = {
{
"<leader>un",
function()
require("notify").dismiss({ silent = true, pending = true })
end,
desc = "Dismiss All Notifications",
},
},
opts = {
stages = "static",
timeout = 3000,
max_height = function()
return math.floor(vim.o.lines * 0.75)
end,
max_width = function()
return math.floor(vim.o.columns * 0.75)
end,
on_open = function(win)
vim.api.nvim_win_set_config(win, { zindex = 100 })
end,
},
init = function()
-- when noice is not enabled, install notify on VeryLazy
if not LazyVim.has("noice.nvim") then
LazyVim.on_very_lazy(function()
vim.notify = require("notify")
end)
end
end,
},
-- This is what powers LazyVim's fancy-looking
-- tabs, which include filetype icons and close buttons.
{
@ -20,9 +55,9 @@ return {
opts = {
options = {
-- stylua: ignore
close_command = function(n) Snacks.bufdelete(n) end,
close_command = function(n) LazyVim.ui.bufremove(n) end,
-- stylua: ignore
right_mouse_command = function(n) Snacks.bufdelete(n) end,
right_mouse_command = function(n) LazyVim.ui.bufremove(n) end,
diagnostics = "nvim_lsp",
always_show_bufferline = false,
diagnostics_indicator = function(_, _, diag)
@ -191,7 +226,7 @@ return {
"lukas-reineke/indent-blankline.nvim",
event = "LazyFile",
opts = function()
Snacks.toggle({
LazyVim.toggle.map("<leader>ug", {
name = "Indention Guides",
get = function()
return require("ibl.config").get_config(0).enabled
@ -199,7 +234,7 @@ return {
set = function(state)
require("ibl").setup_buffer(0, { enabled = state })
end,
}):map("<leader>ug")
})
return {
indent = {
@ -209,19 +244,17 @@ return {
scope = { show_start = false, show_end = false },
exclude = {
filetypes = {
"Trouble",
"help",
"alpha",
"dashboard",
"help",
"neo-tree",
"Trouble",
"trouble",
"lazy",
"mason",
"neo-tree",
"notify",
"snacks_notif",
"snacks_terminal",
"snacks_win",
"toggleterm",
"trouble",
"lazyterm",
},
},
}

View File

@ -1,59 +0,0 @@
local M = {}
M.moved = {
lsp = {
rename_file = { "Snacks.rename.rename_file" },
on_rename = { "Snacks.rename.on_rename_file" },
words = { "Snacks.words" },
},
terminal = {
open = { "Snacks.terminal" },
__call = { "Snacks.terminal" },
},
ui = {
statuscolumn = { "Snacks.statuscolumn" },
bufremove = { "Snacks.bufdelete" },
},
}
---@param name string
---@param mod table
function M.decorate(name, mod)
if not M.moved[name] then
return mod
end
setmetatable(mod, {
__call = function(_, ...)
local to = M.moved[name].__call[1]
LazyVim.deprecate("LazyVim." .. name, to)
local ret = vim.tbl_get(_G, unpack(vim.split(to, ".", { plain = true })))
return ret(...)
end,
__index = function(_, k)
if M.moved[name][k] then
local to = M.moved[name][k][1]
LazyVim.deprecate("LazyVim." .. name .. "." .. k, to)
local ret = vim.tbl_get(_G, unpack(vim.split(to, ".", { plain = true })))
return ret
end
return nil
end,
})
end
function M.lazygit()
LazyVim.deprecate("LazyVim.lazygit", "Snacks.lazygit")
return Snacks.lazygit
end
function M.toggle()
LazyVim.deprecate("LazyVim.toggle", "Snacks.toggle")
return {
map = function() end,
wrap = function()
return {}
end,
}
end
return M

View File

@ -177,20 +177,4 @@ function M.setup()
end, { desc = "Show info about the formatters for the current buffer" })
end
---@param buf? boolean
function M.snacks_toggle(buf)
return Snacks.toggle({
name = "Auto Format (" .. (buf and "Buffer" or "Global") .. ")",
get = function()
if not buf then
return vim.g.autoformat == nil or vim.g.autoformat
end
return LazyVim.format.enabled()
end,
set = function(state)
LazyVim.format.enable(state, buf)
end,
})
end
return M

View File

@ -6,6 +6,8 @@ local LazyUtil = require("lazy.core.util")
---@field lsp lazyvim.util.lsp
---@field root lazyvim.util.root
---@field terminal lazyvim.util.terminal
---@field lazygit lazyvim.util.lazygit
---@field toggle lazyvim.util.toggle
---@field format lazyvim.util.format
---@field plugin lazyvim.util.plugin
---@field extras lazyvim.util.extras
@ -18,17 +20,36 @@ local LazyUtil = require("lazy.core.util")
---@field cmp lazyvim.util.cmp
local M = {}
---@type table<string, string|string[]>
local deprecated = {
get_clients = "lsp",
on_attach = "lsp",
on_rename = "lsp",
root_patterns = { "root", "patterns" },
get_root = { "root", "get" },
float_term = { "terminal", "open" },
toggle_diagnostics = { "toggle", "diagnostics" },
toggle_number = { "toggle", "number" },
fg = "ui",
telescope = "pick",
}
setmetatable(M, {
__index = function(t, k)
if LazyUtil[k] then
return LazyUtil[k]
end
if k == "lazygit" or k == "toggle" then -- HACK: special case for lazygit
return M.deprecated[k]()
local dep = deprecated[k]
if dep then
local mod = type(dep) == "table" and dep[1] or dep
local key = type(dep) == "table" and dep[2] or k
M.deprecate([[LazyVim.]] .. k, [[LazyVim.]] .. mod .. "." .. key)
---@diagnostic disable-next-line: no-unknown
t[mod] = require("lazyvim.util." .. mod) -- load here to prevent loops
return t[mod][key]
end
---@diagnostic disable-next-line: no-unknown
t[k] = require("lazyvim.util." .. k)
M.deprecated.decorate(k, t[k])
return t[k]
end,
})

View File

@ -0,0 +1,231 @@
---@class lazyvim.util.lazygit
---@field config_dir? string
---@overload fun(cmd: string|string[], opts: LazyTermOpts): LazyFloat
local M = setmetatable({}, {
__call = function(m, ...)
return m.open(...)
end,
})
---@alias LazyGitColor {fg?:string, bg?:string, bold?:boolean}
---@class LazyGitTheme: table<number, LazyGitColor>
---@field activeBorderColor LazyGitColor
---@field cherryPickedCommitBgColor LazyGitColor
---@field cherryPickedCommitFgColor LazyGitColor
---@field defaultFgColor LazyGitColor
---@field inactiveBorderColor LazyGitColor
---@field optionsTextColor LazyGitColor
---@field searchingActiveBorderColor LazyGitColor
---@field selectedLineBgColor LazyGitColor
---@field unstagedChangesColor LazyGitColor
M.theme = {
[241] = { fg = "Special" },
activeBorderColor = { fg = "MatchParen", bold = true },
cherryPickedCommitBgColor = { fg = "Identifier" },
cherryPickedCommitFgColor = { fg = "Function" },
defaultFgColor = { fg = "Normal" },
inactiveBorderColor = { fg = "FloatBorder" },
optionsTextColor = { fg = "Function" },
searchingActiveBorderColor = { fg = "MatchParen", bold = true },
selectedLineBgColor = { bg = "Visual" }, -- set to `default` to have no background colour
unstagedChangesColor = { fg = "DiagnosticError" },
}
M.theme_path = LazyVim.norm(vim.fn.stdpath("cache") .. "/lazygit-theme.yml")
-- re-create config file on startup
M.dirty = true
-- re-create theme file on ColorScheme change
vim.api.nvim_create_autocmd("ColorScheme", {
callback = function()
M.dirty = true
end,
})
-- Opens lazygit
---@param opts? LazyTermOpts | {args?: string[]}
function M.open(opts)
if vim.g.lazygit_theme ~= nil then
LazyVim.deprecate("vim.g.lazygit_theme", "vim.g.lazygit_config")
end
opts = vim.tbl_deep_extend("force", {}, {
esc_esc = false,
ctrl_hjkl = false,
}, opts or {})
local cmd = { "lazygit" }
vim.list_extend(cmd, opts.args or {})
if vim.g.lazygit_config then
if M.dirty then
M.update_config()
end
if not M.config_dir then
local Process = require("lazy.manage.process")
local ok, lines = pcall(Process.exec, { "lazygit", "-cd" })
if ok then
M.config_dir = lines[1]
vim.env.LG_CONFIG_FILE = LazyVim.norm(M.config_dir .. "/config.yml" .. "," .. M.theme_path)
local custom_config = LazyVim.norm(M.config_dir .. "/custom.yml")
if vim.uv.fs_stat(custom_config) and vim.uv.fs_stat(custom_config).type == "file" then
vim.env.LG_CONFIG_FILE = vim.env.LG_CONFIG_FILE .. "," .. custom_config
end
else
---@diagnostic disable-next-line: cast-type-mismatch
---@cast lines string
LazyVim.error(
{ "Failed to get **lazygit** config directory.", "Will not apply **lazygit** config.", "", "# Error:", lines },
{ title = "lazygit" }
)
end
end
end
return LazyVim.terminal(cmd, opts)
end
function M.set_ansi_color(idx, color)
io.write(("\27]4;%d;%s\7"):format(idx, color))
end
---@param v LazyGitColor
---@return string[]
function M.get_color(v)
---@type string[]
local color = {}
if v.fg then
color[1] = LazyVim.ui.color(v.fg)
elseif v.bg then
color[1] = LazyVim.ui.color(v.bg, true)
end
if v.bold then
table.insert(color, "bold")
end
return color
end
function M.update_config()
---@type table<string, string[]>
local theme = {}
for k, v in pairs(M.theme) do
if type(k) == "number" then
local color = M.get_color(v)
-- LazyGit uses color 241 a lot, so also set it to a nice color
-- pcall, since some terminals don't like this
pcall(M.set_ansi_color, k, color[1])
else
theme[k] = M.get_color(v)
end
end
local config = [[
os:
editPreset: "nvim-remote"
gui:
nerdFontsVersion: 3
theme:
]]
---@type string[]
local lines = {}
for k, v in pairs(theme) do
lines[#lines + 1] = (" %s:"):format(k)
for _, c in ipairs(v) do
lines[#lines + 1] = (" - %q"):format(c)
end
end
config = config .. table.concat(lines, "\n")
require("lazy.util").write_file(M.theme_path, config)
M.dirty = false
end
---@param opts? {count?: number}|LazyCmdOptions
function M.blame_line(opts)
opts = vim.tbl_deep_extend("force", {
count = 3,
filetype = "git",
size = {
width = 0.6,
height = 0.6,
},
border = "rounded",
}, opts or {})
local cursor = vim.api.nvim_win_get_cursor(0)
local line = cursor[1]
local file = vim.api.nvim_buf_get_name(0)
local root = LazyVim.root.detectors.pattern(0, { ".git" })[1] or "."
local cmd = { "git", "-C", root, "log", "-n", opts.count, "-u", "-L", line .. ",+1:" .. file }
return require("lazy.util").float_cmd(cmd, opts)
end
-- stylua: ignore
M.remote_patterns = {
{ "^(https?://.*)%.git$" , "%1" },
{ "^git@(.+):(.+)%.git$" , "https://%1/%2" },
{ "^git@(.+):(.+)$" , "https://%1/%2" },
{ "^git@(.+)/(.+)$" , "https://%1/%2" },
{ "^ssh://git@(.*)$" , "https://%1" },
{ "ssh%.dev%.azure%.com/v3/(.*)/(.*)$", "dev.azure.com/%1/_git/%2" },
{ "^https://%w*@(.*)" , "https://%1" },
{ "^git@(.*)" , "https://%1" },
{ ":%d+" , "" },
{ "%.git$" , "" },
}
---@param remote string
function M.get_url(remote)
local ret = remote
for _, pattern in ipairs(M.remote_patterns) do
ret = ret:gsub(pattern[1], pattern[2])
end
return ret:find("https://") == 1 and ret or ("https://%s"):format(ret)
end
function M.browse()
local lines = require("lazy.manage.process").exec({ "git", "remote", "-v" })
local remotes = {} ---@type {name:string, url:string}[]
for _, line in ipairs(lines) do
local name, remote = line:match("(%S+)%s+(%S+)%s+%(fetch%)")
if name and remote then
local url = M.get_url(remote)
if url then
table.insert(remotes, {
name = name,
url = url,
})
end
end
end
local function open(remote)
if remote then
LazyVim.info(("Opening [%s](%s)"):format(remote.name, remote.url))
if vim.fn.has("nvim-0.10") == 0 then
require("lazy.util").open(remote.url, { system = true })
return
end
vim.ui.open(remote.url)
end
end
if #remotes == 0 then
return LazyVim.error("No git remotes found")
elseif #remotes == 1 then
return open(remotes[1])
end
vim.ui.select(remotes, {
prompt = "Select remote to browse",
format_item = function(item)
return item.name .. (" "):rep(8 - #item.name) .. " 🔗 " .. item.url
end,
}, open)
end
return M

View File

@ -118,6 +118,63 @@ function M.on_supports_method(method, fn)
})
end
function M.rename_file()
local buf = vim.api.nvim_get_current_buf()
local old = assert(LazyVim.root.realpath(vim.api.nvim_buf_get_name(buf)))
local root = assert(LazyVim.root.realpath(LazyVim.root.get({ normalize = true })))
assert(old:find(root, 1, true) == 1, "File not in project root")
local extra = old:sub(#root + 2)
vim.ui.input({
prompt = "New File Name: ",
default = extra,
completion = "file",
}, function(new)
if not new or new == "" or new == extra then
return
end
new = LazyVim.norm(root .. "/" .. new)
vim.fn.mkdir(vim.fs.dirname(new), "p")
M.on_rename(old, new, function()
vim.fn.rename(old, new)
vim.cmd.edit(new)
vim.api.nvim_buf_delete(buf, { force = true })
vim.fn.delete(old)
end)
end)
end
---@param from string
---@param to string
---@param rename? fun()
function M.on_rename(from, to, rename)
local changes = { files = { {
oldUri = vim.uri_from_fname(from),
newUri = vim.uri_from_fname(to),
} } }
local clients = M.get_clients()
for _, client in ipairs(clients) do
if client.supports_method("workspace/willRenameFiles") then
local resp = client.request_sync("workspace/willRenameFiles", changes, 1000, 0)
if resp and resp.result ~= nil then
vim.lsp.util.apply_workspace_edit(resp.result, client.offset_encoding)
end
end
end
if rename then
rename()
end
for _, client in ipairs(clients) do
if client.supports_method("workspace/didRenameFiles") then
client.notify("workspace/didRenameFiles", changes)
end
end
end
---@return _.lspconfig.options
function M.get_config(server)
local configs = require("lspconfig.configs")
@ -203,6 +260,82 @@ function M.format(opts)
end
end
---@alias LspWord {from:{[1]:number, [2]:number}, to:{[1]:number, [2]:number}} 1-0 indexed
M.words = {}
M.words.enabled = false
M.words.ns = vim.api.nvim_create_namespace("vim_lsp_references")
---@param opts? {enabled?: boolean}
function M.words.setup(opts)
opts = opts or {}
if not opts.enabled then
return
end
M.words.enabled = true
local handler = vim.lsp.handlers["textDocument/documentHighlight"]
vim.lsp.handlers["textDocument/documentHighlight"] = function(err, result, ctx, config)
if not vim.api.nvim_buf_is_loaded(ctx.bufnr) then
return
end
vim.lsp.buf.clear_references()
return handler(err, result, ctx, config)
end
M.on_supports_method("textDocument/documentHighlight", function(_, buf)
vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI", "CursorMoved", "CursorMovedI" }, {
group = vim.api.nvim_create_augroup("lsp_word_" .. buf, { clear = true }),
buffer = buf,
callback = function(ev)
if not require("lazyvim.plugins.lsp.keymaps").has(buf, "documentHighlight") then
return false
end
if not ({ M.words.get() })[2] then
if ev.event:find("CursorMoved") then
vim.lsp.buf.clear_references()
elseif not LazyVim.cmp.visible() then
vim.lsp.buf.document_highlight()
end
end
end,
})
end)
end
---@return LspWord[] words, number? current
function M.words.get()
local cursor = vim.api.nvim_win_get_cursor(0)
local current, ret = nil, {} ---@type number?, LspWord[]
for _, extmark in ipairs(vim.api.nvim_buf_get_extmarks(0, M.words.ns, 0, -1, { details = true })) do
local w = {
from = { extmark[2] + 1, extmark[3] },
to = { extmark[4].end_row + 1, extmark[4].end_col },
}
ret[#ret + 1] = w
if cursor[1] >= w.from[1] and cursor[1] <= w.to[1] and cursor[2] >= w.from[2] and cursor[2] <= w.to[2] then
current = #ret
end
end
return ret, current
end
---@param count number
---@param cycle? boolean
function M.words.jump(count, cycle)
local words, idx = M.words.get()
if not idx then
return
end
idx = idx + count
if cycle then
idx = (idx - 1) % #words + 1
end
local target = words[idx]
if target then
vim.api.nvim_win_set_cursor(0, target.from)
end
end
M.action = setmetatable({}, {
__index = function(_, action)
return function()

Some files were not shown because too many files have changed in this diff Show More