summaryrefslogtreecommitdiff
path: root/lua/lv-formatter/init.lua
diff options
context:
space:
mode:
authorchristianchiarulli <[email protected]>2021-07-12 21:11:43 -0400
committerchristianchiarulli <[email protected]>2021-07-12 21:11:43 -0400
commit2423fcdc904ec1413edaaac1fd8b9c0971f4a869 (patch)
tree388a51b436b364009dc83e301270657f40d8212a /lua/lv-formatter/init.lua
parent476f7bb22f1d6d696ad9c2e2cc6e574167aef841 (diff)
refactor single file
Diffstat (limited to 'lua/lv-formatter/init.lua')
-rw-r--r--lua/lv-formatter/init.lua61
1 files changed, 0 insertions, 61 deletions
diff --git a/lua/lv-formatter/init.lua b/lua/lv-formatter/init.lua
deleted file mode 100644
index ad40dd21..00000000
--- a/lua/lv-formatter/init.lua
+++ /dev/null
@@ -1,61 +0,0 @@
--- autoformat
-if O.format_on_save then
- require("lv-utils").define_augroups {
- autoformat = {
- {
- "BufWritePost",
- "*",
- ":silent FormatWrite",
- },
- },
- }
-end
-
--- check if formatter has been defined for the language or not
-local function formatter_exists(lang_formatter)
- if lang_formatter == nil then
- return false
- end
- if lang_formatter.exe == nil or lang_formatter.args == nil then
- return false
- end
- return true
-end
-
--- returns default formatter for given language
-local function formatter_return(lang_formatter)
- return {
- exe = lang_formatter.exe,
- args = lang_formatter.args,
- stdin = not (lang_formatter.stdin ~= nil),
- }
-end
-
--- fill a table like this -> {rust: {exe:"sth",args:{"a","b"},stdin=true},go: {}...}
-local formatter_filetypes = {}
-for k, v in pairs(O.lang) do
- if formatter_exists(v.formatter) then
- local keys = v.filetypes
- if keys == nil then
- keys = { k }
- end
- for _, l in pairs(keys) do
- formatter_filetypes[l] = {
- function()
- return formatter_return(v.formatter)
- end,
- }
- end
- end
-end
-
-require("formatter").setup {
- logging = false,
- filetype = formatter_filetypes,
-}
-
-if not O.format_on_save then
- vim.cmd [[if exists('#autoformat#BufWritePost')
- :autocmd! autoformat
- endif]]
-end