From 1d65f6a888198d930229f13b47a10c0d3976f5b9 Mon Sep 17 00:00:00 2001 From: Raigo Jerva Date: Mon, 3 May 2021 20:40:52 +0300 Subject: [PATCH] address various comments --- lua/harpoon/init.lua | 4 ++-- lua/harpoon/mark.lua | 4 +++- lua/harpoon/ui.lua | 11 +++-------- 3 files changed, 8 insertions(+), 11 deletions(-) diff --git a/lua/harpoon/init.lua b/lua/harpoon/init.lua index 951f3ea..926ede2 100644 --- a/lua/harpoon/init.lua +++ b/lua/harpoon/init.lua @@ -72,12 +72,12 @@ local function ensure_correct_config(config) local proj = projects[vim.loop.cwd()] if proj.mark == nil then log.trace("ensure_correct_config(): No marks found for", vim.loop.cwd()) - proj.mark = { marks = {} } + proj.mark = {marks = {}} end if proj.term == nil then log.trace("ensure_correct_config(): No terminal commands found for", vim.loop.cwd()) - proj.term = { cmds = {} } + proj.term = {cmds = {}} end local marks = proj.mark.marks diff --git a/lua/harpoon/mark.lua b/lua/harpoon/mark.lua index ba232b0..98b0d98 100644 --- a/lua/harpoon/mark.lua +++ b/lua/harpoon/mark.lua @@ -100,6 +100,7 @@ local function validate_buf_name(buf_name) log.trace("_validate_buf_name():", buf_name) if buf_name == "" or buf_name == nil then log.error("_validate_buf_name(): Not a valid name for a mark,", buf_name) + error("Couldn't find a valid file name to mark, sorry.") return end end @@ -107,7 +108,8 @@ end M.get_index_of = function(item) log.debug("get_index_of():", item) if item == nil then - log.error("get_index_of(): You have provided a nil value to Harpoon, please provide a string rep of the file or the file idx.") + log.error("get_index_of(): Function has been supplied with a nil value.") + error("You have provided a nil value to Harpoon, please provide a string rep of the file or the file idx.") return end diff --git a/lua/harpoon/ui.lua b/lua/harpoon/ui.lua index 4e0e889..f007f12 100644 --- a/lua/harpoon/ui.lua +++ b/lua/harpoon/ui.lua @@ -111,14 +111,9 @@ M.nav_file = function(id) local set_row = not vim.api.nvim_buf_is_loaded(buf_id) vim.api.nvim_set_current_buf(buf_id) - if set_row and mark.row then - local ok, err = pcall(vim.cmd, string.format(":call cursor(%d, %d)", mark.row, mark.col)) - if not ok then - log.warn( - string.format("nav_file(): Could not set cursor to row: %d, col: %d", mark.row, mark.col), - err - ) - end + if set_row and mark.row and mark.col then + vim.cmd(string.format(":call cursor(%d, %d)", mark.row, mark.col)) + log.trace(string.format("nav_file(): Setting cursor to row: %d, col: %d", mark.row, mark.col)) end end