1
0
Fork 0
znvim/lua/znvim/plugins/editor.lua
2024-12-04 17:32:24 +01:00

283 lines
9.8 KiB
Lua

return {
{ -- use bdelete instead
"https://github.com/famiu/bufdelete.nvim",
config = function()
-- switches to Alpha dashboard when last buffer is closed
local alpha_on_empty = vim.api.nvim_create_augroup("alpha_on_empty", { clear = true })
vim.api.nvim_create_autocmd("User", {
pattern = "BDeletePost*",
group = alpha_on_empty,
callback = function(event)
local fallback_name = vim.api.nvim_buf_get_name(event.buf)
local fallback_ft = vim.api.nvim_buf_get_option(event.buf, "filetype")
local fallback_on_empty = fallback_name == "" and fallback_ft == ""
if fallback_on_empty then
require("neo-tree").close_all()
vim.cmd("Alpha")
vim.cmd(event.buf .. "bwipeout")
end
end,
})
end,
keys = {
{ "<leader>bd", "<CMD>Bdelete<CR>", desc = "delete buffer" },
{ "<leader>bD", "<CMD>Bdelete!<CR>", desc = "delete buffer!" },
},
},
{ -- neo-tree file explorer
"https://github.com/nvim-neo-tree/neo-tree.nvim",
cmd = "Neotree",
keys = {
{ "<leader>fe", "<cmd>Neotree toggle<cr>", desc = "file explorer toggle" },
{
"<leader>ge",
function()
require("neo-tree.command").execute({
source = "git_status",
toggle = true
})
end,
desc = "git explorer",
},
{
"<leader>be",
function()
require("neo-tree.command").execute({
source = "buffers",
toggle = true
})
end,
desc = "buffer explorer",
},
},
dependencies = {
"https://github.com/nvim-lua/plenary.nvim",
"https://github.com/MunifTanjim/nui.nvim",
"https://github.com/kyazdani42/nvim-web-devicons",
},
opts = {
close_if_last_window = true,
filesystem = {
hijack_netrw_behavior = "open_default",
},
},
},
{ -- telescope
"https://github.com/nvim-telescope/telescope.nvim",
cmd = "Telescope",
dependencies = {
"https://github.com/nvim-lua/plenary.nvim",
"https://github.com/nvim-lua/popup.nvim",
"https://github.com/nvim-telescope/telescope-file-browser.nvim", -- @TODO: j and k to moving in or out of directiry
"https://github.com/nvim-telescope/telescope-bibtex.nvim",
"https://github.com/nvim-telescope/telescope-symbols.nvim",
},
keys = {
{ "<leader>tb", "<cmd>Telescope buffers<cr>", desc = "buffers" },
{ "<leader>tfb", "<cmd>Telescope file_browser<cr>", desc = "file browser" },
{ "<leader>tff", "<cmd>Telescope find_files<cr>", desc = "find file" },
{ "<leader>tg", "<cmd>Telescope live_grep<cr>", desc = "grep files" },
{ "<leader>th", "<cmd>Telescope help_tags<cr>", desc = "help" },
{ "<leader>tk", "<cmd>Telescope keymaps<cr>", desc = "key maps" },
{ "<leader>tn", "<cmd>Telescope notify<cr>", desc = "notifications" },
{ "<leader>tss", "<cmd>Telescope symbols<cr>", desc = "symbols" },
{ "<leader>tse", function ()
require(telescope.builtin).symbols{ sources = {"emoji"} }
end,
desc = "emoji"
},
{ "<leader>tsm", function ()
require(telescope.builtin).symbols{ sources = {"math" } }
end,
desc = "math"
},
{ "<leader>tt", "<cmd>Telescope<cr>", desc = "telescope" },
-- git
{ "<leader>gf", "<cmd>Telescope git_files<cr>", desc = "files" },
{ "<leader>gc", "<cmd>Telescope git_commits<cr>", desc = "commits" },
{ "<leader>gst", "<cmd>Telescope git_status<cr>", desc = "status" },
-- buffer
{ "<leader>bf", "<cmd>Telescope buffers<cr>", desc = "find buffer" },
{ "<leader>bs", "<cmd>Telescope current_buffer_fuzzy_find<cr>", desc = "fuzzy search" },
},
opts = {
defaults = {
initial_mode = "normal",
},
extensions = {
bibtex = {
depth = 2,
},
},
pickers = {
colorscheme = {
enable_preview = true,
},
},
},
config = function(_, opts)
local telescope = require("telescope")
telescope.setup(opts)
telescope.load_extension("file_browser")
telescope.load_extension("bibtex")
telescope.load_extension("notify")
end,
},
{ -- a fast motion inside a visible area
"https://github.com/ggandor/leap.nvim",
event = "BufReadPre",
config = function()
local leap = require("leap")
leap.add_default_mappings(true)
end,
},
{ -- bookmark files
"https://github.com/otavioschwanck/arrow.nvim",
event = "BufReadPre",
opts = {
show_icons = true,
leader_key = '<leader>H',
buffer_leader_key = '<leader>h',
}
},
{ -- displays a popup with possible key bindings
"https://github.com/folke/which-key.nvim",
event = "VeryLazy",
dependencies = {
"https://github.com/kyazdani42/nvim-web-devicons",
},
opts = {
preset = "helix",
spec = {
{ "<leader>b", group = "buffer" },
{ "<leader>g", group = "git" },
{ "<leader>gd", group = "diff" },
{ "<leader>gr", group = "reset" },
{ "<leader>gs", group = "stage" },
{ "<leader>gt", group = "toggle" },
{ "<leader>t", group = "telescope" },
{ "<leader>u", group = "ui" },
{ "<leader>x", group = "diagnostics" },
},
},
},
{ -- better diagnostics list and others
"https://github.com/folke/trouble.nvim",
cmd = "Trouble",
keys = {
{
"<leader>xx",
"<cmd>Trouble diagnostics toggle<cr>",
desc = "Diagnostics (Trouble)",
},
{
"<leader>xX",
"<cmd>Trouble diagnostics toggle filter.buf=0<cr>",
desc = "Buffer Diagnostics (Trouble)",
},
{
"<leader>cs",
"<cmd>Trouble symbols toggle focus=false<cr>",
desc = "Symbols (Trouble)",
},
{
"<leader>cl",
"<cmd>Trouble lsp toggle focus=false win.position=right<cr>",
desc = "LSP Definitions / references / ... (Trouble)",
},
{
"<leader>xL",
"<cmd>Trouble loclist toggle<cr>",
desc = "Location List (Trouble)",
},
{
"<leader>xQ",
"<cmd>Trouble qflist toggle<cr>",
desc = "Quickfix List (Trouble)",
},
},
opts = {
use_diagnostic_signs = true,
},
},
{ -- todo comments
"https://github.com/folke/todo-comments.nvim",
dependencies = {
"https://github.com/nvim-lua/plenary.nvim",
},
cmd = { "TodoTrouble", "TodoTelescope" },
event = "BufReadPost",
keys = {
{
"]t",
function()
require("todo-comments").jump_next()
end,
desc = "next todo comment",
},
{
"[t",
function()
require("todo-comments").jump_prev()
end,
desc = "previous todo comment",
},
{
"<leader>xt",
"<cmd>TodoTrouble<cr>",
desc = "todo (trouble)"
},
{
"<leader>xT",
"<cmd>TodoTelescope<cr>",
desc = "todo (telescope)"
},
},
config = true,
},
{ -- better folding
"https://github.com/kevinhwang91/nvim-ufo",
dependencies = {
"https://github.com/kevinhwang91/promise-async",
},
event = "BufReadPost",
keys = {
{
"zR",
function ()
require('ufo').openAllFolds()
end,
desc = "Open all folds"
},
{
"zM",
function ()
require('ufo').closeAllFolds()
end,
desc = "Close all folds"
},
},
config = {
provider_selector = function(bufnr, filetype, buftype)
return {'treesitter', 'indent'}
end
},
},
{ -- rainbow delimiters
"https://gitlab.com/HiPhish/rainbow-delimiters.nvim",
event = "BufReadPost",
},
{ -- show colors
"https://github.com/norcalli/nvim-colorizer.lua",
ft = { "html", "css", "scss", },
keys = {
{
"<leader>uh",
"<CMD>ColorizerToggle<CR>",
desc = "Toggle background colors rendering",
},
},
config = true,
},
}