Merge pull request #66 from rudotriton/formatting

formatting with stylua
This commit is contained in:
ThePrimeagen 2021-05-05 14:05:11 -06:00 committed by GitHub
commit c2b7ef3d37
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 47 additions and 50 deletions

5
.stylua.toml Normal file
View File

@ -0,0 +1,5 @@
column_width = 120
line_endings = "Unix"
indent_type = "Spaces"
indent_width = 4
quote_style = "AutoPreferDouble"

View File

@ -6,7 +6,7 @@
local M = {}
M.reload = function()
require("plenary.reload").reload_module("harpoon");
require("plenary.reload").reload_module("harpoon")
end
local function set_log_level()

View File

@ -48,7 +48,7 @@ end
local function merge_tables(...)
log.trace("_merge_tables()")
local out = {}
for i = 1, select("#",...) do
for i = 1, select("#", ...) do
merge_table_impl(out, select(i, ...))
end
return out
@ -61,10 +61,10 @@ local function ensure_correct_config(config)
log.debug("ensure_correct_config(): No config found for:", vim.loop.cwd())
projects[vim.loop.cwd()] = {
mark = {
marks = {}
marks = {},
},
term = {
cmds = {}
cmds = {},
},
}
end
@ -72,12 +72,12 @@ local function ensure_correct_config(config)
local proj = projects[vim.loop.cwd()]
if proj.mark == nil then
log.debug("ensure_correct_config(): No marks found for", vim.loop.cwd())
proj.mark = {marks = {}}
proj.mark = { marks = {} }
end
if proj.term == nil then
log.debug("ensure_correct_config(): No terminal commands found for", vim.loop.cwd())
proj.term = {cmds = {}}
proj.term = { cmds = {} }
end
local marks = proj.mark.marks
@ -85,7 +85,7 @@ local function ensure_correct_config(config)
local mark = marks[idx]
if type(mark) == "string" then
mark = {
filename = mark
filename = mark,
}
marks[idx] = mark
end
@ -144,15 +144,13 @@ M.setup = function(config)
c_config = {}
end
local complete_config =
merge_tables(
{projects = {} , global_settings = {
["save_on_toggle"] = false,
["save_on_change"] = true,
}},
expand_dir(c_config),
expand_dir(u_config),
expand_dir(config))
local complete_config = merge_tables({
projects = {},
global_settings = {
["save_on_toggle"] = false,
["save_on_change"] = true,
},
}, expand_dir(c_config), expand_dir(u_config), expand_dir(config))
-- There was this issue where the vim.loop.cwd() didn't have marks or term, but had
-- an object for vim.loop.cwd()
@ -191,4 +189,3 @@ end
M.setup()
return M

View File

@ -113,10 +113,10 @@ M.get_index_of = function(item)
return
end
if type(item) == 'string' then
if type(item) == "string" then
local relative_item = utils.normalize_path(item)
for idx = 1, M.get_length() do
if M.get_marked_file_name(idx) == relative_item then
if M.get_marked_file_name(idx) == relative_item then
return idx
end
end
@ -171,7 +171,7 @@ M.add_file = function(file_name_or_buf_id)
local found_idx = get_first_empty_slot()
harpoon.get_mark_config().marks[found_idx] = create_mark(buf_name)
M.remove_empty_tail(false)
emit_changed();
emit_changed()
end
-- _emit_on_changed == false should only be used internally
@ -328,7 +328,7 @@ M.toggle_file = function(file_name_or_buf_id)
validate_buf_name(buf_name)
if (mark_exists(buf_name)) then
if mark_exists(buf_name) then
M.rm_file(buf_name)
print("Mark removed")
log.debug("toggle_file(): Mark removed")
@ -356,5 +356,3 @@ M.on = function(event, cb)
end
return M

View File

@ -1,4 +1,4 @@
local harpoon = require('harpoon')
local harpoon = require("harpoon")
local Path = require("plenary.path")
local log = require("harpoon.dev").log
@ -11,7 +11,7 @@ local function create_terminal()
vim.cmd(":terminal")
local buf_id = vim.fn.bufnr()
local term_id = vim.b.terminal_job_id
local term_id = vim.b.terminal_job_id
if term_id == nil then
log.error("_create_terminal(): term_id is nil")
@ -21,7 +21,7 @@ local function create_terminal()
-- Make sure the term buffer has "hidden" set so it doesn't get thrown
-- away and cause an error
vim.api.nvim_buf_set_option(buf_id, 'bufhidden', 'hide')
vim.api.nvim_buf_set_option(buf_id, "bufhidden", "hide")
-- Resets the buffer back to the old one
vim.api.nvim_set_current_buf(current_id)
@ -43,7 +43,7 @@ local function find_terminal(idx)
term_handle = {
buf_id = buf_id,
term_id = term_id
term_id = term_id,
}
terminals[idx] = term_handle
end

