diff --git a/nvim/after/plugin/keymap.vim b/nvim/after/plugin/keymap.vim index 3c54691..88fdcc0 100644 --- a/nvim/after/plugin/keymap.vim +++ b/nvim/after/plugin/keymap.vim @@ -216,17 +216,16 @@ nnoremap o :w %bd e# bd# nnoremap ; q:A " Simply run a make command -nnoremap m :Telescope marks nnoremap md :delmarks! :delmarks A-Z :lua require("utils.marks").refresh() -nnoremap mo mO :lua require("utils.marks").refresh() nnoremap `N nnoremap `E nnoremap `I nnoremap `O -nnoremap n mN :lua require("utils.marks").refresh() -nnoremap e mE :lua require("utils.marks").refresh() -nnoremap i mI :lua require("utils.marks").refresh() -nnoremap o mO :lua require("utils.marks").refresh() +nnoremap m :lua require("utils.marks").marks_to_quickfix_list() +nnoremap n mN :lua require("utils.marks").refresh() +nnoremap e mE :lua require("utils.marks").refresh() +nnoremap i mI :lua require("utils.marks").refresh() +nnoremap o mO :lua require("utils.marks").refresh() nnoremap mn mN :lua require("utils.marks").refresh() nnoremap me mE :lua require("utils.marks").refresh() nnoremap mi mI :lua require("utils.marks").refresh() diff --git a/nvim/lua/plugins/qf_helper.lua b/nvim/lua/plugins/qf_helper.lua index d84c4b2..e256267 100644 --- a/nvim/lua/plugins/qf_helper.lua +++ b/nvim/lua/plugins/qf_helper.lua @@ -3,6 +3,15 @@ return { "stevearc/qf_helper.nvim", event = "VeryLazy", config = function() - require("qf_helper").setup {} + require("qf_helper").setup { + quickfix = { + autoclose = true, -- Autoclose qf if it's the only open window + default_bindings = true, -- Set up recommended bindings in qf window + default_options = true, -- Set recommended buffer and window options + max_height = 10, -- Max qf height when using open() or toggle() + min_height = 1, -- Min qf height when using open() or toggle() + track_location = false, -- Keep qf updated with your current location + }, + } end, } diff --git a/nvim/lua/utils/init.lua b/nvim/lua/utils/init.lua index 81cf616..46a5bb7 100644 --- a/nvim/lua/utils/init.lua +++ b/nvim/lua/utils/init.lua @@ -54,10 +54,10 @@ function M.cheatSheetCommand(detect_language) local command = "" if searchPhrase == nil then - command = language + command = language else - command = language .. "/" .. searchPhrase - end + command = language .. "/" .. searchPhrase + end M.info("cht.sh/" .. command, "Cheat Sheet Query") return ("!curl -s cht.sh/" .. command) diff --git a/nvim/lua/utils/marks.lua b/nvim/lua/utils/marks.lua index ef792d3..bbca96f 100644 --- a/nvim/lua/utils/marks.lua +++ b/nvim/lua/utils/marks.lua @@ -17,7 +17,9 @@ end local function is_lower(char) return (97 <= char:byte() and char:byte() <= 122) end - +local function path_exists(path) + return vim.loop.fs_stat(path) and true or false +end local function define_sign(name) if is_upper(name) then vim.fn.sign_define(name, { @@ -68,6 +70,33 @@ local function add_local_marks() end end +function M.marks_to_quickfix_list() + local global_marks = { + items = vim.fn.getmarklist(), + name_func = function(mark, _) + -- get buffer name if it is opened, otherwise get file name + return vim.api.nvim_get_mark(mark, {})[4] + end, + } + local marks_table = {} + for _, v in ipairs(global_marks.items) do + -- strip the first single quote character + local mark_name = string.sub(v.mark, 2, 3) + local _, lnum, col, _ = unpack(v.pos) + local row = { + text = mark_name, + filename = vim.fs.normalize(v.file), + lnum = lnum, + col = col, + } + if string.find("NEIO", mark_name) and path_exists(row.filename) then + table.insert(marks_table, row) + end + end + vim.fn.setqflist({}, " ", { title = "Bookmarks", id = "$", items = marks_table }) + vim.cmd [[QFToggle]] +end + function M.setup(user_config) if not user_config then config = Defaults