Skip to content

Commit

Permalink
chore: add formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
CWood-sdf committed Nov 28, 2024
1 parent 7e20fc7 commit ff56d7a
Show file tree
Hide file tree
Showing 16 changed files with 581 additions and 383 deletions.
168 changes: 168 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
[*.lua]
# [basic]

# optional space/tab
indent_style = space
# if indent_style is space, this is valid
indent_size = 4
# if indent_style is tab, this is valid
tab_width = 4
# none/single/double
quote_style = double

# continuation_indent = 4
## extend option
# continuation_indent.before_block = 4
# continuation_indent.in_expr = 4
# continuation_indent.in_table = 4

# this mean utf8 length , if this is 'unset' then the line width is no longer checked
# this option decides when to chopdown the code
max_line_length = 80

# optional crlf/lf/cr/auto, if it is 'auto', in windows it is crlf other platforms are lf
# in neovim the value 'auto' is not a valid option, please use 'unset'
end_of_line = lf

# none/ comma / semicolon / only_kv_colon
table_separator_style = none

#optional keep/never/always/smart
trailing_table_separator = keep

# keep/remove/remove_table_only/remove_string_only
call_arg_parentheses = keep

detect_end_of_line = false

# this will check text end with new line
insert_final_newline = true

# [space]
space_around_table_field_list = true

space_before_attribute = true

space_before_function_open_parenthesis = false

space_before_function_call_open_parenthesis = false

space_before_closure_open_parenthesis = true

# optional always/only_string/only_table/none
# or true/false
space_before_function_call_single_arg = always
## extend option
## always/keep/none
# space_before_function_call_single_arg.table = always
## always/keep/none
# space_before_function_call_single_arg.string = always

space_before_open_square_bracket = false

space_inside_function_call_parentheses = false

space_inside_function_param_list_parentheses = false

space_inside_square_brackets = false

# like t[#t+1] = 1
space_around_table_append_operator = true

ignore_spaces_inside_function_call = false

# detail number or 'keep'
space_before_inline_comment = 1

# convert '---' to '--- ' or '--' to '-- '
space_after_comment_dash = false

# [operator space]
space_around_math_operator = true
# space_around_math_operator.exponent = false

space_after_comma = true

space_after_comma_in_for_statement = true

# true/false or none/always/no_space_asym
space_around_concat_operator = true

space_around_logical_operator = true

# true/false or none/always/no_space_asym
space_around_assign_operator = true

# [align]

align_call_args = false

align_function_params = true

align_continuous_assign_statement = true

align_continuous_rect_table_field = true

align_continuous_line_space = 2

align_if_branch = false

# option none / always / contain_curly/
align_array_table = true

align_continuous_similar_call_args = false

align_continuous_inline_comment = true
# option none / always / only_call_stmt
align_chain_expr = always

# [indent]

never_indent_before_if_condition = false

never_indent_comment_on_if_branch = false

keep_indents_on_empty_lines = false

allow_non_indented_comments = false
# [line space]

# The following configuration supports four expressions
# keep
# fixed(n)
# min(n)
# max(n)
# for eg. min(2)

line_space_after_if_statement = keep

line_space_after_do_statement = keep

line_space_after_while_statement = keep

line_space_after_repeat_statement = keep

line_space_after_for_statement = keep

line_space_after_local_or_assign_statement = keep

line_space_after_function_statement = fixed(2)

line_space_after_expression_statement = keep

line_space_after_comment = keep

line_space_around_block = fixed(1)
# [line break]
break_all_list_when_line_exceed = false

auto_collapse_lines = false

break_before_braces = false

# [preference]
ignore_space_after_colon = false