View File

@ -1,6 +1,6 @@
local harpoon = require('harpoon')
local popup = require('popup')
local Marked = require('harpoon.mark')
local harpoon = require("harpoon")
local popup = require("popup")
local Marked = require("harpoon.mark")
local log = require("harpoon.dev").log
local M = {}
@ -13,12 +13,12 @@ local function create_window()
local config = harpoon.get_menu_config()
local width = config.width or 60
local height = config.height or 10
local borderchars = config.borderchars or { '', '', '', '', '', '', '', '' }
local borderchars = config.borderchars or { "", "", "", "", "", "", "", "" }
local bufnr = vim.api.nvim_create_buf(false, false)
local Harpoon_win_id, win = popup.create(bufnr, {
title = 'Harpoon',
highlight = 'HarpoonWindow',
title = "Harpoon",
highlight = "HarpoonWindow",
line = math.floor(((vim.o.lines - height) / 2) - 1),
col = math.floor((vim.o.columns - width) / 2),
minwidth = width,
@ -26,7 +26,7 @@ local function create_window()
borderchars = borderchars,
})
vim.api.nvim_win_set_option(win.border.win_id, 'winhl', 'Normal:HarpoonBorder')
vim.api.nvim_win_set_option(win.border.win_id, "winhl", "Normal:HarpoonBorder")
return {
bufnr = bufnr,
@ -40,7 +40,7 @@ local function get_menu_items()
local indices = {}
for idx = 1, #lines do
local space_location = string.find(lines[idx], ' ')
local space_location = string.find(lines[idx], " ")
log.debug("_get_menu_items():", idx, space_location)
if space_location ~= nil then
@ -51,15 +51,13 @@ local function get_menu_items()
return indices
end
M.toggle_quick_menu = function()
log.trace("toggle_quick_menu()")
if Harpoon_win_id ~= nil and vim.api.nvim_win_is_valid(Harpoon_win_id) then
local global_config = harpoon.get_global_settings()
if global_config.save_on_toggle then
require('harpoon.ui').on_menu_save()
require("harpoon.ui").on_menu_save()
end
vim.api.nvim_win_close(Harpoon_win_id, true)
@ -119,14 +117,14 @@ end
function M.location_window(options)
local default_options = {
relative = 'editor',
style = 'minimal',
relative = "editor",
style = "minimal",
width = 30,
height = 15,
row = 2,
col = 2,
}
options = vim.tbl_extend('keep', options, default_options)
options = vim.tbl_extend("keep", options, default_options)
local bufnr = options.bufnr or vim.fn.nvim_create_buf(false, true)
local win_id = vim.fn.nvim_open_win(bufnr, true, options)
@ -147,15 +145,15 @@ function M.notification(text)
width = 20,
height = 2,
row = 1,
col = win_width - 21
col = win_width - 21,
})
vim.api.nvim_buf_set_lines(info.bufnr, 0, 5, false, {"!!! Notification", text})
vim.api.nvim_buf_set_lines(info.bufnr, 0, 5, false, { "!!! Notification", text })
vim.api.nvim_set_current_win(prev_win)
return {
bufnr = info.bufnr,
win_id = info.win_id
win_id = info.win_id,
}
end
@ -168,13 +166,13 @@ M.nav_next = function()
local current_index = Marked.get_current_index()
local number_of_items = Marked.get_length()
if current_index == nil then
if current_index == nil then
current_index = 1
else
current_index = current_index + 1
end
if (current_index > number_of_items) then
if current_index > number_of_items then
current_index = 1
end
M.nav_file(current_index)
@ -185,13 +183,13 @@ M.nav_prev = function()
local current_index = Marked.get_current_index()
local number_of_items = Marked.get_length()
if current_index == nil then
if current_index == nil then
current_index = number_of_items
else
current_index = current_index - 1
end
if (current_index < 1) then
if current_index < 1 then
current_index = number_of_items
end
@ -199,4 +197,3 @@ M.nav_prev = function()
end
return M

View File

@ -5,7 +5,7 @@ local M = {
data_path = data_path,
normalize_path = function(item)
return Path:new(item):make_relative(vim.loop.cwd())
end
end,
}
return M