mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-07-14 19:34:36 +02:00
Merge branch 'main' into main
This commit is contained in:
commit
1a34fc6c3a
63 changed files with 1832 additions and 625 deletions
|
@ -66,7 +66,6 @@ vim.api.nvim_create_autocmd("FileType", {
|
|||
"neotest-summary",
|
||||
"notify",
|
||||
"qf",
|
||||
"snacks_win",
|
||||
"spectre_panel",
|
||||
"startuptime",
|
||||
"tsplayground",
|
||||
|
|
|
@ -3,7 +3,7 @@ _G.LazyVim = require("lazyvim.util")
|
|||
---@class LazyVimConfig: LazyVimOptions
|
||||
local M = {}
|
||||
|
||||
M.version = "13.5.3" -- x-release-please-version
|
||||
M.version = "14.8.0" -- x-release-please-version
|
||||
LazyVim.config = M
|
||||
|
||||
---@class LazyVimOptions
|
||||
|
@ -85,7 +85,7 @@ local defaults = {
|
|||
Package = " ",
|
||||
Property = " ",
|
||||
Reference = " ",
|
||||
Snippet = " ",
|
||||
Snippet = " ",
|
||||
String = " ",
|
||||
Struct = " ",
|
||||
Supermaven = " ",
|
||||
|
|
|
@ -45,8 +45,12 @@ map("n", "<leader>bo", function()
|
|||
end, { desc = "Delete Other Buffers" })
|
||||
map("n", "<leader>bD", "<cmd>:bd<cr>", { desc = "Delete Buffer and Window" })
|
||||
|
||||
-- Clear search with <esc>
|
||||
map({ "i", "n" }, "<esc>", "<cmd>noh<cr><esc>", { desc = "Escape and Clear hlsearch" })
|
||||
-- Clear search and stop snippet on escape
|
||||
map({ "i", "n", "s" }, "<esc>", function()
|
||||
vim.cmd("noh")
|
||||
LazyVim.cmp.actions.snippet_stop()
|
||||
return "<esc>"
|
||||
end, { expr = true, desc = "Escape and Clear hlsearch" })
|
||||
|
||||
-- Clear search, diff update and redraw
|
||||
-- taken from runtime/lua/_editor.lua
|
||||
|
@ -122,14 +126,22 @@ map("n", "[w", diagnostic_goto(false, "WARN"), { desc = "Prev Warning" })
|
|||
-- 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.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.option("conceallevel", { off = 0, on = vim.o.conceallevel > 0 and vim.o.conceallevel or 2, name = "Conceal Level" }):map("<leader>uc")
|
||||
Snacks.toggle.option("showtabline", { off = 0, on = vim.o.showtabline > 0 and vim.o.showtabline or 2, name = "Tabline" }):map("<leader>uA")
|
||||
Snacks.toggle.treesitter():map("<leader>uT")
|
||||
Snacks.toggle.option("background", { off = "light", on = "dark" , name = "Dark Background"}):map("<leader>ub")
|
||||
Snacks.toggle.option("background", { off = "light", on = "dark" , name = "Dark Background" }):map("<leader>ub")
|
||||
Snacks.toggle.dim():map("<leader>uD")
|
||||
Snacks.toggle.animate():map("<leader>ua")
|
||||
Snacks.toggle.indent():map("<leader>ug")
|
||||
Snacks.toggle.scroll():map("<leader>uS")
|
||||
Snacks.toggle.profiler():map("<leader>dpp")
|
||||
Snacks.toggle.profiler_highlights():map("<leader>dph")
|
||||
|
||||
if vim.lsp.inlay_hint then
|
||||
Snacks.toggle.inlay_hints():map("<leader>uh")
|
||||
end
|
||||
|
@ -138,15 +150,15 @@ end
|
|||
if vim.fn.executable("lazygit") == 1 then
|
||||
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>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>gf", function() Snacks.picker.git_log_file() end, { desc = "Git Current File History" })
|
||||
map("n", "<leader>gl", function() Snacks.picker.git_log({ cwd = LazyVim.root.git() }) end, { desc = "Git Log" })
|
||||
map("n", "<leader>gL", function() Snacks.picker.git_log() end, { desc = "Git Log (cwd)" })
|
||||
end
|
||||
|
||||
map("n", "<leader>gb", function() Snacks.git.blame_line() end, { desc = "Git Blame Line" })
|
||||
map("n", "<leader>gb", function() Snacks.picker.git_log_line() end, { desc = "Git Blame Line" })
|
||||
map({ "n", "x" }, "<leader>gB", function() Snacks.gitbrowse() end, { desc = "Git Browse (open)" })
|
||||
map({"n", "x" }, "<leader>gY", function()
|
||||
Snacks.gitbrowse({ open = function(url) vim.fn.setreg("+", url) end })
|
||||
Snacks.gitbrowse({ open = function(url) vim.fn.setreg("+", url) end, notify = false })
|
||||
end, { desc = "Git Browse (copy)" })
|
||||
|
||||
-- quit
|
||||
|
@ -174,7 +186,8 @@ 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")
|
||||
Snacks.toggle.zoom():map("<leader>wm"):map("<leader>uZ")
|
||||
Snacks.toggle.zen():map("<leader>uz")
|
||||
|
||||
-- tabs
|
||||
map("n", "<leader><tab>l", "<cmd>tablast<cr>", { desc = "Last Tab" })
|
||||
|
|
|
@ -5,12 +5,22 @@ vim.g.maplocalleader = "\\"
|
|||
-- LazyVim auto format
|
||||
vim.g.autoformat = true
|
||||
|
||||
-- Snacks animations
|
||||
-- Set to `false` to globally disable all snacks animations
|
||||
vim.g.snacks_animate = true
|
||||
|
||||
-- LazyVim picker to use.
|
||||
-- Can be one of: telescope, fzf
|
||||
-- Leave it to "auto" to automatically use the picker
|
||||
-- enabled with `:LazyExtras`
|
||||
vim.g.lazyvim_picker = "auto"
|
||||
|
||||
-- LazyVim completion engine to use.
|
||||
-- Can be one of: nvim-cmp, blink.cmp
|
||||
-- Leave it to "auto" to automatically use the completion engine
|
||||
-- enabled with `:LazyExtras`
|
||||
vim.g.lazyvim_cmp = "auto"
|
||||
|
||||
-- if the completion engine supports the AI source,
|
||||
-- use that instead of inline suggestions
|
||||
vim.g.ai_cmp = true
|
||||
|
|
|
@ -17,7 +17,7 @@ function M.check()
|
|||
error("Neovim >= 0.9.0 is required")
|
||||
end
|
||||
|
||||
for _, cmd in ipairs({ "git", "rg", { "fd", "fdfind" }, "lazygit" }) do
|
||||
for _, cmd in ipairs({ "git", "rg", { "fd", "fdfind" }, "lazygit", "fzf", "curl" }) do
|
||||
local name = type(cmd) == "string" and cmd or vim.inspect(cmd)
|
||||
local commands = type(cmd) == "string" and { cmd } or cmd
|
||||
---@cast commands string[]
|
||||
|
|
|
@ -1,113 +1,14 @@
|
|||
return {
|
||||
|
||||
-- auto completion
|
||||
{
|
||||
"hrsh7th/nvim-cmp",
|
||||
version = false, -- last release is way too old
|
||||
event = "InsertEnter",
|
||||
dependencies = {
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
"hrsh7th/cmp-buffer",
|
||||
"hrsh7th/cmp-path",
|
||||
},
|
||||
-- Not all LSP servers add brackets when completing a function.
|
||||
-- To better deal with this, LazyVim adds a custom option to cmp,
|
||||
-- that you can configure. For example:
|
||||
--
|
||||
-- ```lua
|
||||
-- opts = {
|
||||
-- auto_brackets = { "python" }
|
||||
-- }
|
||||
-- ```
|
||||
opts = function()
|
||||
vim.api.nvim_set_hl(0, "CmpGhostText", { link = "Comment", default = true })
|
||||
local cmp = require("cmp")
|
||||
local defaults = require("cmp.config.default")()
|
||||
local auto_select = true
|
||||
return {
|
||||
auto_brackets = {}, -- configure any filetype to auto add brackets
|
||||
completion = {
|
||||
completeopt = "menu,menuone,noinsert" .. (auto_select and "" or ",noselect"),
|
||||
},
|
||||
preselect = auto_select and cmp.PreselectMode.Item or cmp.PreselectMode.None,
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
["<C-b>"] = cmp.mapping.scroll_docs(-4),
|
||||
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
||||
["<C-n>"] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }),
|
||||
["<C-p>"] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }),
|
||||
["<C-Space>"] = cmp.mapping.complete(),
|
||||
["<CR>"] = LazyVim.cmp.confirm({ select = auto_select }),
|
||||
["<C-y>"] = LazyVim.cmp.confirm({ select = true }),
|
||||
["<S-CR>"] = LazyVim.cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
||||
["<C-CR>"] = function(fallback)
|
||||
cmp.abort()
|
||||
fallback()
|
||||
end,
|
||||
["<tab>"] = function(fallback)
|
||||
return LazyVim.cmp.map({ "snippet_forward", "ai_accept" }, fallback)()
|
||||
end,
|
||||
}),
|
||||
sources = cmp.config.sources({
|
||||
{ name = "nvim_lsp" },
|
||||
{ name = "path" },
|
||||
}, {
|
||||
{ name = "buffer" },
|
||||
}),
|
||||
formatting = {
|
||||
format = function(entry, item)
|
||||
local icons = LazyVim.config.icons.kinds
|
||||
if icons[item.kind] then
|
||||
item.kind = icons[item.kind] .. item.kind
|
||||
end
|
||||
|
||||
local widths = {
|
||||
abbr = vim.g.cmp_widths and vim.g.cmp_widths.abbr or 40,
|
||||
menu = vim.g.cmp_widths and vim.g.cmp_widths.menu or 30,
|
||||
}
|
||||
|
||||
for key, width in pairs(widths) do
|
||||
if item[key] and vim.fn.strdisplaywidth(item[key]) > width then
|
||||
item[key] = vim.fn.strcharpart(item[key], 0, width - 1) .. "…"
|
||||
end
|
||||
end
|
||||
|
||||
return item
|
||||
end,
|
||||
},
|
||||
experimental = {
|
||||
-- only show ghost text when we show ai completions
|
||||
ghost_text = vim.g.ai_cmp and {
|
||||
hl_group = "CmpGhostText",
|
||||
} or false,
|
||||
},
|
||||
sorting = defaults.sorting,
|
||||
}
|
||||
import = "lazyvim.plugins.extras.coding.nvim-cmp",
|
||||
enabled = function()
|
||||
return LazyVim.cmp_engine() == "nvim-cmp"
|
||||
end,
|
||||
main = "lazyvim.util.cmp",
|
||||
},
|
||||
|
||||
-- snippets
|
||||
{
|
||||
"nvim-cmp",
|
||||
optional = true,
|
||||
dependencies = {
|
||||
{
|
||||
"garymjr/nvim-snippets",
|
||||
opts = {
|
||||
friendly_snippets = true,
|
||||
},
|
||||
dependencies = { "rafamadriz/friendly-snippets" },
|
||||
},
|
||||
},
|
||||
opts = function(_, opts)
|
||||
opts.snippet = {
|
||||
expand = function(item)
|
||||
return LazyVim.cmp.expand(item.body)
|
||||
end,
|
||||
}
|
||||
if LazyVim.has("nvim-snippets") then
|
||||
table.insert(opts.sources, { name = "snippets" })
|
||||
end
|
||||
import = "lazyvim.plugins.extras.coding.blink",
|
||||
enabled = function()
|
||||
return LazyVim.cmp_engine() == "blink.cmp"
|
||||
end,
|
||||
},
|
||||
|
||||
|
@ -160,7 +61,6 @@ return {
|
|||
{ "%u[%l%d]+%f[^%l%d]", "%f[%S][%l%d]+%f[^%l%d]", "%f[%P][%l%d]+%f[^%l%d]", "^[%l%d]+%f[^%l%d]" },
|
||||
"^().*()$",
|
||||
},
|
||||
i = LazyVim.mini.ai_indent, -- indent
|
||||
g = LazyVim.mini.ai_buffer, -- buffer
|
||||
u = ai.gen_spec.function_call(), -- u for "Usage"
|
||||
U = ai.gen_spec.function_call({ name_pattern = "[%w_]" }), -- without dot in function name
|
||||
|
@ -190,12 +90,4 @@ return {
|
|||
},
|
||||
},
|
||||
},
|
||||
-- Add lazydev source to cmp
|
||||
{
|
||||
"hrsh7th/nvim-cmp",
|
||||
optional = true,
|
||||
opts = function(_, opts)
|
||||
table.insert(opts.sources, { name = "lazydev", group_index = 0 })
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ return {
|
|||
cmp = true,
|
||||
dashboard = true,
|
||||
flash = true,
|
||||
fzf = true,
|
||||
grug_far = true,
|
||||
gitsigns = true,
|
||||
headlines = true,
|
||||
|
|
|
@ -4,6 +4,9 @@ return {
|
|||
{ "garymjr/nvim-snippets", enabled = false },
|
||||
{ import = "lazyvim.plugins.extras.coding.luasnip" },
|
||||
|
||||
-- Use nvim-cmp instead of blink.cmp
|
||||
{ import = "lazyvim.plugins.extras.coding.nvim-cmp" },
|
||||
|
||||
-- Use mini.comment instead of ts-comments
|
||||
{ "folke/ts-comments.nvim", enabled = false },
|
||||
{ import = "lazyvim.plugins.extras.coding.mini-comment" },
|
||||
|
|
|
@ -176,12 +176,15 @@ return {
|
|||
event = "VeryLazy",
|
||||
opts_extend = { "spec" },
|
||||
opts = {
|
||||
preset = "helix",
|
||||
defaults = {},
|
||||
spec = {
|
||||
{
|
||||
mode = { "n", "v" },
|
||||
{ "<leader><tab>", group = "tabs" },
|
||||
{ "<leader>c", group = "code" },
|
||||
{ "<leader>d", group = "debug" },
|
||||
{ "<leader>dp", group = "profiler" },
|
||||
{ "<leader>f", group = "file/find" },
|
||||
{ "<leader>g", group = "git" },
|
||||
{ "<leader>gh", group = "hunks" },
|
||||
|
@ -300,6 +303,20 @@ return {
|
|||
end,
|
||||
},
|
||||
},
|
||||
{
|
||||
"gitsigns.nvim",
|
||||
opts = function()
|
||||
Snacks.toggle({
|
||||
name = "Git Signs",
|
||||
get = function()
|
||||
return require("gitsigns.config").config.signcolumn
|
||||
end,
|
||||
set = function(state)
|
||||
require("gitsigns").toggle_signs(state)
|
||||
end,
|
||||
}):map("<leader>uG")
|
||||
end,
|
||||
},
|
||||
|
||||
-- better diagnostics list and others
|
||||
{
|
||||
|
@ -380,4 +397,10 @@ return {
|
|||
return LazyVim.pick.want() == "telescope"
|
||||
end,
|
||||
},
|
||||
{
|
||||
import = "lazyvim.plugins.extras.editor.snacks_picker",
|
||||
enabled = function()
|
||||
return LazyVim.pick.want() == "snacks"
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ return {
|
|||
{
|
||||
"Exafunction/codeium.nvim",
|
||||
cmd = "Codeium",
|
||||
event = "InsertEnter",
|
||||
build = ":Codeium Auth",
|
||||
opts = {
|
||||
enable_cmp_source = vim.g.ai_cmp,
|
||||
|
@ -34,7 +35,7 @@ return {
|
|||
|
||||
-- codeium cmp source
|
||||
{
|
||||
"nvim-cmp",
|
||||
"hrsh7th/nvim-cmp",
|
||||
optional = true,
|
||||
dependencies = { "codeium.nvim" },
|
||||
opts = function(_, opts)
|
||||
|
@ -55,17 +56,21 @@ return {
|
|||
end,
|
||||
},
|
||||
|
||||
{
|
||||
vim.g.ai_cmp and {
|
||||
"saghen/blink.cmp",
|
||||
optional = true,
|
||||
dependencies = { "codeium.nvim", "saghen/blink.compat" },
|
||||
opts = {
|
||||
sources = {
|
||||
compat = vim.g.ai_cmp and { "codeium" } or nil,
|
||||
compat = { "codeium" },
|
||||
providers = {
|
||||
codeium = {
|
||||
kind = "Codeium",
|
||||
score_offset = 100,
|
||||
async = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
dependencies = {
|
||||
"codeium.nvim",
|
||||
vim.g.ai_cmp and "saghen/blink.compat" or nil,
|
||||
},
|
||||
},
|
||||
} or nil,
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ end
|
|||
return {
|
||||
{
|
||||
"CopilotC-Nvim/CopilotChat.nvim",
|
||||
branch = "canary",
|
||||
branch = "main",
|
||||
cmd = "CopilotChat",
|
||||
opts = function()
|
||||
local user = vim.env.USER or "User"
|
||||
|
|
|
@ -58,67 +58,61 @@ return {
|
|||
end,
|
||||
},
|
||||
|
||||
-- copilot cmp source
|
||||
{
|
||||
"nvim-cmp",
|
||||
optional = true,
|
||||
dependencies = { -- this will only be evaluated if nvim-cmp is enabled
|
||||
{
|
||||
"zbirenbaum/copilot-cmp",
|
||||
enabled = vim.g.ai_cmp, -- only enable if wanted
|
||||
opts = {},
|
||||
config = function(_, opts)
|
||||
local copilot_cmp = require("copilot_cmp")
|
||||
copilot_cmp.setup(opts)
|
||||
-- attach cmp source whenever copilot attaches
|
||||
-- fixes lazy-loading issues with the copilot cmp source
|
||||
LazyVim.lsp.on_attach(function()
|
||||
copilot_cmp._on_insert_enter({})
|
||||
end, "copilot")
|
||||
end,
|
||||
specs = {
|
||||
{
|
||||
"nvim-cmp",
|
||||
optional = true,
|
||||
---@param opts cmp.ConfigSchema
|
||||
opts = function(_, opts)
|
||||
table.insert(opts.sources, 1, {
|
||||
name = "copilot",
|
||||
group_index = 1,
|
||||
priority = 100,
|
||||
})
|
||||
end,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- blink.cmp
|
||||
{
|
||||
"saghen/blink.cmp",
|
||||
optional = true,
|
||||
dependencies = {
|
||||
{
|
||||
"giuxtaposition/blink-cmp-copilot",
|
||||
enabled = vim.g.ai_cmp, -- only enable if needed
|
||||
specs = {
|
||||
{
|
||||
"blink.cmp",
|
||||
optional = true,
|
||||
opts = {
|
||||
sources = {
|
||||
providers = {
|
||||
copilot = { name = "copilot", module = "blink-cmp-copilot" },
|
||||
},
|
||||
completion = {
|
||||
enabled_providers = { "copilot" },
|
||||
vim.g.ai_cmp
|
||||
and {
|
||||
-- copilot cmp source
|
||||
{
|
||||
"hrsh7th/nvim-cmp",
|
||||
optional = true,
|
||||
dependencies = { -- this will only be evaluated if nvim-cmp is enabled
|
||||
{
|
||||
"zbirenbaum/copilot-cmp",
|
||||
opts = {},
|
||||
config = function(_, opts)
|
||||
local copilot_cmp = require("copilot_cmp")
|
||||
copilot_cmp.setup(opts)
|
||||
-- attach cmp source whenever copilot attaches
|
||||
-- fixes lazy-loading issues with the copilot cmp source
|
||||
LazyVim.lsp.on_attach(function()
|
||||
copilot_cmp._on_insert_enter({})
|
||||
end, "copilot")
|
||||
end,
|
||||
specs = {
|
||||
{
|
||||
"hrsh7th/nvim-cmp",
|
||||
optional = true,
|
||||
---@param opts cmp.ConfigSchema
|
||||
opts = function(_, opts)
|
||||
table.insert(opts.sources, 1, {
|
||||
name = "copilot",
|
||||
group_index = 1,
|
||||
priority = 100,
|
||||
})
|
||||
end,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"saghen/blink.cmp",
|
||||
optional = true,
|
||||
dependencies = { "giuxtaposition/blink-cmp-copilot" },
|
||||
opts = {
|
||||
sources = {
|
||||
default = { "copilot" },
|
||||
providers = {
|
||||
copilot = {
|
||||
name = "copilot",
|
||||
module = "blink-cmp-copilot",
|
||||
kind = "Copilot",
|
||||
score_offset = 100,
|
||||
async = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
or nil,
|
||||
}
|
||||
|
|
|
@ -1,11 +1,17 @@
|
|||
return {
|
||||
{
|
||||
"supermaven-inc/supermaven-nvim",
|
||||
event = "InsertEnter",
|
||||
cmd = {
|
||||
"SupermavenUseFree",
|
||||
"SupermavenUsePro",
|
||||
},
|
||||
opts = {
|
||||
keymaps = {
|
||||
accept_suggestion = nil, -- handled by nvim-cmp / blink.cmp
|
||||
},
|
||||
disable_inline_completion = vim.g.ai_cmp,
|
||||
ignore_filetypes = { "bigfile", "snacks_input", "snacks_notif" },
|
||||
},
|
||||
},
|
||||
|
||||
|
@ -43,41 +49,23 @@ return {
|
|||
end,
|
||||
},
|
||||
|
||||
-- blink.cmp integration
|
||||
--
|
||||
-- FIXME: this currently doesn't work properly
|
||||
-- {
|
||||
-- "saghen/blink.cmp",
|
||||
-- optional = true,
|
||||
-- opts = {
|
||||
-- sources = {
|
||||
-- compat = vim.g.ai_cmp and { "supermaven" } or nil,
|
||||
-- },
|
||||
-- },
|
||||
-- dependencies = {
|
||||
-- "supermaven-nvim",
|
||||
-- vim.g.ai_cmp and "saghen/blink.compat" or nil,
|
||||
-- },
|
||||
-- },
|
||||
--
|
||||
-- Disabble cmp integration for now
|
||||
{
|
||||
vim.g.ai_cmp and {
|
||||
"saghen/blink.cmp",
|
||||
optional = true,
|
||||
---@module 'blink.cmp'
|
||||
---@type blink.cmp.Config
|
||||
dependencies = { "supermaven-nvim", "saghen/blink.compat" },
|
||||
opts = {
|
||||
completion = { ghost_text = { enabled = false } },
|
||||
},
|
||||
dependencies = {
|
||||
{
|
||||
"supermaven-nvim",
|
||||
opts = {
|
||||
disable_inline_completion = false,
|
||||
sources = {
|
||||
compat = { "supermaven" },
|
||||
providers = {
|
||||
supermaven = {
|
||||
kind = "Supermaven",
|
||||
score_offset = 100,
|
||||
async = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
} or nil,
|
||||
|
||||
{
|
||||
"nvim-lualine/lualine.nvim",
|
||||
|
|
|
@ -1,25 +1,22 @@
|
|||
return {
|
||||
-- Tabnine cmp source
|
||||
{
|
||||
"nvim-cmp",
|
||||
optional = true,
|
||||
dependencies = {
|
||||
{
|
||||
"tzachar/cmp-tabnine",
|
||||
build = {
|
||||
LazyVim.is_win() and "pwsh -noni .\\install.ps1" or "./install.sh",
|
||||
},
|
||||
dependencies = "hrsh7th/nvim-cmp",
|
||||
opts = {
|
||||
max_lines = 1000,
|
||||
max_num_results = 3,
|
||||
sort = true,
|
||||
},
|
||||
config = function(_, opts)
|
||||
require("cmp_tabnine.config"):setup(opts)
|
||||
end,
|
||||
},
|
||||
"tzachar/cmp-tabnine",
|
||||
build = LazyVim.is_win() and "pwsh -noni .\\install.ps1" or "./install.sh",
|
||||
opts = {
|
||||
max_lines = 1000,
|
||||
max_num_results = 3,
|
||||
sort = true,
|
||||
},
|
||||
config = function(_, opts)
|
||||
require("cmp_tabnine.config"):setup(opts)
|
||||
end,
|
||||
},
|
||||
|
||||
{
|
||||
"hrsh7th/nvim-cmp",
|
||||
optional = true,
|
||||
dependencies = { "tzachar/cmp-tabnine" },
|
||||
---@param opts cmp.ConfigSchema
|
||||
opts = function(_, opts)
|
||||
table.insert(opts.sources, 1, {
|
||||
|
@ -36,6 +33,25 @@ return {
|
|||
end)
|
||||
end,
|
||||
},
|
||||
|
||||
{
|
||||
"saghen/blink.cmp",
|
||||
optional = true,
|
||||
dependencies = { "tzachar/cmp-tabnine", "saghen/blink.compat" },
|
||||
opts = {
|
||||
sources = {
|
||||
compat = { "cmp_tabnine" },
|
||||
providers = {
|
||||
cmp_tabnine = {
|
||||
kind = "TabNine",
|
||||
score_offset = 100,
|
||||
async = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- Show TabNine status in lualine
|
||||
{
|
||||
"nvim-lualine/lualine.nvim",
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
---@diagnostic disable: missing-fields
|
||||
if lazyvim_docs then
|
||||
-- set to `true` to follow the main branch
|
||||
-- you need to have a working rust toolchain to build the plugin
|
||||
|
@ -8,6 +9,7 @@ end
|
|||
return {
|
||||
{
|
||||
"hrsh7th/nvim-cmp",
|
||||
optional = true,
|
||||
enabled = false,
|
||||
},
|
||||
{
|
||||
|
@ -17,6 +19,7 @@ return {
|
|||
opts_extend = {
|
||||
"sources.completion.enabled_providers",
|
||||
"sources.compat",
|
||||
"sources.default",
|
||||
},
|
||||
dependencies = {
|
||||
"rafamadriz/friendly-snippets",
|
||||
|
@ -33,18 +36,31 @@ return {
|
|||
---@module 'blink.cmp'
|
||||
---@type blink.cmp.Config
|
||||
opts = {
|
||||
highlight = {
|
||||
snippets = {
|
||||
expand = function(snippet, _)
|
||||
return LazyVim.cmp.expand(snippet)
|
||||
end,
|
||||
},
|
||||
appearance = {
|
||||
-- sets the fallback highlight groups to nvim-cmp's highlight groups
|
||||
-- useful for when your theme doesn't support blink.cmp
|
||||
-- will be removed in a future release, assuming themes add support
|
||||
use_nvim_cmp_as_default = false,
|
||||
-- set to 'mono' for 'Nerd Font Mono' or 'normal' for 'Nerd Font'
|
||||
-- adjusts spacing to ensure icons are aligned
|
||||
nerd_font_variant = "mono",
|
||||
},
|
||||
-- set to 'mono' for 'Nerd Font Mono' or 'normal' for 'Nerd Font'
|
||||
-- adjusts spacing to ensure icons are aligned
|
||||
nerd_font_variant = "mono",
|
||||
completion = {
|
||||
accept = {
|
||||
-- experimental auto-brackets support
|
||||
auto_brackets = {
|
||||
enabled = true,
|
||||
},
|
||||
},
|
||||
menu = {
|
||||
winblend = vim.o.pumblend,
|
||||
draw = {
|
||||
treesitter = { "lsp" },
|
||||
},
|
||||
},
|
||||
documentation = {
|
||||
auto_show = true,
|
||||
|
@ -55,33 +71,26 @@ return {
|
|||
},
|
||||
},
|
||||
|
||||
-- experimental auto-brackets support
|
||||
accept = { auto_brackets = { enabled = true } },
|
||||
|
||||
-- experimental signature help support
|
||||
-- trigger = { signature_help = { enabled = true } }
|
||||
-- signature = { enabled = true },
|
||||
|
||||
sources = {
|
||||
-- adding any nvim-cmp sources here will enable them
|
||||
-- with blink.compat
|
||||
compat = {},
|
||||
completion = {
|
||||
-- remember to enable your providers here
|
||||
enabled_providers = { "lsp", "path", "snippets", "buffer" },
|
||||
},
|
||||
default = { "lsp", "path", "snippets", "buffer" },
|
||||
cmdline = {},
|
||||
},
|
||||
|
||||
keymap = {
|
||||
preset = "enter",
|
||||
["<Tab>"] = {
|
||||
LazyVim.cmp.map({ "snippet_forward", "ai_accept" }),
|
||||
"fallback",
|
||||
},
|
||||
["<C-y>"] = { "select_and_accept" },
|
||||
},
|
||||
},
|
||||
---@param opts blink.cmp.Config | { sources: { compat: string[] } }
|
||||
config = function(_, opts)
|
||||
-- setup compat sources
|
||||
local enabled = opts.sources.completion.enabled_providers
|
||||
local enabled = opts.sources.default
|
||||
for _, source in ipairs(opts.sources.compat or {}) do
|
||||
opts.sources.providers[source] = vim.tbl_deep_extend(
|
||||
"force",
|
||||
|
@ -92,6 +101,54 @@ return {
|
|||
table.insert(enabled, source)
|
||||
end
|
||||
end
|
||||
|
||||
-- add ai_accept to <Tab> key
|
||||
if not opts.keymap["<Tab>"] then
|
||||
if opts.keymap.preset == "super-tab" then -- super-tab
|
||||
opts.keymap["<Tab>"] = {
|
||||
require("blink.cmp.keymap.presets")["super-tab"]["<Tab>"][1],
|
||||
LazyVim.cmp.map({ "snippet_forward", "ai_accept" }),
|
||||
"fallback",
|
||||
}
|
||||
else -- other presets
|
||||
opts.keymap["<Tab>"] = {
|
||||
LazyVim.cmp.map({ "snippet_forward", "ai_accept" }),
|
||||
"fallback",
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
-- Unset custom prop to pass blink.cmp validation
|
||||
opts.sources.compat = nil
|
||||
|
||||
-- check if we need to override symbol kinds
|
||||
for _, provider in pairs(opts.sources.providers or {}) do
|
||||
---@cast provider blink.cmp.SourceProviderConfig|{kind?:string}
|
||||
if provider.kind then
|
||||
local CompletionItemKind = require("blink.cmp.types").CompletionItemKind
|
||||
local kind_idx = #CompletionItemKind + 1
|
||||
|
||||
CompletionItemKind[kind_idx] = provider.kind
|
||||
---@diagnostic disable-next-line: no-unknown
|
||||
CompletionItemKind[provider.kind] = kind_idx
|
||||
|
||||
---@type fun(ctx: blink.cmp.Context, items: blink.cmp.CompletionItem[]): blink.cmp.CompletionItem[]
|
||||
local transform_items = provider.transform_items
|
||||
---@param ctx blink.cmp.Context
|
||||
---@param items blink.cmp.CompletionItem[]
|
||||
provider.transform_items = function(ctx, items)
|
||||
items = transform_items and transform_items(ctx, items) or items
|
||||
for _, item in ipairs(items) do
|
||||
item.kind = kind_idx or item.kind
|
||||
end
|
||||
return items
|
||||
end
|
||||
|
||||
-- Unset custom prop to pass blink.cmp validation
|
||||
provider.kind = nil
|
||||
end
|
||||
end
|
||||
|
||||
require("blink.cmp").setup(opts)
|
||||
end,
|
||||
},
|
||||
|
@ -101,7 +158,7 @@ return {
|
|||
"saghen/blink.cmp",
|
||||
opts = function(_, opts)
|
||||
opts.appearance = opts.appearance or {}
|
||||
opts.appearance.kind_icons = LazyVim.config.icons.kinds
|
||||
opts.appearance.kind_icons = vim.tbl_extend("force", opts.appearance.kind_icons or {}, LazyVim.config.icons.kinds)
|
||||
end,
|
||||
},
|
||||
|
||||
|
@ -110,18 +167,13 @@ return {
|
|||
"saghen/blink.cmp",
|
||||
opts = {
|
||||
sources = {
|
||||
completion = {
|
||||
-- add lazydev to your completion providers
|
||||
enabled_providers = { "lazydev" },
|
||||
},
|
||||
-- add lazydev to your completion providers
|
||||
default = { "lazydev" },
|
||||
providers = {
|
||||
lsp = {
|
||||
-- dont show LuaLS require statements when lazydev has items
|
||||
fallback_for = { "lazydev" },
|
||||
},
|
||||
lazydev = {
|
||||
name = "LazyDev",
|
||||
module = "lazydev.integrations.blink",
|
||||
score_offset = 100, -- show at a higher priority than lsp
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
@ -14,6 +14,7 @@ return {
|
|||
"rafamadriz/friendly-snippets",
|
||||
config = function()
|
||||
require("luasnip.loaders.from_vscode").lazy_load()
|
||||
require("luasnip.loaders.from_vscode").lazy_load({ paths = { vim.fn.stdpath("config") .. "/snippets" } })
|
||||
end,
|
||||
},
|
||||
},
|
||||
|
@ -33,12 +34,18 @@ return {
|
|||
return true
|
||||
end
|
||||
end
|
||||
LazyVim.cmp.actions.snippet_stop = function()
|
||||
if require("luasnip").expand_or_jumpable() then -- or just jumpable(1) is fine?
|
||||
require("luasnip").unlink_current()
|
||||
return true
|
||||
end
|
||||
end
|
||||
end,
|
||||
},
|
||||
|
||||
-- nvim-cmp integration
|
||||
{
|
||||
"nvim-cmp",
|
||||
"hrsh7th/nvim-cmp",
|
||||
optional = true,
|
||||
dependencies = { "saadparwaiz1/cmp_luasnip" },
|
||||
opts = function(_, opts)
|
||||
|
@ -60,25 +67,9 @@ return {
|
|||
{
|
||||
"saghen/blink.cmp",
|
||||
optional = true,
|
||||
dependencies = {
|
||||
{ "saghen/blink.compat", opts = { impersonate_nvim_cmp = true } },
|
||||
{ "saadparwaiz1/cmp_luasnip" },
|
||||
},
|
||||
opts = {
|
||||
sources = { compat = { "luasnip" } },
|
||||
snippets = {
|
||||
expand = function(snippet)
|
||||
require("luasnip").lsp_expand(snippet)
|
||||
end,
|
||||
active = function(filter)
|
||||
if filter and filter.direction then
|
||||
return require("luasnip").jumpable(filter.direction)
|
||||
end
|
||||
return require("luasnip").in_snippet()
|
||||
end,
|
||||
jump = function(direction)
|
||||
require("luasnip").jump(direction)
|
||||
end,
|
||||
preset = "luasnip",
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
167
lua/lazyvim/plugins/extras/coding/mini-snippets.lua
Normal file
167
lua/lazyvim/plugins/extras/coding/mini-snippets.lua
Normal file
|
@ -0,0 +1,167 @@
|
|||
if lazyvim_docs then
|
||||
-- Set to `false` to prevent "non-lsp snippets"" from appearing inside completion windows
|
||||
-- Motivation: Less clutter in completion windows and a more direct usage of snippits
|
||||
vim.g.lazyvim_mini_snippets_in_completion = true
|
||||
|
||||
-- NOTE: Please also read:
|
||||
-- https://github.com/echasnovski/mini.nvim/blob/main/readmes/mini-snippets.md#expand
|
||||
-- :h MiniSnippets-session
|
||||
|
||||
-- Example override for your own config:
|
||||
--[[
|
||||
return {
|
||||
{
|
||||
"echasnovski/mini.snippets",
|
||||
opts = function(_, opts)
|
||||
-- By default, for opts.snippets, the extra for mini.snippets only adds gen_loader.from_lang()
|
||||
-- This provides a sensible quickstart, integrating with friendly-snippets
|
||||
-- and your own language-specific snippets
|
||||
--
|
||||
-- In order to change opts.snippets, replace the entire table inside your own opts
|
||||
|
||||
local snippets, config_path = require("mini.snippets"), vim.fn.stdpath("config")
|
||||
|
||||
opts.snippets = { -- override opts.snippets provided by extra...
|
||||
-- Load custom file with global snippets first (order matters)
|
||||
snippets.gen_loader.from_file(config_path .. "/snippets/global.json"),
|
||||
|
||||
-- Load snippets based on current language by reading files from
|
||||
-- "snippets/" subdirectories from 'runtimepath' directories.
|
||||
snippets.gen_loader.from_lang(), -- this is the default in the extra...
|
||||
}
|
||||
end,
|
||||
},
|
||||
}
|
||||
--]]
|
||||
end
|
||||
|
||||
local include_in_completion = vim.g.lazyvim_mini_snippets_in_completion == nil
|
||||
or vim.g.lazyvim_mini_snippets_in_completion
|
||||
|
||||
local function expand_from_lsp(snippet)
|
||||
local insert = MiniSnippets.config.expand.insert or MiniSnippets.default_insert
|
||||
insert({ body = snippet })
|
||||
end
|
||||
|
||||
local function jump(direction)
|
||||
local is_active = MiniSnippets.session.get(false) ~= nil
|
||||
if is_active then
|
||||
MiniSnippets.session.jump(direction)
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
---@type fun(snippets, insert) | nil
|
||||
local expand_select_override = nil
|
||||
|
||||
return {
|
||||
-- disable builtin snippet support:
|
||||
{ "garymjr/nvim-snippets", optional = true, enabled = false },
|
||||
-- disable luasnip:
|
||||
{ "L3MON4D3/LuaSnip", optional = true, enabled = false },
|
||||
|
||||
-- add mini.snippets
|
||||
desc = "mini.snippets(beta), a plugin to manage and expand snippets (alternative for luasnip)",
|
||||
{
|
||||
"echasnovski/mini.snippets",
|
||||
event = "InsertEnter", -- don't depend on other plugins to load...
|
||||
dependencies = "rafamadriz/friendly-snippets",
|
||||
opts = function()
|
||||
---@diagnostic disable-next-line: duplicate-set-field
|
||||
LazyVim.cmp.actions.snippet_stop = function() end -- by design, <esc> should not stop the session!
|
||||
---@diagnostic disable-next-line: duplicate-set-field
|
||||
LazyVim.cmp.actions.snippet_forward = function()
|
||||
return jump("next")
|
||||
end
|
||||
|
||||
local mini_snippets = require("mini.snippets")
|
||||
return {
|
||||
snippets = { mini_snippets.gen_loader.from_lang() },
|
||||
|
||||
-- Following the behavior of vim.snippets,
|
||||
-- the intended usage of <esc> is to be able to temporarily exit into normal mode for quick edits.
|
||||
--
|
||||
-- If you'd rather stop the snippet on <esc>, activate the line below in your own config:
|
||||
-- mappings = { stop = "<esc>" }, -- <c-c> by default, see :h MiniSnippets-session
|
||||
|
||||
expand = {
|
||||
select = function(snippets, insert)
|
||||
-- Close completion window on snippet select - vim.ui.select
|
||||
-- Needed to remove virtual text for fzf-lua and telescope, but not for mini.pick...
|
||||
local select = expand_select_override or MiniSnippets.default_select
|
||||
select(snippets, insert)
|
||||
end,
|
||||
},
|
||||
}
|
||||
end,
|
||||
},
|
||||
|
||||
-- nvim-cmp integration
|
||||
{
|
||||
"hrsh7th/nvim-cmp",
|
||||
optional = true,
|
||||
dependencies = include_in_completion and { "abeldekat/cmp-mini-snippets" } or nil,
|
||||
opts = function(_, opts)
|
||||
local cmp = require("cmp")
|
||||
local cmp_config = require("cmp.config")
|
||||
|
||||
opts.snippet = {
|
||||
expand = function(args)
|
||||
expand_from_lsp(args.body)
|
||||
cmp.resubscribe({ "TextChangedI", "TextChangedP" })
|
||||
cmp_config.set_onetime({ sources = {} })
|
||||
end,
|
||||
}
|
||||
|
||||
if include_in_completion then
|
||||
table.insert(opts.sources, { name = "mini_snippets" })
|
||||
else
|
||||
expand_select_override = function(snippets, insert)
|
||||
-- stylua: ignore
|
||||
if cmp.visible() then cmp.close() end
|
||||
MiniSnippets.default_select(snippets, insert)
|
||||
end
|
||||
end
|
||||
end,
|
||||
-- stylua: ignore
|
||||
-- counterpart to <tab> defined in cmp.mappings
|
||||
keys = include_in_completion and { { "<s-tab>", function() jump("prev") end, mode = "i" } } or nil,
|
||||
},
|
||||
|
||||
-- blink.cmp integration
|
||||
{
|
||||
"saghen/blink.cmp",
|
||||
optional = true,
|
||||
opts = function(_, opts)
|
||||
-- Return early
|
||||
if include_in_completion then
|
||||
opts.snippets = { preset = "mini_snippets" }
|
||||
return
|
||||
end
|
||||
|
||||
-- Standalone --
|
||||
expand_select_override = function(snippets, insert)
|
||||
-- Schedule, otherwise blink's virtual text is not removed on vim.ui.select
|
||||
require("blink.cmp").cancel()
|
||||
vim.schedule(function()
|
||||
MiniSnippets.default_select(snippets, insert)
|
||||
end)
|
||||
end
|
||||
--
|
||||
-- Blink performs a require on blink.cmp.sources.snippets.default
|
||||
-- By removing the source, the default engine will not be used
|
||||
opts.sources.default = vim.tbl_filter(function(source)
|
||||
return source ~= "snippets"
|
||||
end, opts.sources.default)
|
||||
opts.snippets = { -- need to repeat blink's preset here
|
||||
expand = expand_from_lsp,
|
||||
active = function()
|
||||
return MiniSnippets.session.get(false) ~= nil
|
||||
end,
|
||||
jump = function(direction)
|
||||
jump(direction == -1 and "prev" or "next")
|
||||
end,
|
||||
}
|
||||
end,
|
||||
},
|
||||
}
|
118
lua/lazyvim/plugins/extras/coding/nvim-cmp.lua
Normal file
118
lua/lazyvim/plugins/extras/coding/nvim-cmp.lua
Normal file
|
@ -0,0 +1,118 @@
|
|||
return {
|
||||
{
|
||||
"saghen/blink.cmp",
|
||||
enabled = false,
|
||||
optional = true,
|
||||
},
|
||||
|
||||
-- Setup nvim-cmp
|
||||
{
|
||||
"hrsh7th/nvim-cmp",
|
||||
version = false, -- last release is way too old
|
||||
event = "InsertEnter",
|
||||
dependencies = {
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
"hrsh7th/cmp-buffer",
|
||||
"hrsh7th/cmp-path",
|
||||
},
|
||||
-- Not all LSP servers add brackets when completing a function.
|
||||
-- To better deal with this, LazyVim adds a custom option to cmp,
|
||||
-- that you can configure. For example:
|
||||
--
|
||||
-- ```lua
|
||||
-- opts = {
|
||||
-- auto_brackets = { "python" }
|
||||
-- }
|
||||
-- ```
|
||||
opts = function()
|
||||
vim.api.nvim_set_hl(0, "CmpGhostText", { link = "Comment", default = true })
|
||||
local cmp = require("cmp")
|
||||
local defaults = require("cmp.config.default")()
|
||||
local auto_select = true
|
||||
return {
|
||||
auto_brackets = {}, -- configure any filetype to auto add brackets
|
||||
completion = {
|
||||
completeopt = "menu,menuone,noinsert" .. (auto_select and "" or ",noselect"),
|
||||
},
|
||||
preselect = auto_select and cmp.PreselectMode.Item or cmp.PreselectMode.None,
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
["<C-b>"] = cmp.mapping.scroll_docs(-4),
|
||||
["<C-f>"] = cmp.mapping.scroll_docs(4),
|
||||
["<C-n>"] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }),
|
||||
["<C-p>"] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }),
|
||||
["<C-Space>"] = cmp.mapping.complete(),
|
||||
["<CR>"] = LazyVim.cmp.confirm({ select = auto_select }),
|
||||
["<C-y>"] = LazyVim.cmp.confirm({ select = true }),
|
||||
["<S-CR>"] = LazyVim.cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
||||
["<C-CR>"] = function(fallback)
|
||||
cmp.abort()
|
||||
fallback()
|
||||
end,
|
||||
["<tab>"] = function(fallback)
|
||||
return LazyVim.cmp.map({ "snippet_forward", "ai_accept" }, fallback)()
|
||||
end,
|
||||
}),
|
||||
sources = cmp.config.sources({
|
||||
{ name = "lazydev" },
|
||||
{ name = "nvim_lsp" },
|
||||
{ name = "path" },
|
||||
}, {
|
||||
{ name = "buffer" },
|
||||
}),
|
||||
formatting = {
|
||||
format = function(entry, item)
|
||||
local icons = LazyVim.config.icons.kinds
|
||||
if icons[item.kind] then
|
||||
item.kind = icons[item.kind] .. item.kind
|
||||
end
|
||||
|
||||
local widths = {
|
||||
abbr = vim.g.cmp_widths and vim.g.cmp_widths.abbr or 40,
|
||||
menu = vim.g.cmp_widths and vim.g.cmp_widths.menu or 30,
|
||||
}
|
||||
|
||||
for key, width in pairs(widths) do
|
||||
if item[key] and vim.fn.strdisplaywidth(item[key]) > width then
|
||||
item[key] = vim.fn.strcharpart(item[key], 0, width - 1) .. "…"
|
||||
end
|
||||
end
|
||||
|
||||
return item
|
||||
end,
|
||||
},
|
||||
experimental = {
|
||||
-- only show ghost text when we show ai completions
|
||||
ghost_text = vim.g.ai_cmp and {
|
||||
hl_group = "CmpGhostText",
|
||||
} or false,
|
||||
},
|
||||
sorting = defaults.sorting,
|
||||
}
|
||||
end,
|
||||
main = "lazyvim.util.cmp",
|
||||
},
|
||||
|
||||
-- snippets
|
||||
{
|
||||
"hrsh7th/nvim-cmp",
|
||||
dependencies = {
|
||||
{
|
||||
"garymjr/nvim-snippets",
|
||||
opts = {
|
||||
friendly_snippets = true,
|
||||
},
|
||||
dependencies = { "rafamadriz/friendly-snippets" },
|
||||
},
|
||||
},
|
||||
opts = function(_, opts)
|
||||
opts.snippet = {
|
||||
expand = function(item)
|
||||
return LazyVim.cmp.expand(item.body)
|
||||
end,
|
||||
}
|
||||
if LazyVim.has("nvim-snippets") then
|
||||
table.insert(opts.sources, { name = "snippets" })
|
||||
end
|
||||
end,
|
||||
},
|
||||
}
|
|
@ -33,7 +33,6 @@ return {
|
|||
|
||||
-- stylua: ignore
|
||||
keys = {
|
||||
{ "<leader>d", "", desc = "+debug", mode = {"n", "v"} },
|
||||
{ "<leader>dB", function() require("dap").set_breakpoint(vim.fn.input('Breakpoint condition: ')) end, desc = "Breakpoint Condition" },
|
||||
{ "<leader>db", function() require("dap").toggle_breakpoint() end, desc = "Toggle Breakpoint" },
|
||||
{ "<leader>dc", function() require("dap").continue() end, desc = "Run/Continue" },
|
||||
|
@ -46,7 +45,7 @@ return {
|
|||
{ "<leader>dl", function() require("dap").run_last() end, desc = "Run Last" },
|
||||
{ "<leader>do", function() require("dap").step_out() end, desc = "Step Out" },
|
||||
{ "<leader>dO", function() require("dap").step_over() end, desc = "Step Over" },
|
||||
{ "<leader>dp", function() require("dap").pause() end, desc = "Pause" },
|
||||
{ "<leader>dP", function() require("dap").pause() end, desc = "Pause" },
|
||||
{ "<leader>dr", function() require("dap").repl.toggle() end, desc = "Toggle REPL" },
|
||||
{ "<leader>ds", function() require("dap").session() end, desc = "Session" },
|
||||
{ "<leader>dt", function() require("dap").terminate() end, desc = "Terminate" },
|
||||
|
|
|
@ -140,6 +140,11 @@ return {
|
|||
}),
|
||||
},
|
||||
markdown = {
|
||||
augend.constant.new({
|
||||
elements = { "[ ]", "[x]" },
|
||||
word = false,
|
||||
cyclic = true,
|
||||
}),
|
||||
augend.misc.alias.markdown_header,
|
||||
},
|
||||
json = {
|
||||
|
|
|
@ -45,8 +45,9 @@ return {
|
|||
"ibhagwan/fzf-lua",
|
||||
cmd = "FzfLua",
|
||||
opts = function(_, opts)
|
||||
local config = require("fzf-lua.config")
|
||||
local actions = require("fzf-lua.actions")
|
||||
local fzf = require("fzf-lua")
|
||||
local config = fzf.config
|
||||
local actions = fzf.actions
|
||||
|
||||
-- Quickfix
|
||||
config.defaults.keymap.fzf["ctrl-q"] = "select-all+accept"
|
||||
|
@ -285,6 +286,9 @@ return {
|
|||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
opts = function()
|
||||
if LazyVim.pick.want() ~= "fzf" then
|
||||
return
|
||||
end
|
||||
local Keys = require("lazyvim.plugins.lsp.keymaps").get()
|
||||
-- stylua: ignore
|
||||
vim.list_extend(Keys, {
|
||||
|
|
|
@ -2,6 +2,9 @@
|
|||
-- This works with LSP, Treesitter, and regexp matching to find the other
|
||||
-- instances.
|
||||
return {
|
||||
-- disable snacks words
|
||||
{ "snacks.nvim", opts = { words = { enabled = false } } },
|
||||
|
||||
{
|
||||
"RRethy/vim-illuminate",
|
||||
event = "LazyFile",
|
||||
|
@ -53,8 +56,4 @@ return {
|
|||
{ "[[", desc = "Prev Reference" },
|
||||
},
|
||||
},
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
opts = { document_highlight = { enabled = false } },
|
||||
},
|
||||
}
|
||||
|
|
|
@ -29,6 +29,29 @@ return {
|
|||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"mini.diff",
|
||||
opts = function()
|
||||
Snacks.toggle({
|
||||
name = "Mini Diff Signs",
|
||||
get = function()
|
||||
return vim.g.minidiff_disable ~= true
|
||||
end,
|
||||
set = function(state)
|
||||
vim.g.minidiff_disable = not state
|
||||
if state then
|
||||
require("mini.diff").enable(0)
|
||||
else
|
||||
require("mini.diff").disable(0)
|
||||
end
|
||||
-- HACK: redraw to update the signs
|
||||
vim.defer_fn(function()
|
||||
vim.cmd([[redraw!]])
|
||||
end, 200)
|
||||
end,
|
||||
}):map("<leader>uG")
|
||||
end,
|
||||
},
|
||||
|
||||
-- lualine integration
|
||||
{
|
||||
|
|
155
lua/lazyvim/plugins/extras/editor/snacks_picker.lua
Normal file
155
lua/lazyvim/plugins/extras/editor/snacks_picker.lua
Normal file
|
@ -0,0 +1,155 @@
|
|||
if lazyvim_docs then
|
||||
-- In case you don't want to use `:LazyExtras`,
|
||||
-- then you need to set the option below.
|
||||
vim.g.lazyvim_picker = "snacks"
|
||||
end
|
||||
|
||||
---@module 'snacks'
|
||||
|
||||
---@type LazyPicker
|
||||
local picker = {
|
||||
name = "snacks",
|
||||
commands = {
|
||||
files = "files",
|
||||
live_grep = "grep",
|
||||
oldfiles = "recent",
|
||||
},
|
||||
|
||||
---@param source string
|
||||
---@param opts? snacks.picker.Config
|
||||
open = function(source, opts)
|
||||
return Snacks.picker.pick(source, opts)
|
||||
end,
|
||||
}
|
||||
if not LazyVim.pick.register(picker) then
|
||||
return {}
|
||||
end
|
||||
|
||||
return {
|
||||
desc = "Fast and modern file picker",
|
||||
recommended = true,
|
||||
{
|
||||
"folke/snacks.nvim",
|
||||
opts = {
|
||||
picker = {
|
||||
win = {
|
||||
input = {
|
||||
keys = {
|
||||
["<a-c>"] = {
|
||||
"toggle_cwd",
|
||||
mode = { "n", "i" },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
actions = {
|
||||
---@param p snacks.Picker
|
||||
toggle_cwd = function(p)
|
||||
local root = LazyVim.root({ buf = p.input.filter.current_buf, normalize = true })
|
||||
local cwd = vim.fs.normalize((vim.uv or vim.loop).cwd() or ".")
|
||||
local current = p:cwd()
|
||||
p:set_cwd(current == root and cwd or root)
|
||||
p:find()
|
||||
end,
|
||||
},
|
||||
},
|
||||
},
|
||||
-- stylua: ignore
|
||||
keys = {
|
||||
{ "<leader>,", function() Snacks.picker.buffers() end, desc = "Buffers" },
|
||||
{ "<leader>/", LazyVim.pick("grep"), desc = "Grep (Root Dir)" },
|
||||
{ "<leader>:", function() Snacks.picker.command_history() end, desc = "Command History" },
|
||||
{ "<leader><space>", LazyVim.pick("files"), desc = "Find Files (Root Dir)" },
|
||||
-- find
|
||||
{ "<leader>fb", function() Snacks.picker.buffers() end, desc = "Buffers" },
|
||||
{ "<leader>fB", function() Snacks.picker.buffers({ hidden = true, nofile = true }) end, desc = "Buffers (all)" },
|
||||
{ "<leader>fc", LazyVim.pick.config_files(), desc = "Find Config File" },
|
||||
{ "<leader>ff", LazyVim.pick("files"), desc = "Find Files (Root Dir)" },
|
||||
{ "<leader>fF", LazyVim.pick("files", { root = false }), desc = "Find Files (cwd)" },
|
||||
{ "<leader>fg", function() Snacks.picker.git_files() end, desc = "Find Files (git-files)" },
|
||||
{ "<leader>fr", LazyVim.pick("oldfiles"), desc = "Recent" },
|
||||
{ "<leader>fR", LazyVim.pick("oldfiles", { filter = { cwd = true }}), desc = "Recent (cwd)" },
|
||||
{ "<leader>fp", function() Snacks.picker.projects() end, desc = "Projects" },
|
||||
-- git
|
||||
{ "<leader>gc", function() Snacks.picker.git_log() end, desc = "Git Log" },
|
||||
{ "<leader>gd", function() Snacks.picker.git_diff() end, desc = "Git Diff (hunks)" },
|
||||
{ "<leader>gs", function() Snacks.picker.git_status() end, desc = "Git Status" },
|
||||
-- Grep
|
||||
{ "<leader>sb", function() Snacks.picker.lines() end, desc = "Buffer Lines" },
|
||||
{ "<leader>sB", function() Snacks.picker.grep_buffers() end, desc = "Grep Open Buffers" },
|
||||
{ "<leader>sg", LazyVim.pick("live_grep"), desc = "Grep (Root Dir)" },
|
||||
{ "<leader>sG", LazyVim.pick("live_grep", { root = false }), desc = "Grep (cwd)" },
|
||||
{ "<leader>sp", function() Snacks.picker.lazy() end, desc = "Search for Plugin Spec" },
|
||||
{ "<leader>sw", LazyVim.pick("grep_word"), desc = "Visual selection or word (Root Dir)", mode = { "n", "x" } },
|
||||
{ "<leader>sW", LazyVim.pick("grep_word", { root = false }), desc = "Visual selection or word (cwd)", mode = { "n", "x" } },
|
||||
-- search
|
||||
{ '<leader>s"', function() Snacks.picker.registers() end, desc = "Registers" },
|
||||
{ "<leader>sa", function() Snacks.picker.autocmds() end, desc = "Autocmds" },
|
||||
{ "<leader>sc", function() Snacks.picker.command_history() end, desc = "Command History" },
|
||||
{ "<leader>sC", function() Snacks.picker.commands() end, desc = "Commands" },
|
||||
{ "<leader>sd", function() Snacks.picker.diagnostics() end, desc = "Diagnostics" },
|
||||
{ "<leader>sh", function() Snacks.picker.help() end, desc = "Help Pages" },
|
||||
{ "<leader>sH", function() Snacks.picker.highlights() end, desc = "Highlights" },
|
||||
{ "<leader>si", function() Snacks.picker.icons() end, desc = "Icons" },
|
||||
{ "<leader>sj", function() Snacks.picker.jumps() end, desc = "Jumps" },
|
||||
{ "<leader>sk", function() Snacks.picker.keymaps() end, desc = "Keymaps" },
|
||||
{ "<leader>sl", function() Snacks.picker.loclist() end, desc = "Location List" },
|
||||
{ "<leader>sM", function() Snacks.picker.man() end, desc = "Man Pages" },
|
||||
{ "<leader>sm", function() Snacks.picker.marks() end, desc = "Marks" },
|
||||
{ "<leader>sR", function() Snacks.picker.resume() end, desc = "Resume" },
|
||||
{ "<leader>sq", function() Snacks.picker.qflist() end, desc = "Quickfix List" },
|
||||
{ "<leader>su", function() Snacks.picker.undo() end, desc = "Undotree" },
|
||||
-- ui
|
||||
{ "<leader>uC", function() Snacks.picker.colorschemes() end, desc = "Colorschemes" },
|
||||
},
|
||||
},
|
||||
{
|
||||
"folke/snacks.nvim",
|
||||
opts = function(_, opts)
|
||||
if LazyVim.has("trouble.nvim") then
|
||||
return vim.tbl_deep_extend("force", opts or {}, {
|
||||
picker = {
|
||||
actions = require("trouble.sources.snacks").actions,
|
||||
win = {
|
||||
input = {
|
||||
keys = {
|
||||
["<c-t>"] = {
|
||||
"trouble_open",
|
||||
mode = { "n", "i" },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
end
|
||||
end,
|
||||
},
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
opts = function()
|
||||
if LazyVim.pick.want() ~= "snacks" then
|
||||
return
|
||||
end
|
||||
local Keys = require("lazyvim.plugins.lsp.keymaps").get()
|
||||
-- stylua: ignore
|
||||
vim.list_extend(Keys, {
|
||||
{ "gd", function() Snacks.picker.lsp_definitions() end, desc = "Goto Definition", has = "definition" },
|
||||
{ "gr", function() Snacks.picker.lsp_references() end, nowait = true, desc = "References" },
|
||||
{ "gI", function() Snacks.picker.lsp_implementations() end, desc = "Goto Implementation" },
|
||||
{ "gy", function() Snacks.picker.lsp_type_definitions() end, desc = "Goto T[y]pe Definition" },
|
||||
{ "<leader>ss", function() Snacks.picker.lsp_symbols({ filter = LazyVim.config.kind_filter }) end, desc = "LSP Symbols", has = "documentSymbol" },
|
||||
{ "<leader>sS", function() Snacks.picker.lsp_workspace_symbols({ filter = LazyVim.config.kind_filter }) end, desc = "LSP Workspace Symbols", has = "workspace/symbols" },
|
||||
})
|
||||
end,
|
||||
},
|
||||
{
|
||||
"folke/todo-comments.nvim",
|
||||
optional = true,
|
||||
-- stylua: ignore
|
||||
keys = {
|
||||
{ "<leader>st", function() Snacks.picker.todo_comments() end, desc = "Todo" },
|
||||
{ "<leader>sT", function () Snacks.picker.todo_comments({ keywords = { "TODO", "FIX", "FIXME" } }) end, desc = "Todo/Fix/Fixme" },
|
||||
},
|
||||
},
|
||||
}
|
|
@ -103,8 +103,11 @@ return {
|
|||
},
|
||||
|
||||
{
|
||||
"nvim-cmp",
|
||||
"hrsh7th/nvim-cmp",
|
||||
optional = true,
|
||||
opts = function(_, opts)
|
||||
opts.sorting = opts.sorting or {}
|
||||
opts.sorting.comparators = opts.sorting.comparators or {}
|
||||
table.insert(opts.sorting.comparators, 1, require("clangd_extensions.cmp_scores"))
|
||||
end,
|
||||
},
|
||||
|
|
|
@ -9,7 +9,8 @@ return {
|
|||
},
|
||||
|
||||
{
|
||||
"nvim-cmp",
|
||||
"hrsh7th/nvim-cmp",
|
||||
optional = true,
|
||||
dependencies = {
|
||||
{ "petertriho/cmp-git", opts = {} },
|
||||
},
|
||||
|
|
|
@ -85,8 +85,12 @@ return {
|
|||
dependencies = { "folke/which-key.nvim" },
|
||||
ft = java_filetypes,
|
||||
opts = function()
|
||||
local mason_registry = require("mason-registry")
|
||||
local lombok_jar = mason_registry.get_package("jdtls"):get_install_path() .. "/lombok.jar"
|
||||
local cmd = { vim.fn.exepath("jdtls") }
|
||||
if LazyVim.has("mason.nvim") then
|
||||
local mason_registry = require("mason-registry")
|
||||
local lombok_jar = mason_registry.get_package("jdtls"):get_install_path() .. "/lombok.jar"
|
||||
table.insert(cmd, string.format("--jvm-arg=-javaagent:%s", lombok_jar))
|
||||
end
|
||||
return {
|
||||
-- How to find the root dir for a given filename. The default comes from
|
||||
-- lspconfig which provides a function specifically for java projects.
|
||||
|
@ -107,10 +111,7 @@ return {
|
|||
|
||||
-- How to run jdtls. This can be overridden to a full java command-line
|
||||
-- if the Python wrapper script doesn't suffice.
|
||||
cmd = {
|
||||
vim.fn.exepath("jdtls"),
|
||||
string.format("--jvm-arg=-javaagent:%s", lombok_jar),
|
||||
},
|
||||
cmd = cmd,
|
||||
full_cmd = function(opts)
|
||||
local fname = vim.api.nvim_buf_get_name(0)
|
||||
local root_dir = opts.root_dir(fname)
|
||||
|
@ -129,6 +130,7 @@ return {
|
|||
|
||||
-- These depend on nvim-dap, but can additionally be disabled by setting false here.
|
||||
dap = { hotcodereplace = "auto", config_overrides = {} },
|
||||
-- Can set this to false to disable main class scan, which is a performance killer for large project
|
||||
dap_main = {},
|
||||
test = true,
|
||||
settings = {
|
||||
|
@ -145,29 +147,30 @@ return {
|
|||
config = function(_, opts)
|
||||
-- Find the extra bundles that should be passed on the jdtls command-line
|
||||
-- if nvim-dap is enabled with java debug/test.
|
||||
local mason_registry = require("mason-registry")
|
||||
local bundles = {} ---@type string[]
|
||||
if opts.dap and LazyVim.has("nvim-dap") and mason_registry.is_installed("java-debug-adapter") then
|
||||
local java_dbg_pkg = mason_registry.get_package("java-debug-adapter")
|
||||
local java_dbg_path = java_dbg_pkg:get_install_path()
|
||||
local jar_patterns = {
|
||||
java_dbg_path .. "/extension/server/com.microsoft.java.debug.plugin-*.jar",
|
||||
}
|
||||
-- java-test also depends on java-debug-adapter.
|
||||
if opts.test and mason_registry.is_installed("java-test") then
|
||||
local java_test_pkg = mason_registry.get_package("java-test")
|
||||
local java_test_path = java_test_pkg:get_install_path()
|
||||
vim.list_extend(jar_patterns, {
|
||||
java_test_path .. "/extension/server/*.jar",
|
||||
})
|
||||
end
|
||||
for _, jar_pattern in ipairs(jar_patterns) do
|
||||
for _, bundle in ipairs(vim.split(vim.fn.glob(jar_pattern), "\n")) do
|
||||
table.insert(bundles, bundle)
|
||||
if LazyVim.has("mason.nvim") then
|
||||
local mason_registry = require("mason-registry")
|
||||
if opts.dap and LazyVim.has("nvim-dap") and mason_registry.is_installed("java-debug-adapter") then
|
||||
local java_dbg_pkg = mason_registry.get_package("java-debug-adapter")
|
||||
local java_dbg_path = java_dbg_pkg:get_install_path()
|
||||
local jar_patterns = {
|
||||
java_dbg_path .. "/extension/server/com.microsoft.java.debug.plugin-*.jar",
|
||||
}
|
||||
-- java-test also depends on java-debug-adapter.
|
||||
if opts.test and mason_registry.is_installed("java-test") then
|
||||
local java_test_pkg = mason_registry.get_package("java-test")
|
||||
local java_test_path = java_test_pkg:get_install_path()
|
||||
vim.list_extend(jar_patterns, {
|
||||
java_test_path .. "/extension/server/*.jar",
|
||||
})
|
||||
end
|
||||
for _, jar_pattern in ipairs(jar_patterns) do
|
||||
for _, bundle in ipairs(vim.split(vim.fn.glob(jar_pattern), "\n")) do
|
||||
table.insert(bundles, bundle)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function attach_jdtls()
|
||||
local fname = vim.api.nvim_buf_get_name(0)
|
||||
|
||||
|
@ -239,40 +242,45 @@ return {
|
|||
},
|
||||
})
|
||||
|
||||
if opts.dap and LazyVim.has("nvim-dap") and mason_registry.is_installed("java-debug-adapter") then
|
||||
-- custom init for Java debugger
|
||||
require("jdtls").setup_dap(opts.dap)
|
||||
require("jdtls.dap").setup_dap_main_class_configs(opts.dap_main)
|
||||
if LazyVim.has("mason.nvim") then
|
||||
local mason_registry = require("mason-registry")
|
||||
if opts.dap and LazyVim.has("nvim-dap") and mason_registry.is_installed("java-debug-adapter") then
|
||||
-- custom init for Java debugger
|
||||
require("jdtls").setup_dap(opts.dap)
|
||||
if opts.dap_main then
|
||||
require("jdtls.dap").setup_dap_main_class_configs(opts.dap_main)
|
||||
end
|
||||
|
||||
-- Java Test require Java debugger to work
|
||||
if opts.test and mason_registry.is_installed("java-test") then
|
||||
-- custom keymaps for Java test runner (not yet compatible with neotest)
|
||||
wk.add({
|
||||
{
|
||||
mode = "n",
|
||||
buffer = args.buf,
|
||||
{ "<leader>t", group = "test" },
|
||||
-- Java Test require Java debugger to work
|
||||
if opts.test and mason_registry.is_installed("java-test") then
|
||||
-- custom keymaps for Java test runner (not yet compatible with neotest)
|
||||
wk.add({
|
||||
{
|
||||
"<leader>tt",
|
||||
function()
|
||||
require("jdtls.dap").test_class({
|
||||
config_overrides = type(opts.test) ~= "boolean" and opts.test.config_overrides or nil,
|
||||
})
|
||||
end,
|
||||
desc = "Run All Test",
|
||||
mode = "n",
|
||||
buffer = args.buf,
|
||||
{ "<leader>t", group = "test" },
|
||||
{
|
||||
"<leader>tt",
|
||||
function()
|
||||
require("jdtls.dap").test_class({
|
||||
config_overrides = type(opts.test) ~= "boolean" and opts.test.config_overrides or nil,
|
||||
})
|
||||
end,
|
||||
desc = "Run All Test",
|
||||
},
|
||||
{
|
||||
"<leader>tr",
|
||||
function()
|
||||
require("jdtls.dap").test_nearest_method({
|
||||
config_overrides = type(opts.test) ~= "boolean" and opts.test.config_overrides or nil,
|
||||
})
|
||||
end,
|
||||
desc = "Run Nearest Test",
|
||||
},
|
||||
{ "<leader>tT", require("jdtls.dap").pick_test, desc = "Run Test" },
|
||||
},
|
||||
{
|
||||
"<leader>tr",
|
||||
function()
|
||||
require("jdtls.dap").test_nearest_method({
|
||||
config_overrides = type(opts.test) ~= "boolean" and opts.test.config_overrides or nil,
|
||||
})
|
||||
end,
|
||||
desc = "Run Nearest Test",
|
||||
},
|
||||
{ "<leader>tT", require("jdtls.dap").pick_test, desc = "Run Test" },
|
||||
},
|
||||
})
|
||||
})
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -104,6 +104,9 @@ return {
|
|||
sign = false,
|
||||
icons = {},
|
||||
},
|
||||
checkbox = {
|
||||
enabled = false,
|
||||
},
|
||||
},
|
||||
ft = { "markdown", "norg", "rmd", "org" },
|
||||
config = function(_, opts)
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
if lazyvim_docs then
|
||||
-- LSP Server to use for Rust.
|
||||
-- Set to "bacon-ls" to use bacon-ls instead of rust-analyzer.
|
||||
-- only for diagnostics. The rest of LSP support will still be
|
||||
-- provided by rust-analyzer.
|
||||
vim.g.lazyvim_rust_diagnostics = "rust-analyzer"
|
||||
end
|
||||
|
||||
local diagnostics = vim.g.lazyvim_rust_diagnostics or "rust-analyzer"
|
||||
|
||||
return {
|
||||
recommended = function()
|
||||
return LazyVim.extras.wants({
|
||||
|
@ -35,7 +45,13 @@ return {
|
|||
{
|
||||
"williamboman/mason.nvim",
|
||||
optional = true,
|
||||
opts = { ensure_installed = { "codelldb" } },
|
||||
opts = function(_, opts)
|
||||
opts.ensure_installed = opts.ensure_installed or {}
|
||||
vim.list_extend(opts.ensure_installed, { "codelldb" })
|
||||
if diagnostics == "bacon-ls" then
|
||||
vim.list_extend(opts.ensure_installed, { "bacon" })
|
||||
end
|
||||
end,
|
||||
},
|
||||
|
||||
{
|
||||
|
@ -62,8 +78,12 @@ return {
|
|||
enable = true,
|
||||
},
|
||||
},
|
||||
-- Add clippy lints for Rust.
|
||||
checkOnSave = true,
|
||||
-- Add clippy lints for Rust if using rust-analyzer
|
||||
checkOnSave = diagnostics == "rust-analyzer",
|
||||
-- Enable diagnostics if using rust-analyzer
|
||||
diagnostics = {
|
||||
enable = diagnostics == "rust-analyzer",
|
||||
},
|
||||
procMacro = {
|
||||
enable = true,
|
||||
ignored = {
|
||||
|
@ -72,11 +92,36 @@ return {
|
|||
["async-recursion"] = { "async_recursion" },
|
||||
},
|
||||
},
|
||||
files = {
|
||||
excludeDirs = {
|
||||
".direnv",
|
||||
".git",
|
||||
".github",
|
||||
".gitlab",
|
||||
"bin",
|
||||
"node_modules",
|
||||
"target",
|
||||
"venv",
|
||||
".venv",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
config = function(_, opts)
|
||||
if LazyVim.has("mason.nvim") then
|
||||
local package_path = require("mason-registry").get_package("codelldb"):get_install_path()
|
||||
local codelldb = package_path .. "/extension/adapter/codelldb"
|
||||
local library_path = package_path .. "/extension/lldb/lib/liblldb.dylib"
|
||||
local uname = io.popen("uname"):read("*l")
|
||||
if uname == "Linux" then
|
||||
library_path = package_path .. "/extension/lldb/lib/liblldb.so"
|
||||
end
|
||||
opts.dap = {
|
||||
adapter = require("rustaceanvim.config").get_codelldb_adapter(codelldb, library_path),
|
||||
}
|
||||
end
|
||||
vim.g.rustaceanvim = vim.tbl_deep_extend("keep", vim.g.rustaceanvim or {}, opts or {})
|
||||
if vim.fn.executable("rust-analyzer") == 0 then
|
||||
LazyVim.error(
|
||||
|
@ -92,6 +137,9 @@ return {
|
|||
"neovim/nvim-lspconfig",
|
||||
opts = {
|
||||
servers = {
|
||||
bacon_ls = {
|
||||
enabled = diagnostics == "bacon-ls",
|
||||
},
|
||||
rust_analyzer = { enabled = false },
|
||||
},
|
||||
},
|
||||
|
|
|
@ -48,7 +48,7 @@ return {
|
|||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = sql_ft,
|
||||
callback = function()
|
||||
if LazyVim.has("nvim-cmp") then
|
||||
if LazyVim.cmp_engine() == "nvim-cmp" then
|
||||
local cmp = require("cmp")
|
||||
|
||||
-- global sources
|
||||
|
@ -130,9 +130,7 @@ return {
|
|||
optional = true,
|
||||
opts = {
|
||||
sources = {
|
||||
completion = {
|
||||
enabled_providers = { "dadbod" },
|
||||
},
|
||||
default = { "dadbod" },
|
||||
providers = {
|
||||
dadbod = { name = "Dadbod", module = "vim_dadbod_completion.blink" },
|
||||
},
|
||||
|
|
|
@ -30,7 +30,7 @@ return {
|
|||
vim.g.vimtex_quickfix_method = vim.fn.executable("pplatex") == 1 and "pplatex" or "latexlog"
|
||||
end,
|
||||
keys = {
|
||||
{ "<localLeader>l", "", desc = "+vimtex" },
|
||||
{ "<localLeader>l", "", desc = "+vimtex", ft = "tex" },
|
||||
},
|
||||
},
|
||||
|
||||
|
|
51
lua/lazyvim/plugins/extras/ui/indent-blankline.lua
Normal file
51
lua/lazyvim/plugins/extras/ui/indent-blankline.lua
Normal file
|
@ -0,0 +1,51 @@
|
|||
return {
|
||||
-- disable snacks indent when indent-blankline is enabled
|
||||
{
|
||||
"snacks.nvim",
|
||||
opts = {
|
||||
indent = { enabled = false },
|
||||
},
|
||||
},
|
||||
{
|
||||
"lukas-reineke/indent-blankline.nvim",
|
||||
event = "LazyFile",
|
||||
opts = function()
|
||||
Snacks.toggle({
|
||||
name = "Indention Guides",
|
||||
get = function()
|
||||
return require("ibl.config").get_config(0).enabled
|
||||
end,
|
||||
set = function(state)
|
||||
require("ibl").setup_buffer(0, { enabled = state })
|
||||
end,
|
||||
}):map("<leader>ug")
|
||||
|
||||
return {
|
||||
indent = {
|
||||
char = "│",
|
||||
tab_char = "│",
|
||||
},
|
||||
scope = { show_start = false, show_end = false },
|
||||
exclude = {
|
||||
filetypes = {
|
||||
"Trouble",
|
||||
"alpha",
|
||||
"dashboard",
|
||||
"help",
|
||||
"lazy",
|
||||
"mason",
|
||||
"neo-tree",
|
||||
"notify",
|
||||
"snacks_dashboard",
|
||||
"snacks_notif",
|
||||
"snacks_terminal",
|
||||
"snacks_win",
|
||||
"toggleterm",
|
||||
"trouble",
|
||||
},
|
||||
},
|
||||
}
|
||||
end,
|
||||
main = "ibl",
|
||||
},
|
||||
}
|
|
@ -1,54 +1,64 @@
|
|||
-- animations
|
||||
return {
|
||||
"echasnovski/mini.animate",
|
||||
recommended = true,
|
||||
event = "VeryLazy",
|
||||
cond = vim.g.neovide == nil,
|
||||
opts = function(_, opts)
|
||||
-- don't use animate when scrolling with the mouse
|
||||
local mouse_scrolled = false
|
||||
for _, scroll in ipairs({ "Up", "Down" }) do
|
||||
local key = "<ScrollWheel" .. scroll .. ">"
|
||||
vim.keymap.set({ "", "i" }, key, function()
|
||||
mouse_scrolled = true
|
||||
return key
|
||||
end, { expr = true })
|
||||
end
|
||||
-- disable snacks scroll when animate is enabled
|
||||
{
|
||||
"snacks.nvim",
|
||||
opts = {
|
||||
scroll = { enabled = false },
|
||||
},
|
||||
},
|
||||
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = "grug-far",
|
||||
callback = function()
|
||||
vim.b.minianimate_disable = true
|
||||
end,
|
||||
})
|
||||
-- setup animate
|
||||
{
|
||||
"echasnovski/mini.animate",
|
||||
event = "VeryLazy",
|
||||
cond = vim.g.neovide == nil,
|
||||
opts = function(_, opts)
|
||||
-- don't use animate when scrolling with the mouse
|
||||
local mouse_scrolled = false
|
||||
for _, scroll in ipairs({ "Up", "Down" }) do
|
||||
local key = "<ScrollWheel" .. scroll .. ">"
|
||||
vim.keymap.set({ "", "i" }, key, function()
|
||||
mouse_scrolled = true
|
||||
return key
|
||||
end, { expr = true })
|
||||
end
|
||||
|
||||
Snacks.toggle({
|
||||
name = "Mini Animate",
|
||||
get = function()
|
||||
return not vim.g.minianimate_disable
|
||||
end,
|
||||
set = function(state)
|
||||
vim.g.minianimate_disable = not state
|
||||
end,
|
||||
}):map("<leader>ua")
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = "grug-far",
|
||||
callback = function()
|
||||
vim.b.minianimate_disable = true
|
||||
end,
|
||||
})
|
||||
|
||||
local animate = require("mini.animate")
|
||||
return vim.tbl_deep_extend("force", opts, {
|
||||
resize = {
|
||||
timing = animate.gen_timing.linear({ duration = 50, unit = "total" }),
|
||||
},
|
||||
scroll = {
|
||||
timing = animate.gen_timing.linear({ duration = 150, unit = "total" }),
|
||||
subscroll = animate.gen_subscroll.equal({
|
||||
predicate = function(total_scroll)
|
||||
if mouse_scrolled then
|
||||
mouse_scrolled = false
|
||||
return false
|
||||
end
|
||||
return total_scroll > 1
|
||||
end,
|
||||
}),
|
||||
},
|
||||
})
|
||||
end,
|
||||
Snacks.toggle({
|
||||
name = "Mini Animate",
|
||||
get = function()
|
||||
return not vim.g.minianimate_disable
|
||||
end,
|
||||
set = function(state)
|
||||
vim.g.minianimate_disable = not state
|
||||
end,
|
||||
}):map("<leader>ua")
|
||||
|
||||
local animate = require("mini.animate")
|
||||
return vim.tbl_deep_extend("force", opts, {
|
||||
resize = {
|
||||
timing = animate.gen_timing.linear({ duration = 50, unit = "total" }),
|
||||
},
|
||||
scroll = {
|
||||
timing = animate.gen_timing.linear({ duration = 150, unit = "total" }),
|
||||
subscroll = animate.gen_subscroll.equal({
|
||||
predicate = function(total_scroll)
|
||||
if mouse_scrolled then
|
||||
mouse_scrolled = false
|
||||
return false
|
||||
end
|
||||
return total_scroll > 1
|
||||
end,
|
||||
}),
|
||||
},
|
||||
})
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ return {
|
|||
"mason",
|
||||
"neo-tree",
|
||||
"notify",
|
||||
"snacks_dashboard",
|
||||
"snacks_notif",
|
||||
"snacks_terminal",
|
||||
"snacks_win",
|
||||
|
@ -33,13 +34,33 @@ return {
|
|||
vim.b.miniindentscope_disable = true
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("User", {
|
||||
pattern = "SnacksDashboardOpened",
|
||||
callback = function(data)
|
||||
vim.b[data.buf].miniindentscope_disable = true
|
||||
end,
|
||||
})
|
||||
end,
|
||||
},
|
||||
|
||||
-- disable inent-blankline scope when mini-indentscope is enabled
|
||||
{
|
||||
"lukas-reineke/indent-blankline.nvim",
|
||||
optional = true,
|
||||
event = "LazyFile",
|
||||
opts = {
|
||||
scope = { enabled = false },
|
||||
},
|
||||
},
|
||||
|
||||
-- disable snacks scroll when mini-indentscope is enabled
|
||||
{
|
||||
"snacks.nvim",
|
||||
opts = {
|
||||
indent = {
|
||||
scope = { enabled = false },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
-- Show context of the current function
|
||||
return {
|
||||
"nvim-treesitter/nvim-treesitter-context",
|
||||
event = "VeryLazy",
|
||||
event = "LazyFile",
|
||||
opts = function()
|
||||
local tsc = require("treesitter-context")
|
||||
Snacks.toggle({
|
||||
|
|
|
@ -19,6 +19,38 @@ local pick_chezmoi = function()
|
|||
},
|
||||
}
|
||||
fzf_lua.fzf_exec(results, opts)
|
||||
elseif LazyVim.pick.picker.name == "snacks" then
|
||||
local results = require("chezmoi.commands").list({
|
||||
args = {
|
||||
"--path-style",
|
||||
"absolute",
|
||||
"--include",
|
||||
"files",
|
||||
"--exclude",
|
||||
"externals",
|
||||
},
|
||||
})
|
||||
local items = {}
|
||||
|
||||
for _, czFile in ipairs(results) do
|
||||
table.insert(items, {
|
||||
text = czFile,
|
||||
file = czFile,
|
||||
})
|
||||
end
|
||||
|
||||
---@type snacks.picker.Config
|
||||
local opts = {
|
||||
items = items,
|
||||
confirm = function(picker, item)
|
||||
picker:close()
|
||||
require("chezmoi.commands").edit({
|
||||
targets = { item.text },
|
||||
args = { "--watch" },
|
||||
})
|
||||
end,
|
||||
}
|
||||
Snacks.picker.pick(opts)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -39,11 +39,12 @@ return {
|
|||
pattern = {
|
||||
[".*/waybar/config"] = "jsonc",
|
||||
[".*/mako/config"] = "dosini",
|
||||
[".*/kitty/.+%.conf"] = "bash",
|
||||
[".*/kitty/.+%.conf"] = "kitty",
|
||||
[".*/hypr/.+%.conf"] = "hyprlang",
|
||||
["%.env%.[%w_.-]+"] = "sh",
|
||||
},
|
||||
})
|
||||
vim.treesitter.language.register("bash", "kitty")
|
||||
|
||||
add("git_config")
|
||||
|
||||
|
|
|
@ -28,14 +28,24 @@ Config.options.change_detection.enabled = false
|
|||
Config.options.defaults.cond = function(plugin)
|
||||
return vim.tbl_contains(enabled, plugin.name) or plugin.vscode
|
||||
end
|
||||
vim.g.snacks_animate = false
|
||||
|
||||
-- Add some vscode specific keymaps
|
||||
vim.api.nvim_create_autocmd("User", {
|
||||
pattern = "LazyVimKeymapsDefaults",
|
||||
callback = function()
|
||||
-- VSCode-specific keymaps for search and navigation
|
||||
vim.keymap.set("n", "<leader><space>", "<cmd>Find<cr>")
|
||||
vim.keymap.set("n", "<leader>/", [[<cmd>lua require('vscode').action('workbench.action.findInFiles')<cr>]])
|
||||
vim.keymap.set("n", "<leader>ss", [[<cmd>lua require('vscode').action('workbench.action.gotoSymbol')<cr>]])
|
||||
|
||||
-- Keep undo/redo lists in sync with VsCode
|
||||
vim.keymap.set("n", "u", "<Cmd>call VSCodeNotify('undo')<CR>")
|
||||
vim.keymap.set("n", "<C-r>", "<Cmd>call VSCodeNotify('redo')<CR>")
|
||||
|
||||
-- Navigate VSCode tabs like lazyvim buffers
|
||||
vim.keymap.set("n", "<S-h>", "<Cmd>call VSCodeNotify('workbench.action.previousEditor')<CR>")
|
||||
vim.keymap.set("n", "<S-l>", "<Cmd>call VSCodeNotify('workbench.action.nextEditor')<CR>")
|
||||
end,
|
||||
})
|
||||
|
||||
|
@ -44,6 +54,20 @@ function LazyVim.terminal()
|
|||
end
|
||||
|
||||
return {
|
||||
{
|
||||
"snacks.nvim",
|
||||
opts = {
|
||||
bigfile = { enabled = false },
|
||||
dashboard = { enabled = false },
|
||||
indent = { enabled = false },
|
||||
input = { enabled = false },
|
||||
notifier = { enabled = false },
|
||||
picker = { enabled = false },
|
||||
quickfile = { enabled = false },
|
||||
scroll = { enabled = false },
|
||||
statuscolumn = { enabled = false },
|
||||
},
|
||||
},
|
||||
{
|
||||
"LazyVim/LazyVim",
|
||||
config = function(_, opts)
|
||||
|
|
|
@ -10,16 +10,6 @@ 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 = "*" },
|
||||
|
@ -27,36 +17,7 @@ return {
|
|||
"folke/snacks.nvim",
|
||||
priority = 1000,
|
||||
lazy = false,
|
||||
opts = function()
|
||||
---@type snacks.Config
|
||||
return {
|
||||
bigfile = { enabled = true },
|
||||
notifier = { enabled = true },
|
||||
quickfile = { enabled = true },
|
||||
statuscolumn = { enabled = false }, -- we set this in options.lua
|
||||
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" },
|
||||
},
|
||||
},
|
||||
},
|
||||
toggle = { map = LazyVim.safe_keymap_set },
|
||||
words = { enabled = true },
|
||||
}
|
||||
end,
|
||||
keys = {
|
||||
{
|
||||
"<leader>un",
|
||||
function()
|
||||
Snacks.notifier.hide()
|
||||
end,
|
||||
desc = "Dismiss All Notifications",
|
||||
},
|
||||
},
|
||||
opts = {},
|
||||
config = function(_, opts)
|
||||
local notify = vim.notify
|
||||
require("snacks").setup(opts)
|
||||
|
|
|
@ -46,10 +46,6 @@ return {
|
|||
codelens = {
|
||||
enabled = false,
|
||||
},
|
||||
-- Enable lsp cursor word highlighting
|
||||
document_highlight = {
|
||||
enabled = true,
|
||||
},
|
||||
-- add any global capabilities here
|
||||
capabilities = {
|
||||
workspace = {
|
||||
|
|
|
@ -105,29 +105,30 @@ return {
|
|||
{ LazyVim.lualine.pretty_path() },
|
||||
},
|
||||
lualine_x = {
|
||||
Snacks.profiler.status(),
|
||||
-- stylua: ignore
|
||||
{
|
||||
function() return require("noice").api.status.command.get() end,
|
||||
cond = function() return package.loaded["noice"] and require("noice").api.status.command.has() end,
|
||||
color = function() return LazyVim.ui.fg("Statement") end,
|
||||
color = function() return { fg = Snacks.util.color("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 = function() return LazyVim.ui.fg("Constant") end,
|
||||
color = function() return { fg = Snacks.util.color("Constant") } end,
|
||||
},
|
||||
-- stylua: ignore
|
||||
{
|
||||
function() return " " .. require("dap").status() end,
|
||||
cond = function() return package.loaded["dap"] and require("dap").status() ~= "" end,
|
||||
color = function() return LazyVim.ui.fg("Debug") end,
|
||||
color = function() return { fg = Snacks.util.color("Debug") } end,
|
||||
},
|
||||
-- stylua: ignore
|
||||
{
|
||||
require("lazy.status").updates,
|
||||
cond = require("lazy.status").has_updates,
|
||||
color = function() return LazyVim.ui.fg("Special") end,
|
||||
color = function() return { fg = Snacks.util.color("Special") } end,
|
||||
},
|
||||
{
|
||||
"diff",
|
||||
|
@ -158,7 +159,7 @@ return {
|
|||
end,
|
||||
},
|
||||
},
|
||||
extensions = { "neo-tree", "lazy" },
|
||||
extensions = { "neo-tree", "lazy", "fzf" },
|
||||
}
|
||||
|
||||
-- do not add trouble symbols if aerial is enabled
|
||||
|
@ -185,50 +186,6 @@ return {
|
|||
end,
|
||||
},
|
||||
|
||||
-- indent guides for Neovim
|
||||
{
|
||||
"lukas-reineke/indent-blankline.nvim",
|
||||
event = "LazyFile",
|
||||
opts = function()
|
||||
Snacks.toggle({
|
||||
name = "Indention Guides",
|
||||
get = function()
|
||||
return require("ibl.config").get_config(0).enabled
|
||||
end,
|
||||
set = function(state)
|
||||
require("ibl").setup_buffer(0, { enabled = state })
|
||||
end,
|
||||
}):map("<leader>ug")
|
||||
|
||||
return {
|
||||
indent = {
|
||||
char = "│",
|
||||
tab_char = "│",
|
||||
},
|
||||
scope = { show_start = false, show_end = false },
|
||||
exclude = {
|
||||
filetypes = {
|
||||
"Trouble",
|
||||
"alpha",
|
||||
"dashboard",
|
||||
"help",
|
||||
"lazy",
|
||||
"mason",
|
||||
"neo-tree",
|
||||
"notify",
|
||||
"snacks_dashboard",
|
||||
"snacks_notif",
|
||||
"snacks_terminal",
|
||||
"snacks_win",
|
||||
"toggleterm",
|
||||
"trouble",
|
||||
},
|
||||
},
|
||||
}
|
||||
end,
|
||||
main = "ibl",
|
||||
},
|
||||
|
||||
-- Highly experimental plugin that completely replaces the UI for messages, cmdline and the popupmenu.
|
||||
{
|
||||
"folke/noice.nvim",
|
||||
|
@ -308,10 +265,32 @@ return {
|
|||
{ "MunifTanjim/nui.nvim", lazy = true },
|
||||
|
||||
{
|
||||
"folke/snacks.nvim",
|
||||
"snacks.nvim",
|
||||
opts = {
|
||||
indent = { enabled = true },
|
||||
input = { enabled = true },
|
||||
notifier = { enabled = true },
|
||||
scope = { enabled = true },
|
||||
scroll = { enabled = true },
|
||||
statuscolumn = { enabled = false }, -- we set this in options.lua
|
||||
toggle = { map = LazyVim.safe_keymap_set },
|
||||
words = { enabled = true },
|
||||
},
|
||||
-- stylua: ignore
|
||||
keys = {
|
||||
{ "<leader>n", function() Snacks.notifier.show_history() end, desc = "Notification History" },
|
||||
{ "<leader>un", function() Snacks.notifier.hide() end, desc = "Dismiss All Notifications" },
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
"snacks.nvim",
|
||||
opts = {
|
||||
dashboard = {
|
||||
preset = {
|
||||
pick = function(cmd, opts)
|
||||
return LazyVim.pick(cmd, opts)()
|
||||
end,
|
||||
header = [[
|
||||
██╗ █████╗ ███████╗██╗ ██╗██╗ ██╗██╗███╗ ███╗ Z
|
||||
██║ ██╔══██╗╚══███╔╝╚██╗ ██╔╝██║ ██║██║████╗ ████║ Z
|
||||
|
|
|
@ -1,5 +1,40 @@
|
|||
-- 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 {
|
||||
|
||||
-- Snacks utils
|
||||
{
|
||||
"snacks.nvim",
|
||||
opts = {
|
||||
bigfile = { enabled = true },
|
||||
quickfile = { enabled = true },
|
||||
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" },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
-- stylua: ignore
|
||||
keys = {
|
||||
{ "<leader>.", function() Snacks.scratch() end, desc = "Toggle Scratch Buffer" },
|
||||
{ "<leader>S", function() Snacks.scratch.select() end, desc = "Select Scratch Buffer" },
|
||||
{ "<leader>dps", function() Snacks.profiler.scratch() end, desc = "Profiler Scratch Buffer" },
|
||||
},
|
||||
},
|
||||
|
||||
-- Session management. This saves your session in the background,
|
||||
-- keeping track of open buffers, window arrangement, and more.
|
||||
-- You can restore sessions when returning through the dashboard.
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
local prios = {
|
||||
["lazyvim.plugins.extras.test.core"] = 1,
|
||||
["lazyvim.plugins.extras.dap.core"] = 1,
|
||||
["lazyvim.plugins.extras.coding.nvim-cmp"] = 2,
|
||||
["lazyvim.plugins.extras.ui.edgy"] = 2,
|
||||
["lazyvim.plugins.extras.lang.typescript"] = 5,
|
||||
["lazyvim.plugins.extras.coding.blink"] = 5,
|
||||
|
|
|
@ -13,6 +13,11 @@ M.actions = {
|
|||
return true
|
||||
end
|
||||
end,
|
||||
snippet_stop = function()
|
||||
if vim.snippet then
|
||||
vim.snippet.stop()
|
||||
end
|
||||
end,
|
||||
}
|
||||
|
||||
---@param actions string[]
|
||||
|
@ -100,20 +105,6 @@ function M.add_missing_snippet_docs(window)
|
|||
end
|
||||
end
|
||||
|
||||
function M.visible()
|
||||
---@module 'blink.cmp'
|
||||
local blink = package.loaded["blink.cmp"]
|
||||
if blink then
|
||||
return blink.windows and blink.windows.autocomplete.win:is_open()
|
||||
end
|
||||
---@module 'cmp'
|
||||
local cmp = package.loaded["cmp"]
|
||||
if cmp then
|
||||
return cmp.core.view:visible()
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
-- This is a better implementation of `cmp.confirm`:
|
||||
-- * check if the completion menu is visible without waiting for running sources
|
||||
-- * create an undo point before confirming
|
||||
|
|
|
@ -13,6 +13,12 @@ M.moved = {
|
|||
ui = {
|
||||
statuscolumn = { "Snacks.statuscolumn" },
|
||||
bufremove = { "Snacks.bufdelete" },
|
||||
fg = {
|
||||
"{ fg = Snacks.util.color(...) }",
|
||||
fn = function(...)
|
||||
return { fg = Snacks.util.color(...) }
|
||||
end,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -33,6 +39,9 @@ function M.decorate(name, mod)
|
|||
if M.moved[name][k] then
|
||||
local to = M.moved[name][k][1]
|
||||
LazyVim.deprecate("LazyVim." .. name .. "." .. k, to)
|
||||
if M.moved[name][k].fn then
|
||||
return M.moved[name][k].fn
|
||||
end
|
||||
local ret = vim.tbl_get(_G, unpack(vim.split(to, ".", { plain = true })))
|
||||
return ret
|
||||
end
|
||||
|
|
|
@ -265,4 +265,13 @@ function M.memoize(fn)
|
|||
end
|
||||
end
|
||||
|
||||
---@return "nvim-cmp" | "blink.cmp"
|
||||
function M.cmp_engine()
|
||||
vim.g.lazyvim_cmp = vim.g.lazyvim_cmp or "auto"
|
||||
if vim.g.lazyvim_cmp == "auto" then
|
||||
return LazyVim.has_extra("coding.nvim-cmp") and "nvim-cmp" or "blink.cmp"
|
||||
end
|
||||
return vim.g.lazyvim_cmp
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
|
@ -17,7 +17,7 @@ function M.status(icon, status)
|
|||
return status() ~= nil
|
||||
end,
|
||||
color = function()
|
||||
return LazyVim.ui.fg(colors[status()] or colors.ok)
|
||||
return { fg = Snacks.util.color(colors[status()] or colors.ok) }
|
||||
end,
|
||||
}
|
||||
end
|
||||
|
@ -157,7 +157,7 @@ function M.root_dir(opts)
|
|||
other = true,
|
||||
icon = " ",
|
||||
color = function()
|
||||
return LazyVim.ui.fg("Special")
|
||||
return { fg = Snacks.util.color("Special") }
|
||||
end,
|
||||
}, opts or {})
|
||||
|
||||
|
|
|
@ -1,47 +1,6 @@
|
|||
---@class lazyvim.util.mini
|
||||
local M = {}
|
||||
|
||||
---@alias Mini.ai.loc {line:number, col:number}
|
||||
---@alias Mini.ai.region {from:Mini.ai.loc, to:Mini.ai.loc}
|
||||
|
||||
-- Mini.ai indent text object
|
||||
-- For "a", it will include the non-whitespace line surrounding the indent block.
|
||||
-- "a" is line-wise, "i" is character-wise.
|
||||
function M.ai_indent(ai_type)
|
||||
local spaces = (" "):rep(vim.o.tabstop)
|
||||
local lines = vim.api.nvim_buf_get_lines(0, 0, -1, false)
|
||||
local indents = {} ---@type {line: number, indent: number, text: string}[]
|
||||
|
||||
for l, line in ipairs(lines) do
|
||||
if not line:find("^%s*$") then
|
||||
indents[#indents + 1] = { line = l, indent = #line:gsub("\t", spaces):match("^%s*"), text = line }
|
||||
end
|
||||
end
|
||||
|
||||
local ret = {} ---@type (Mini.ai.region | {indent: number})[]
|
||||
|
||||
for i = 1, #indents do
|
||||
if i == 1 or indents[i - 1].indent < indents[i].indent then
|
||||
local from, to = i, i
|
||||
for j = i + 1, #indents do
|
||||
if indents[j].indent < indents[i].indent then
|
||||
break
|
||||
end
|
||||
to = j
|
||||
end
|
||||
from = ai_type == "a" and from > 1 and from - 1 or from
|
||||
to = ai_type == "a" and to < #indents and to + 1 or to
|
||||
ret[#ret + 1] = {
|
||||
indent = indents[i].indent,
|
||||
from = { line = indents[from].line, col = ai_type == "a" and 1 or indents[from].indent + 1 },
|
||||
to = { line = indents[to].line, col = #indents[to].text },
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
return ret
|
||||
end
|
||||
|
||||
-- taken from MiniExtra.gen_ai_spec.buffer
|
||||
function M.ai_buffer(ai_type)
|
||||
local start_line, end_line = 1, vim.fn.line("$")
|
||||
|
@ -92,6 +51,7 @@ function M.ai_whichkey(opts)
|
|||
{ "}", desc = "{} with ws" },
|
||||
}
|
||||
|
||||
---@type wk.Spec[]
|
||||
local ret = { mode = { "o", "x" } }
|
||||
---@type table<string, string>
|
||||
local mappings = vim.tbl_extend("force", {}, {
|
||||
|
|
|
@ -42,10 +42,13 @@ function M.register(picker)
|
|||
return true
|
||||
end
|
||||
|
||||
---@return "telescope" | "fzf" | "snacks"
|
||||
function M.want()
|
||||
vim.g.lazyvim_picker = vim.g.lazyvim_picker or "auto"
|
||||
if vim.g.lazyvim_picker == "auto" then
|
||||
return LazyVim.has_extra("editor.fzf") and "fzf" or "telescope"
|
||||
return LazyVim.has_extra("editor.snacks_picker") and "snacks"
|
||||
or LazyVim.has_extra("editor.telescope") and "telescope"
|
||||
or "fzf"
|
||||
end
|
||||
return vim.g.lazyvim_picker
|
||||
end
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
---@class lazyvim.util.root
|
||||
---@overload fun(): string
|
||||
local M = setmetatable({}, {
|
||||
__call = function(m)
|
||||
return m.get()
|
||||
__call = function(m, ...)
|
||||
return m.get(...)
|
||||
end,
|
||||
})
|
||||
|
||||
|
|
|
@ -24,52 +24,4 @@ function M.foldexpr()
|
|||
return vim.b[buf].ts_folds and vim.treesitter.foldexpr() or "0"
|
||||
end
|
||||
|
||||
---@return {fg?:string}?
|
||||
function M.fg(name)
|
||||
local hl = vim.api.nvim_get_hl(0, { name = name, link = false })
|
||||
local fg = hl and hl.fg or hl.foreground
|
||||
return fg and { fg = string.format("#%06x", fg) } or nil
|
||||
end
|
||||
|
||||
function M.maximize()
|
||||
---@type {k:string, v:any}[]?
|
||||
local maximized = nil
|
||||
return Snacks.toggle({
|
||||
name = "Maximize",
|
||||
get = function()
|
||||
return maximized ~= nil
|
||||
end,
|
||||
set = function(state)
|
||||
if state then
|
||||
maximized = {}
|
||||
local function set(k, v)
|
||||
table.insert(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 =")
|
||||
-- `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.set(false)
|
||||
end,
|
||||
})
|
||||
else
|
||||
for _, opt in ipairs(maximized) do
|
||||
vim.o[opt.k] = opt.v
|
||||
end
|
||||
maximized = nil
|
||||
vim.cmd("wincmd =")
|
||||
end
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue