diff options
| author | christianchiarulli <[email protected]> | 2021-07-13 00:48:37 -0400 | 
|---|---|---|
| committer | christianchiarulli <[email protected]> | 2021-07-13 00:48:37 -0400 | 
| commit | eceb656b4bdcd5bb4050c1e2566e95f97b99e20e (patch) | |
| tree | dfe178e1a6317d70f2daf5619a2d23e1cc33b1cf /lua/core | |
| parent | 4fad35a7e1a9d15317dada0625670707ffc5f9b0 (diff) | |
poc with local prettier working
Diffstat (limited to 'lua/core')
| -rw-r--r-- | lua/core/formatter.lua | 71 | 
1 files changed, 34 insertions, 37 deletions
| diff --git a/lua/core/formatter.lua b/lua/core/formatter.lua index ad40dd21..50dcb654 100644 --- a/lua/core/formatter.lua +++ b/lua/core/formatter.lua @@ -11,48 +11,45 @@ if O.format_on_save then    }  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 +-- -- 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 +-- 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 +-- 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, -} +require("formatter").setup {}  if not O.format_on_save then    vim.cmd [[if exists('#autoformat#BufWritePost') | 
