style: add and apply stylua config

Made it compatible with the .editorconfig already present and didn't
introduce any bells and whistles beyond that. Fixed the typo in
.editorconfig indent_style while I was at it.
This commit is contained in:
Oula Kuuva
2023-02-12 17:34:08 +02:00
committed by okuuva
parent 979b6c82f6
commit fc7c13d755
5 changed files with 134 additions and 140 deletions

View File

@@ -10,7 +10,7 @@ end_of_line = lf
charset = utf-8 charset = utf-8
trim_trailing_whitespace = true trim_trailing_whitespace = true
insert_final_newline = true insert_final_newline = true
indent_style = tabs indent_style = tab
indent_size = 4 indent_size = 4
[*.txt] [*.txt]

View File

@@ -16,8 +16,7 @@ Config = {
local fn = vim.fn local fn = vim.fn
local utils = require("auto-save.utils.data") local utils = require("auto-save.utils.data")
if fn.getbufvar(buf, "&modifiable") == 1 and if fn.getbufvar(buf, "&modifiable") == 1 and utils.not_in(fn.getbufvar(buf, "&filetype"), {}) then
utils.not_in(fn.getbufvar(buf, "&filetype"), {}) then
return true -- met condition(s), can save return true -- met condition(s), can save
end end
return false -- can't save return false -- can't save

View File

@@ -82,20 +82,15 @@ function M.save(buf)
callback("after_saving") callback("after_saving")
api.nvim_echo( api.nvim_echo({
{
{ {
( (
type(cnf.opts.execution_message.message) == "function" type(cnf.opts.execution_message.message) == "function" and cnf.opts.execution_message.message()
and cnf.opts.execution_message.message()
or cnf.opts.execution_message.message or cnf.opts.execution_message.message
), ),
AUTO_SAVE_COLOR, AUTO_SAVE_COLOR,
}, },
}, }, true, {})
true,
{}
)
if cnf.opts.execution_message.cleaning_interval > 0 then if cnf.opts.execution_message.cleaning_interval > 0 then
fn.timer_start(cnf.opts.execution_message.cleaning_interval, function() fn.timer_start(cnf.opts.execution_message.cleaning_interval, function()
cmd([[echon '']]) cmd([[echon '']])
@@ -104,8 +99,7 @@ function M.save(buf)
api.nvim_echo({ api.nvim_echo({
{ {
( (
type(cnf.opts.execution_message.message) == "function" type(cnf.opts.execution_message.message) == "function" and cnf.opts.execution_message.message()
and cnf.opts.execution_message.message()
or cnf.opts.execution_message.message or cnf.opts.execution_message.message
), ),
AUTO_SAVE_COLOR, AUTO_SAVE_COLOR,
@@ -118,9 +112,7 @@ function M.save(buf)
end end
end end
local save_func = ( local save_func = (cnf.opts.debounce_delay > 0 and debounce(M.save, cnf.opts.debounce_delay) or M.save)
cnf.opts.debounce_delay > 0 and debounce(M.save, cnf.opts.debounce_delay) or M.save
)
local function perform_save() local function perform_save()
g.auto_save_abort = false g.auto_save_abort = false
@@ -142,9 +134,7 @@ function M.on()
if cnf.opts.execution_message.dim > 0 then if cnf.opts.execution_message.dim > 0 then
MSG_AREA = colors.get_hl("MsgArea") MSG_AREA = colors.get_hl("MsgArea")
if MSG_AREA.foreground ~= nil then if MSG_AREA.foreground ~= nil then
MSG_AREA.background = ( MSG_AREA.background = (MSG_AREA.background or colors.get_hl("Normal")["background"])
MSG_AREA.background or colors.get_hl("Normal")["background"]
)
local foreground = ( local foreground = (
o.background == "dark" o.background == "dark"
and colors.darken( and colors.darken(

5
stylua.toml Normal file
View File

@@ -0,0 +1,5 @@
line_endings = "Unix"
indent_type = "Tabs"
indent_width = 4
quote_style = "AutoPreferDouble"
call_parentheses = "Always"