remove_call_expression_list_finish_comma = false
# keep / always / same_line / replace_with_newline / never
end_statement_with_semicolon = never
20 changes: 11 additions & 9 deletions lua/spaceport/data.lua
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,11 @@ function M.refreshData()
table.insert(pinnedData, insert)
end
end
table.sort(data, function(a, b)
table.sort(data, function (a, b)
return a.time > b.time
end)

table.sort(pinnedData, function(a, b)
table.sort(pinnedData, function (a, b)
return a.pinNumber < b.pinNumber
end)
end
Expand All @@ -224,7 +224,7 @@ function M.getAllData()
for _, v in pairs(pinnedData) do
table.insert(ret, v)
end
table.sort(ret, function(a, b)
table.sort(ret, function (a, b)
return a.time > b.time
end)
return ret
Expand Down Expand Up @@ -300,7 +300,7 @@ function M.useWindowName()
return
end
vim.fn.jobstart({ "tmux", "rename-window", currentDir.tmuxWindowName }, {
on_exit = function()
on_exit = function ()
end,
})
end
Expand All @@ -316,7 +316,7 @@ function M.useSessionName()
return
end
vim.fn.jobstart({ "tmux", "rename-session", currentDir.tmuxSessionName }, {
on_exit = function()
on_exit = function ()
end,
})
end
Expand All @@ -331,7 +331,7 @@ function M.tmuxSplitWindowDown()
return
end
vim.fn.jobstart({ "tmux", "split-window", "-c" .. currentDir.dir }, {
on_exit = function()
on_exit = function ()
end,
})
end
Expand All @@ -346,7 +346,7 @@ function M.tmuxSplitWindowLeft()
return
end
vim.fn.jobstart({ "tmux", "split-window", "-h", "-c" .. currentDir.dir }, {
on_exit = function()
on_exit = function ()
end,
})
end
Expand Down Expand Up @@ -405,7 +405,8 @@ function M.cd(dir)
local answer = vim.fn.input(
"It seems like "
.. dir.dir
.. " does not exist anymore, would you like it to be removed from spaceport? (y/n):"
..
" does not exist anymore, would you like it to be removed from spaceport? (y/n):"
)
if answer == "y" then
M.removeDir(dir.dir)
Expand All @@ -431,7 +432,8 @@ function M.cd(dir)
local answer = vim.fn.input(
"It seems like "
.. dir.dir
.. " does not exist anymore, would you like it to be removed from spaceport? (y/n):"
..
" does not exist anymore, would you like it to be removed from spaceport? (y/n):"
)
if answer == "y" then
M.removeDir(dir.dir)
Expand Down
19 changes: 16 additions & 3 deletions lua/spaceport/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ local function cleanLog()
end
local log = vim.fn.readfile(logFile)
for i = 1, #log do
local num = vim.fn.strptime("%Y-%m-%d~%H:%M:%S", vim.fn.split(log[i], " ")[1])
local num = vim.fn.strptime("%Y-%m-%d~%H:%M:%S",
vim.fn.split(log[i], " ")[1])
if not num then
table.remove(log, i)
elseif num < vim.fn.localtime() - opts.logPreserveHrs * 60 then
Expand Down Expand Up @@ -92,7 +93,7 @@ function M.setup(_opts)
end
opts.logPath = vim.fn.fnamemodify(opts.logPath, ":p") or ""
require("spaceport.setup_auto")
vim.schedule(function()
vim.schedule(function ()
cleanLog()
end)
end
Expand Down Expand Up @@ -187,7 +188,19 @@ end
---@return string
---@param icon string
function M._getIcon(icon)
local defaultIcons = { file = "", dir = "", remaps = "", pinned = "", today = "", yesterday = "", week = "", month = "", long = "", news = "󱀄 " }
local defaultIcons = {
file = "",
dir = "",
remaps = "",
pinned = "",
today =
"",
yesterday = "",
week = "",
month = "",
long = "",
news = "󱀄 "
}
if type(opts.icons) == "table" then
return opts.icons[icon] or defaultIcons[icon] or ""
elseif opts.icons then
Expand Down
Loading

0 comments on commit ff56d7a

Please sign in to comment.