diff --git a/config/nvim/lua/aleidk/options.lua b/config/nvim/lua/aleidk/options.lua index aa543e9..d1fe584 100644 --- a/config/nvim/lua/aleidk/options.lua +++ b/config/nvim/lua/aleidk/options.lua @@ -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 = { diff --git a/config/nvim/lua/aleidk/plugins-base/auto-pairs.lua b/config/nvim/lua/aleidk/plugins-base/auto-pairs.lua index 2355082..883891d 100644 --- a/config/nvim/lua/aleidk/plugins-base/auto-pairs.lua +++ b/config/nvim/lua/aleidk/plugins-base/auto-pairs.lua @@ -1,5 +1,6 @@ return { "windwp/nvim-autopairs", event = "InsertEnter", + config = true, opts = {}, -- this is equalent to setup({}) function } diff --git a/config/nvim/lua/aleidk/plugins-base/comments.lua b/config/nvim/lua/aleidk/plugins-base/comments.lua index 083aaff..edd3413 100644 --- a/config/nvim/lua/aleidk/plugins-base/comments.lua +++ b/config/nvim/lua/aleidk/plugins-base/comments.lua @@ -17,18 +17,12 @@ return { }, { "LudoPinelli/comment-box.nvim", - event = "VeryLazy", - config = function() - require("comment-box").setup({ - 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, + opts = { + outer_blank_lines = true, + }, + 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" }, } }, + }, }, } diff --git a/config/nvim/lua/aleidk/plugins-base/file-explorer.lua b/config/nvim/lua/aleidk/plugins-base/file-explorer.lua index b0dfa3e..2f76b72 100644 --- a/config/nvim/lua/aleidk/plugins-base/file-explorer.lua +++ b/config/nvim/lua/aleidk/plugins-base/file-explorer.lua @@ -1,9 +1,6 @@ ----@type LazySpec return { "mikavilpas/yazi.nvim", - -- event = "VeryLazy", keys = { - -- šŸ‘‡ in this section, choose your own keymappings! { "e", "Yazi", @@ -15,15 +12,7 @@ return { "Yazi cwd", 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 - -- '', - -- "Yazi toggle", - -- 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, diff --git a/config/nvim/lua/aleidk/plugins-base/quickfix.lua b/config/nvim/lua/aleidk/plugins-base/quickfix.lua deleted file mode 100644 index 7ce267a..0000000 --- a/config/nvim/lua/aleidk/plugins-base/quickfix.lua +++ /dev/null @@ -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", "fQ", toggle_qf, "Toggle quickfix") - end, - }, -} diff --git a/config/nvim/lua/aleidk/plugins-base/treesitter.lua b/config/nvim/lua/aleidk/plugins-base/treesitter.lua index 870f442..c0077f4 100644 --- a/config/nvim/lua/aleidk/plugins-base/treesitter.lua +++ b/config/nvim/lua/aleidk/plugins-base/treesitter.lua @@ -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, } diff --git a/config/nvim/lua/aleidk/plugins-core/markdown.lua b/config/nvim/lua/aleidk/plugins-core/markdown.lua index 8a53320..3fc9cbb 100644 --- a/config/nvim/lua/aleidk/plugins-core/markdown.lua +++ b/config/nvim/lua/aleidk/plugins-core/markdown.lua @@ -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", "", "lua vim.lsp.buf.definition()", "Open the link under cursor") - - MAP("n", "zn", "ZkNew { dir = vim.fn.expand('%:p:h'), title = vim.fn.input('Title: ') }", - "Create new note") - MAP("v", "zN", - ":'<,'>ZkNewFromContentSelection { dir = vim.fn.expand('%:p:h'), title = vim.fn.input('Title: ') }", - "Create new note using selection as content") - - MAP("n", "zl", "ZkInsertLink", "Insert Link into cursor position") - MAP("v", "zl", ":'<,'>ZkInsertLinkAtSelection", "Insert Link into selection") - - MAP("n", "zb", "ZkBacklinks", "Backlinks") - MAP("n", "zo", "ZkLinks", "Outlinks") - - MAP("n", "zf", "ZkNotes", "Find note") - MAP("n", "zt", "ZkTags", "Find tags") - end - } } diff --git a/config/nvim/lua/aleidk/plugins-core/telescope.lua b/config/nvim/lua/aleidk/plugins-core/telescope.lua index 5574cdd..48441dc 100644 --- a/config/nvim/lua/aleidk/plugins-core/telescope.lua +++ b/config/nvim/lua/aleidk/plugins-core/telescope.lua @@ -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" }, { diff --git a/config/nvim/lua/aleidk/plugins-core/todo-comments.lua b/config/nvim/lua/aleidk/plugins-core/todo-comments.lua index 33f2372..d9044cd 100644 --- a/config/nvim/lua/aleidk/plugins-core/todo-comments.lua +++ b/config/nvim/lua/aleidk/plugins-core/todo-comments.lua @@ -1,9 +1,8 @@ return { - "folke/todo-comments.nvim", - cmd = { "TodoTrouble", "TodoTelescope" }, - event = { "BufReadPost", "BufNewFile" }, - config = true, - -- stylua: ignore + "folke/todo-comments.nvim", + cmd = { "TodoTrouble", "TodoTelescope" }, + event = { "BufReadPost", "BufNewFile" }, + config = true, 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" },