Skip to content

Commit

Permalink
chore: Remove unused format task
Browse files Browse the repository at this point in the history
  • Loading branch information
TheLeoP committed Jul 23, 2024
1 parent 1c2b889 commit e25a4f4
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 63 deletions.
39 changes: 0 additions & 39 deletions lua/refactoring/config/init.lua
Original file line number Diff line number Diff line change
@@ -1,34 +1,5 @@
local default_code_generation = require("refactoring.code_generation")

-- There is no formatting that we should do
local default_formatting = {
-- TODO: should we change default to be nothing?
-- I realize this is almost never a good idea.
ts = {},
js = {},
typescriptreact = {},

lua = {},
go = {},
php = {},

-- All of the Cs
cpp = {},
c = {},
h = {},
hpp = {},
cxx = {},

-- Python needs tons of work to become correct.
python = {},

ruby = {},

default = {
cmd = nil, -- format.lua checks to see if the command is nil or not
},
}

local default_prompt_func_param_type = {
go = false,
java = false,
Expand Down Expand Up @@ -107,7 +78,6 @@ local default_extract_var_statements = {}
---| "cs"

---@class ConfigOpts
---@field formatting? table<ft, {cmd: string}>
---@field code_generation? table<ft, code_generation>|{new_line: fun(): string}
---@field prompt_func_return_type? table<ft, boolean>
---@field prompt_func_param_type? table<ft, boolean>
Expand Down Expand Up @@ -136,7 +106,6 @@ function Config:new(...)
bufnr = nil,
},
}, {
formatting = vim.deepcopy(default_formatting),
code_generation = vim.deepcopy(default_code_generation),
prompt_func_return_type = vim.deepcopy(default_prompt_func_return_type),
prompt_func_param_type = vim.deepcopy(default_prompt_func_param_type),
Expand Down Expand Up @@ -169,7 +138,6 @@ end

function Config:reset()
local c = self.config
c.formatting = vim.deepcopy(default_formatting)
c.code_generation = vim.deepcopy(default_code_generation)
c.prompt_func_return_type = vim.deepcopy(default_prompt_func_return_type)
c.prompt_func_param_type = vim.deepcopy(default_prompt_func_param_type)
Expand Down Expand Up @@ -291,13 +259,6 @@ function Config:get_code_generation_for(filetype)
or self.config.code_generation["default"]
end

---@param filetype ft
---@return {cmd: string}
function Config:get_formatting_for(filetype)
filetype = filetype or vim.bo[0].ft
return self.config.formatting[filetype] or self.config.formatting["default"]
end

---@param filetype ft
---@return string
function Config:get_visibility_for(filetype)
Expand Down
17 changes: 0 additions & 17 deletions lua/refactoring/tasks/format.lua

This file was deleted.

4 changes: 0 additions & 4 deletions lua/refactoring/tasks/post_refactor.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
local Pipeline = require("refactoring.pipeline")
local format = require("refactoring.tasks.format")
local adjust_cursor = require("refactoring.tasks.adjust_cursor").adjust_cursor
local apply_text_edits = require("refactoring.tasks.apply_text_edits")

Expand All @@ -18,18 +17,15 @@ local function success_message(refactor)
return true, refactor
end

-- TODO: How to save/reformat??? no idea
M.post_refactor = function()
return Pipeline:from_task(apply_text_edits)
:add_task(format)
:add_task(adjust_cursor)
:add_task(success_message)
end

-- needed when another file is generated
M.no_cursor_post_refactor = function()
return Pipeline:from_task(apply_text_edits)
:add_task(format)
:add_task(
---@param refactor Refactor
---@return boolean, Refactor
Expand Down
3 changes: 0 additions & 3 deletions lua/refactoring/tests/refactor_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,6 @@ local function test_empty_input()
---@type boolean, nil|string
local status, err = pcall(refactoring.refactor, refactor)

-- waits for the next frame for formatting to work.
async.util.scheduler()

vim.api.nvim_buf_delete(bufnr, { force = true })

eq(false, status)
Expand Down

0 comments on commit e25a4f4

Please sign in to comment.