neovim plugin cleanup

This commit is contained in:
Alexander Navarro 2024-11-22 13:29:05 -03:00
parent ec617fabc2
commit 4a5a878a7f
9 changed files with 69 additions and 161 deletions

View file

@ -52,6 +52,62 @@ opt.wrap = false -- Disable line wrap
vim.o.sessionoptions = "blank,buffers,curdir,folds,help,tabpages,winsize,winpos,terminal,localoptions"
local fn = vim.fn
-- Quickfix customization
function _G.qftf(info)
local items
local ret = {}
-- The name of item in list is based on the directory of quickfix window.
-- Change the directory for quickfix window make the name of item shorter.
-- It's a good opportunity to change current directory in quickfixtextfunc :)
--
-- local alterBufnr = fn.bufname('#') -- alternative buffer is the buffer before enter qf window
-- local root = getRootByAlterBufnr(alterBufnr)
-- vim.cmd(('noa lcd %s'):format(fn.fnameescape(root)))
--
if info.quickfix == 1 then
items = fn.getqflist({ id = info.id, items = 0 }).items
else
items = fn.getloclist(info.winid, { id = info.id, items = 0 }).items
end
local limit = 31
local fnameFmt1, fnameFmt2 = "%-" .. limit .. "s", "…%." .. (limit - 1) .. "s"
local validFmt = "%s │%5d:%-3d│%s %s"
for i = info.start_idx, info.end_idx do
local e = items[i]
local fname = ""
local str
if e.valid == 1 then
if e.bufnr > 0 then
fname = fn.bufname(e.bufnr)
if fname == "" then
fname = "[No Name]"
else
fname = fname:gsub("^" .. vim.env.HOME, "~")
end
-- char in fname may occur more than 1 width, ignore this issue in order to keep performance
if #fname <= limit then
fname = fnameFmt1:format(fname)
else
fname = fnameFmt2:format(fname:sub(1 - limit))
end
end
local lnum = e.lnum > 99999 and -1 or e.lnum
local col = e.col > 999 and -1 or e.col
local qtype = e.type == "" and "" or " " .. e.type:sub(1, 1):upper()
str = validFmt:format(fname, lnum, col, qtype, e.text)
else
str = e.text
end
table.insert(ret, str)
end
return ret
end
-- TODO: how to customize?
vim.o.qftf = "{info -> v:lua._G.qftf(info)}"
vim.filetype.add({
-- Detect and assign filetype based on the extension of the filename
extension = {

View file

@ -1,5 +1,6 @@
return {
"windwp/nvim-autopairs",
event = "InsertEnter",
config = true,
opts = {}, -- this is equalent to setup({}) function
}

View file

@ -17,18 +17,12 @@ return {
},
{
"LudoPinelli/comment-box.nvim",
event = "VeryLazy",
config = function()
require("comment-box").setup({
opts = {
outer_blank_lines = true,
})
local cb = require("comment-box")
-- left aligned fixed size box with left aligned text
MAP({ "n", "v" }, "gcb", cb.lcbox, "Create a comment box")
-- centered adapted box with centered text
MAP({ "n", "v" }, "gcl", cb.llline, "Create a comment line")
end,
},
keys = {
{ "gcb", function() require("comment-box").lcbox() end, { desc = "Create a comment box", mode = { "n", "v" }, } },
{ "gcl", function() require("comment-box").llline() end, { desc = "Create a comment line", mode = { "n", "v" }, } },
},
},
}

View file

@ -1,9 +1,6 @@
---@type LazySpec
return {
"mikavilpas/yazi.nvim",
-- event = "VeryLazy",
keys = {
-- 👇 in this section, choose your own keymappings!
{
"<leader>e",
"<cmd>Yazi<cr>",
@ -15,15 +12,7 @@ return {
"<cmd>Yazi cwd<cr>",
desc = "Open the file manager in nvim's working directory",
},
-- {
-- -- NOTE: this requires a version of yazi that includes
-- -- https://github.com/sxyazi/yazi/pull/1305 from 2024-07-18
-- '<c-up>',
-- "<cmd>Yazi toggle<cr>",
-- desc = "Resume the last yazi session",
-- },
},
---@type YaziConfig
opts = {
-- if you want to open yazi instead of netrw, see below for more info
open_for_directories = true,

View file

@ -1,89 +0,0 @@
return {
{
"kevinhwang91/nvim-bqf",
event = "VeryLazy",
dependencies = {},
config = function()
local fn = vim.fn
function _G.qftf(info)
local items
local ret = {}
-- The name of item in list is based on the directory of quickfix window.
-- Change the directory for quickfix window make the name of item shorter.
-- It's a good opportunity to change current directory in quickfixtextfunc :)
--
-- local alterBufnr = fn.bufname('#') -- alternative buffer is the buffer before enter qf window
-- local root = getRootByAlterBufnr(alterBufnr)
-- vim.cmd(('noa lcd %s'):format(fn.fnameescape(root)))
--
if info.quickfix == 1 then
items = fn.getqflist({ id = info.id, items = 0 }).items
else
items = fn.getloclist(info.winid, { id = info.id, items = 0 }).items
end
local limit = 31
local fnameFmt1, fnameFmt2 = "%-" .. limit .. "s", "…%." .. (limit - 1) .. "s"
local validFmt = "%s │%5d:%-3d│%s %s"
for i = info.start_idx, info.end_idx do
local e = items[i]
local fname = ""
local str
if e.valid == 1 then
if e.bufnr > 0 then
fname = fn.bufname(e.bufnr)
if fname == "" then
fname = "[No Name]"
else
fname = fname:gsub("^" .. vim.env.HOME, "~")
end
-- char in fname may occur more than 1 width, ignore this issue in order to keep performance
if #fname <= limit then
fname = fnameFmt1:format(fname)
else
fname = fnameFmt2:format(fname:sub(1 - limit))
end
end
local lnum = e.lnum > 99999 and -1 or e.lnum
local col = e.col > 999 and -1 or e.col
local qtype = e.type == "" and "" or " " .. e.type:sub(1, 1):upper()
str = validFmt:format(fname, lnum, col, qtype, e.text)
else
str = e.text
end
table.insert(ret, str)
end
return ret
end
vim.o.qftf = "{info -> v:lua._G.qftf(info)}"
-- Adapt fzf's delimiter in nvim-bqf
require("bqf").setup({
filter = {
fzf = {
extra_opts = { "--bind", "ctrl-o:toggle-all", "--delimiter", "" },
},
},
})
local toggle_qf = function()
local qf_open = false
for _, win in pairs(vim.fn.getwininfo()) do
if win["quickfix"] == 1 then
qf_open = true
end
end
if qf_open == true then
vim.cmd("cclose")
return
end
if not vim.tbl_isempty(vim.fn.getqflist()) then
vim.cmd("copen")
end
end
MAP("n", "<Leader>fQ", toggle_qf, "Toggle quickfix")
end,
},
}

View file

@ -86,17 +86,5 @@ return {
-- Uncoment this line to disable auto folding on file open
vim.cmd("set nofoldenable")
-- TODO: remove this when blade treesitter is added to nvim-treesitter repo
-- Also remove the "config/nvim/after/queries/blade" folder.
local parser_config = require("nvim-treesitter.parsers").get_parser_configs()
parser_config.blade = {
install_info = {
url = "https://github.com/EmranMR/tree-sitter-blade",
files = { "src/parser.c" },
branch = "main",
},
filetype = "blade",
}
end,
}

View file

@ -12,33 +12,4 @@ return {
},
},
},
{
"zk-org/zk-nvim",
config = function()
require("zk").setup({
picker = "select",
})
function MAP(mode, l, r, desc)
vim.keymap.set(mode, l, r, { desc = desc, silent = true })
end
MAP("n", "<CR>", "<Cmd>lua vim.lsp.buf.definition()<CR>", "Open the link under cursor")
MAP("n", "<leader>zn", "<Cmd>ZkNew { dir = vim.fn.expand('%:p:h'), title = vim.fn.input('Title: ') }<CR>",
"Create new note")
MAP("v", "<leader>zN",
":'<,'>ZkNewFromContentSelection { dir = vim.fn.expand('%:p:h'), title = vim.fn.input('Title: ') }<CR>",
"Create new note using selection as content")
MAP("n", "<leader>zl", "<Cmd>ZkInsertLink<CR>", "Insert Link into cursor position")
MAP("v", "<leader>zl", ":'<,'>ZkInsertLinkAtSelection<CR>", "Insert Link into selection")
MAP("n", "<leader>zb", "<Cmd>ZkBacklinks<CR>", "Backlinks")
MAP("n", "<leader>zo", "<Cmd>ZkLinks<CR>", "Outlinks")
MAP("n", "<leader>zf", "<Cmd>ZkNotes<CR>", "Find note")
MAP("n", "<leader>zt", "<Cmd>ZkTags<CR>", "Find tags")
end
}
}

View file

@ -1,8 +1,7 @@
-- Fuzzy Finder (files, lsp, etc)
return {
"nvim-telescope/telescope.nvim",
version = "*",
event = "VeryLazy",
branch = "0.1.x",
dependencies = {
{ "nvim-lua/plenary.nvim" },
{

View file

@ -3,7 +3,6 @@ return {
cmd = { "TodoTrouble", "TodoTelescope" },
event = { "BufReadPost", "BufNewFile" },
config = true,
-- stylua: ignore
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" },