neovim plugin cleanup
This commit is contained in:
parent
ec617fabc2
commit
4a5a878a7f
9 changed files with 69 additions and 161 deletions
|
|
@ -52,6 +52,62 @@ opt.wrap = false -- Disable line wrap
|
||||||
|
|
||||||
vim.o.sessionoptions = "blank,buffers,curdir,folds,help,tabpages,winsize,winpos,terminal,localoptions"
|
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({
|
vim.filetype.add({
|
||||||
-- Detect and assign filetype based on the extension of the filename
|
-- Detect and assign filetype based on the extension of the filename
|
||||||
extension = {
|
extension = {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
return {
|
return {
|
||||||
"windwp/nvim-autopairs",
|
"windwp/nvim-autopairs",
|
||||||
event = "InsertEnter",
|
event = "InsertEnter",
|
||||||
|
config = true,
|
||||||
opts = {}, -- this is equalent to setup({}) function
|
opts = {}, -- this is equalent to setup({}) function
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,18 +17,12 @@ return {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"LudoPinelli/comment-box.nvim",
|
"LudoPinelli/comment-box.nvim",
|
||||||
event = "VeryLazy",
|
opts = {
|
||||||
config = function()
|
|
||||||
require("comment-box").setup({
|
|
||||||
outer_blank_lines = true,
|
outer_blank_lines = true,
|
||||||
})
|
},
|
||||||
|
keys = {
|
||||||
local cb = require("comment-box")
|
{ "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" }, } },
|
||||||
-- 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,
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,6 @@
|
||||||
---@type LazySpec
|
|
||||||
return {
|
return {
|
||||||
"mikavilpas/yazi.nvim",
|
"mikavilpas/yazi.nvim",
|
||||||
-- event = "VeryLazy",
|
|
||||||
keys = {
|
keys = {
|
||||||
-- 👇 in this section, choose your own keymappings!
|
|
||||||
{
|
{
|
||||||
"<leader>e",
|
"<leader>e",
|
||||||
"<cmd>Yazi<cr>",
|
"<cmd>Yazi<cr>",
|
||||||
|
|
@ -15,15 +12,7 @@ return {
|
||||||
"<cmd>Yazi cwd<cr>",
|
"<cmd>Yazi cwd<cr>",
|
||||||
desc = "Open the file manager in nvim's working directory",
|
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 = {
|
opts = {
|
||||||
-- if you want to open yazi instead of netrw, see below for more info
|
-- if you want to open yazi instead of netrw, see below for more info
|
||||||
open_for_directories = true,
|
open_for_directories = true,
|
||||||
|
|
|
||||||
|
|
@ -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,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
@ -86,17 +86,5 @@ return {
|
||||||
|
|
||||||
-- Uncoment this line to disable auto folding on file open
|
-- Uncoment this line to disable auto folding on file open
|
||||||
vim.cmd("set nofoldenable")
|
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,
|
end,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
-- Fuzzy Finder (files, lsp, etc)
|
-- Fuzzy Finder (files, lsp, etc)
|
||||||
return {
|
return {
|
||||||
"nvim-telescope/telescope.nvim",
|
"nvim-telescope/telescope.nvim",
|
||||||
version = "*",
|
branch = "0.1.x",
|
||||||
event = "VeryLazy",
|
|
||||||
dependencies = {
|
dependencies = {
|
||||||
{ "nvim-lua/plenary.nvim" },
|
{ "nvim-lua/plenary.nvim" },
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ return {
|
||||||
cmd = { "TodoTrouble", "TodoTelescope" },
|
cmd = { "TodoTrouble", "TodoTelescope" },
|
||||||
event = { "BufReadPost", "BufNewFile" },
|
event = { "BufReadPost", "BufNewFile" },
|
||||||
config = true,
|
config = true,
|
||||||
-- stylua: ignore
|
|
||||||
keys = {
|
keys = {
|
||||||
{ "]t", function() require("todo-comments").jump_next() end, desc = "Next todo comment" },
|
{ "]t", function() require("todo-comments").jump_next() end, desc = "Next todo comment" },
|
||||||
{ "[t", function() require("todo-comments").jump_prev() end, desc = "Previous todo comment" },
|
{ "[t", function() require("todo-comments").jump_prev() end, desc = "Previous todo comment" },
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue