From 574a6422044629510e3492296728a9b5932d1c52 Mon Sep 17 00:00:00 2001 From: mpaulson Date: Thu, 30 Nov 2023 20:14:10 -0700 Subject: [PATCH] chore: style --- lua/harpoon/autocmd.lua | 2 -- lua/harpoon/buffer.lua | 23 +++++++++++------------ lua/harpoon/config.lua | 7 +++++-- lua/harpoon/data.lua | 1 - lua/harpoon/init.lua | 3 --- lua/harpoon/test/ui_spec.lua | 4 +--- lua/harpoon/ui.lua | 5 ++++- lua/harpoon/utils.lua | 1 - 8 files changed, 21 insertions(+), 25 deletions(-) diff --git a/lua/harpoon/autocmd.lua b/lua/harpoon/autocmd.lua index de76e21..5aa24ce 100644 --- a/lua/harpoon/autocmd.lua +++ b/lua/harpoon/autocmd.lua @@ -1,4 +1,2 @@ local augroup = vim.api.nvim_create_augroup return augroup("Harpoon", {}) - - diff --git a/lua/harpoon/buffer.lua b/lua/harpoon/buffer.lua index 1c6f623..c224594 100644 --- a/lua/harpoon/buffer.lua +++ b/lua/harpoon/buffer.lua @@ -21,16 +21,15 @@ end ---@param bufnr number function M.setup_autocmds_and_keymaps(bufnr) local curr_file = vim.api.nvim_buf_get_name(0) - local cmd = - string.format( - "autocmd Filetype harpoon " - .. "let path = '%s' | call clearmatches() | " - -- move the cursor to the line containing the current filename - .. "call search('\\V'.path.'\\$') | " - -- add a hl group to that line - .. "call matchadd('HarpoonCurrentFile', '\\V'.path.'\\$')", - curr_file:gsub("\\", "\\\\") - ) + local cmd = string.format( + "autocmd Filetype harpoon " + .. "let path = '%s' | call clearmatches() | " + -- move the cursor to the line containing the current filename + .. "call search('\\V'.path.'\\$') | " + -- add a hl group to that line + .. "call matchadd('HarpoonCurrentFile', '\\V'.path.'\\$')", + curr_file:gsub("\\", "\\\\") + ) vim.cmd(cmd) if vim.api.nvim_buf_get_name(bufnr) == "" then @@ -90,7 +89,7 @@ function M.setup_autocmds_and_keymaps(bufnr) vim.schedule(function() require("harpoon").ui:toggle_quick_menu() end) - end + end, }) vim.api.nvim_create_autocmd({ "BufLeave" }, { @@ -98,7 +97,7 @@ function M.setup_autocmds_and_keymaps(bufnr) pattern = "__harpoon*", callback = function() require("harpoon").ui:toggle_quick_menu() - end + end, }) end diff --git a/lua/harpoon/config.lua b/lua/harpoon/config.lua index 09f744b..bfb1d48 100644 --- a/lua/harpoon/config.lua +++ b/lua/harpoon/config.lua @@ -3,7 +3,6 @@ local function normalize_path(buf_name) return Path:new(buf_name):make_relative(vim.loop.cwd()) end - local M = {} ---@alias HarpoonListItem {value: any, context: any} @@ -133,7 +132,11 @@ function M.get_default_config() -- path, if that is the case we can use the context to -- store the bufname and then have value be the normalized -- value - or normalize_path(vim.api.nvim_buf_get_name(vim.api.nvim_get_current_buf())) + or normalize_path( + vim.api.nvim_buf_get_name( + vim.api.nvim_get_current_buf() + ) + ) local bufnr = vim.fn.bufnr(name, false) diff --git a/lua/harpoon/data.lua b/lua/harpoon/data.lua index a031b7e..9653564 100644 --- a/lua/harpoon/data.lua +++ b/lua/harpoon/data.lua @@ -26,7 +26,6 @@ function M.set_data_path(path) end local function has_keys(t) - -- luacheck: ignore 512 for _ in pairs(t) do return true diff --git a/lua/harpoon/init.lua b/lua/harpoon/init.lua index 12ed810..7a9db74 100644 --- a/lua/harpoon/init.lua +++ b/lua/harpoon/init.lua @@ -50,7 +50,6 @@ function Harpoon:setup(partial_config) ---TODO: should we go through every seen list and update its config? if self.hooks_setup == false then - vim.api.nvim_create_autocmd({ "BufLeave", "VimLeavePre" }, { group = HarpoonGroup, pattern = "*", @@ -145,5 +144,3 @@ function Harpoon:__debug_reset() end return Harpoon:new() - - diff --git a/lua/harpoon/test/ui_spec.lua b/lua/harpoon/test/ui_spec.lua index ed9ba76..db84591 100644 --- a/lua/harpoon/test/ui_spec.lua +++ b/lua/harpoon/test/ui_spec.lua @@ -72,7 +72,6 @@ describe("harpoon", function() eq(list:length(), 3) eq(created_files, list:display()) - end) it("using :q to leave harpoon should quit everything", function() @@ -85,12 +84,11 @@ describe("harpoon", function() eq(vim.api.nvim_win_is_valid(win_id), true) eq(vim.api.nvim_get_current_buf(), bufnr) - vim.cmd [[ q! ]] -- TODO: I shouldn't need q! here + vim.cmd([[ q! ]]) -- TODO: I shouldn't need q! here eq(vim.api.nvim_buf_is_valid(bufnr), false) eq(vim.api.nvim_win_is_valid(win_id), false) eq(harpoon.ui.bufnr, nil) eq(harpoon.ui.win_id, nil) end) - end) diff --git a/lua/harpoon/ui.lua b/lua/harpoon/ui.lua index 6e42709..76fcaa6 100644 --- a/lua/harpoon/ui.lua +++ b/lua/harpoon/ui.lua @@ -39,7 +39,10 @@ function HarpoonUI:close_menu() vim.api.nvim_win_close(self.win_id, true) end - if self.border_win_id ~= nil and vim.api.nvim_win_is_valid(self.border_win_id) then + if + self.border_win_id ~= nil + and vim.api.nvim_win_is_valid(self.border_win_id) + then vim.api.nvim_win_close(self.border_win_id, true) end diff --git a/lua/harpoon/utils.lua b/lua/harpoon/utils.lua index 61dcb44..5660f63 100644 --- a/lua/harpoon/utils.lua +++ b/lua/harpoon/utils.lua @@ -1,4 +1,3 @@ - local M = {} function M.is_white_space(str)