pojokcodeid.nvim-lazy/lua/custom/plugins/cmdline.lua

162 lines
3.3 KiB
Lua
Raw Normal View History

2023-03-14 09:02:28 +07:00
-- initial gui app
local is_neovide = false
local use_noice = true
2024-04-14 12:13:15 +07:00
-- if vim.g.neovide then
-- is_neovide = true
-- use_noice = false
-- end
2023-03-14 09:02:28 +07:00
vim.opt.lazyredraw = is_neovide
2023-03-03 07:09:50 +07:00
return {
{ "gelguy/wilder.nvim", enabled = not use_noice },
2023-11-30 23:53:17 +07:00
{
"folke/noice.nvim",
2024-03-09 08:06:10 +07:00
lazy = true,
2023-11-30 23:53:17 +07:00
enabled = use_noice,
dependencies = {
{ "MunifTanjim/nui.nvim", enabled = use_noice },
},
2024-04-10 20:34:02 +07:00
-- event = "BufWinEnter",
event = "VeryLazy",
2023-11-30 23:53:17 +07:00
opts = {
messages = {
enabled = false,
},
notify = {
enabled = false,
},
lsp = {
progress = {
enabled = false,
},
hover = {
enabled = false,
},
signature = {
enabled = false,
},
},
},
2024-03-31 16:35:21 +07:00
init = function()
2024-04-04 12:16:40 +07:00
-- load if mode command mode
-- vim.api.nvim_create_autocmd("CmdlineEnter", {
-- callback = function()
-- require("lazy").load({ plugins = { "noice.nvim" } })
-- end,
-- })
-- require("lazy").load({ plugins = { "noice.nvim" } })
2024-03-31 16:35:21 +07:00
end,
2023-11-30 23:53:17 +07:00
keys = {
{
"<S-Enter>",
function()
require("noice").redirect(vim.fn.getcmdline())
end,
mode = "c",
desc = "Redirect Cmdline",
},
{
"<leader>snl",
function()
require("noice").cmd("last")
end,
desc = "Noice Last Message",
},
{
"<leader>snh",
function()
require("noice").cmd("history")
end,
desc = "Noice History",
},
{
"<leader>sna",
function()
require("noice").cmd("all")
end,
desc = "Noice All",
},
{
"<c-f>",
function()
if not require("noice.lsp").scroll(4) then
return "<c-f>"
end
end,
silent = true,
expr = true,
desc = "Scroll forward",
mode = { "i", "n", "s" },
},
{
"<c-b>",
function()
if not require("noice.lsp").scroll(-4) then
return "<c-b>"
end
end,
silent = true,
expr = true,
desc = "Scroll backward",
mode = { "i", "n", "s" },
},
},
},
{
"hrsh7th/cmp-cmdline",
2024-04-10 20:34:02 +07:00
event = "VeryLazy",
2024-04-04 12:16:40 +07:00
enabled = use_noice,
2024-04-08 20:43:52 +07:00
init = function()
-- load if mode command mode
2024-04-10 20:34:02 +07:00
-- vim.api.nvim_create_autocmd("CmdlineEnter", {
-- callback = function()
-- require("lazy").load({ plugins = { "cmp-cmdline" } })
-- end,
-- })
2024-04-08 20:43:52 +07:00
end,
2023-11-30 23:53:17 +07:00
config = function()
local cmp = require("cmp")
local mapping = {
["<CR>"] = cmp.mapping.confirm({ select = true }),
["<Up>"] = cmp.mapping(cmp.mapping.select_prev_item(), { "i", "c" }),
["<S-Tab>"] = cmp.mapping(cmp.mapping.select_prev_item(), { "i", "c" }),
["<Down>"] = cmp.mapping(cmp.mapping.select_next_item(), { "i", "c" }),
["<Tab>"] = cmp.mapping(cmp.mapping.select_next_item(), { "i", "c" }),
}
-- Use buffer source for `/`.
cmp.setup.cmdline("/", {
preselect = "none",
completion = {
completeopt = "menu,preview,menuone,noselect",
},
mapping = mapping,
sources = {
{ name = "buffer" },
},
experimental = {
ghost_text = true,
native_menu = false,
},
})
-- Use cmdline & path source for ':'.
cmp.setup.cmdline(":", {
preselect = "none",
completion = {
completeopt = "menu,preview,menuone,noselect",
},
mapping = mapping,
sources = cmp.config.sources({
{ name = "path" },
}, {
{ name = "cmdline" },
}),
experimental = {
ghost_text = true,
native_menu = false,
},
})
end,
},
2023-03-03 07:09:50 +07:00
}