Merge branch 'main' into lang/typst

This commit is contained in:
Võ Quang Chiến 2025-02-04 16:35:16 +07:00 committed by GitHub
commit c2fc1aa37d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
25 changed files with 605 additions and 53 deletions

View file

@ -4,6 +4,7 @@ return {
{
"Exafunction/codeium.nvim",
cmd = "Codeium",
event = "InsertEnter",
build = ":Codeium Auth",
opts = {
enable_cmp_source = vim.g.ai_cmp,

View file

@ -5,11 +5,12 @@ return {
"zbirenbaum/copilot.lua",
cmd = "Copilot",
build = ":Copilot auth",
event = "InsertEnter",
event = "BufReadPost",
opts = {
suggestion = {
enabled = not vim.g.ai_cmp,
auto_trigger = true,
hide_during_completion = vim.g.ai_cmp,
keymap = {
accept = false, -- handled by nvim-cmp / blink.cmp
next = "<M-]>",

View file

@ -1,6 +1,11 @@
return {
{
"supermaven-inc/supermaven-nvim",
event = "InsertEnter",
cmd = {
"SupermavenUseFree",
"SupermavenUsePro",
},
opts = {
keymaps = {
accept_suggestion = nil, -- handled by nvim-cmp / blink.cmp

View file

@ -118,17 +118,6 @@ return {
end
end
--- NOTE: compat with latest version. Currenlty 0.7.6
if not vim.g.lazyvim_blink_main then
---@diagnostic disable-next-line: inject-field
opts.sources.completion = opts.sources.completion or {}
opts.sources.completion.enabled_providers = enabled
if vim.tbl_get(opts, "completion", "menu", "draw", "treesitter") then
---@diagnostic disable-next-line: assign-type-mismatch
opts.completion.menu.draw.treesitter = true
end
end
-- Unset custom prop to pass blink.cmp validation
opts.sources.compat = nil
@ -169,9 +158,7 @@ return {
"saghen/blink.cmp",
opts = function(_, opts)
opts.appearance = opts.appearance or {}
opts.appearance.kind_icons = vim.tbl_extend("keep", {
Color = "██", -- Use block instead of icon for color items to make swatches more usable
}, LazyVim.config.icons.kinds)
opts.appearance.kind_icons = vim.tbl_extend("force", opts.appearance.kind_icons or {}, LazyVim.config.icons.kinds)
end,
},

View file

@ -30,7 +30,9 @@ return {
opts = function()
LazyVim.cmp.actions.snippet_forward = function()
if require("luasnip").jumpable(1) then
require("luasnip").jump(1)
vim.schedule(function()
require("luasnip").jump(1)
end)
return true
end
end
@ -67,25 +69,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",
},
},
},

View 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 = "Manage and expand snippets (alternative to 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,
},
}

View file

@ -140,6 +140,11 @@ return {
}),
},
markdown = {
augend.constant.new({
elements = { "[ ]", "[x]" },
word = false,
cyclic = true,
}),
augend.misc.alias.markdown_header,
},
json = {

View file

@ -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, {

View file

@ -0,0 +1,25 @@
return {
{ "nvim-neo-tree/neo-tree.nvim", enabled = false },
{
"folke/snacks.nvim",
opts = { explorer = {} },
keys = {
{
"<leader>fe",
function()
Snacks.explorer({ cwd = LazyVim.root() })
end,
desc = "Explorer Snacks (root dir)",
},
{
"<leader>fE",
function()
Snacks.explorer()
end,
desc = "Explorer Snacks (cwd)",
},
{ "<leader>e", "<leader>fe", desc = "Explorer Snacks (root dir)", remap = true },
{ "<leader>E", "<leader>fE", desc = "Explorer Snacks (cwd)", remap = true },
},
},
}

View file

@ -0,0 +1,201 @@
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)" },
{ "<leader>n", function() Snacks.picker.notifications() end, desc = "Notification History" },
-- 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", function() Snacks.picker.recent({ filter = { cwd = true }}) end, 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 = {
trouble_open = function(...)
return require("trouble.sources.snacks").actions.trouble_open.action(...)
end,
},
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" },
},
},
{
"folke/flash.nvim",
optional = true,
specs = {
{
"folke/snacks.nvim",
opts = {
picker = {
win = {
input = {
keys = {
["<a-s>"] = { "flash", mode = { "n", "i" } },
["s"] = { "flash" },
},
},
},
actions = {
flash = function(picker)
require("flash").jump({
pattern = "^",
label = { after = { 0, 0 } },
search = {
mode = "search",
exclude = {
function(win)
return vim.bo[vim.api.nvim_win_get_buf(win)].filetype ~= "snacks_picker_list"
end,
},
},
action = function(match)
local idx = picker.list:row2idx(match.pos[1])
picker.list:_move(idx, true, true)
end,
})
end,
},
},
},
},
},
},
}

View file

@ -130,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 = {
@ -246,7 +247,9 @@ 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 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

View file

@ -104,8 +104,11 @@ return {
sign = false,
icons = {},
},
checkbox = {
enabled = false,
},
},
ft = { "markdown", "norg", "rmd", "org" },
ft = { "markdown", "norg", "rmd", "org", "codecompanion" },
config = function(_, opts)
require("render-markdown").setup(opts)
Snacks.toggle({

View file

@ -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

View file

@ -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

View file

@ -57,9 +57,14 @@ return {
{
"snacks.nvim",
opts = {
bigfile = { enabled = false },
dashboard = { enabled = false },
indent = { enabled = false },
scroll = { enabled = false },
input = { enabled = false },
notifier = { enabled = false },
picker = { enabled = false },
quickfile = { enabled = false },
scroll = { enabled = false },
statuscolumn = { enabled = false },
},
},