Skip to content

Commit

Permalink
Replace all simple usages of vim.cmd('foo' ..) with vim.cmd.foo(..).
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian committed Oct 20, 2023
1 parent bee8847 commit 5de3aa2
Show file tree
Hide file tree
Showing 20 changed files with 114 additions and 114 deletions.
10 changes: 5 additions & 5 deletions lua/lean/infoview.lua
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ function Infoview:open()
else
self.__orientation = 'horizontal'
if self.__separate_tab then
vim.cmd('tabnew')
vim.cmd.tabnew()
else
local position = self.__horizontal_position == 'bottom' and 'botright '
or 'topleft '
Expand Down Expand Up @@ -178,19 +178,19 @@ end

---Move this infoview's window to the right of the tab, then size it properly.
function Infoview:move_to_right()
vim.api.nvim_win_call(self.window, function() vim.cmd[[wincmd L]] end)
vim.api.nvim_win_call(self.window, function() vim.cmd.wincmd('L') end)
vim.api.nvim_win_set_width(self.window, options.width)
end

---Move this infoview's window to the top of the tab, then size it properly.
function Infoview:move_to_top()
vim.api.nvim_win_call(self.window, function() vim.cmd[[wincmd K]] end)
vim.api.nvim_win_call(self.window, function() vim.cmd.wincmd('K') end)
vim.api.nvim_win_set_height(self.window, options.height)
end

---Move this infoview's window to the bottom of the tab, then size it properly.
function Infoview:move_to_bottom()
vim.api.nvim_win_call(self.window, function() vim.cmd[[wincmd J]] end)
vim.api.nvim_win_call(self.window, function() vim.cmd.wincmd('J') end)
vim.api.nvim_win_set_height(self.window, options.height)
end

Expand Down Expand Up @@ -240,7 +240,7 @@ function Infoview:__open_win(buf)
vim.cmd('vertical resize ' .. self.__width)
else
if self.__separate_tab then
vim.cmd('tabnew')
vim.cmd.tabnew()
else
vim.cmd('leftabove ' .. self.__height .. 'split')
vim.cmd('resize ' .. self.__height)
Expand Down
2 changes: 1 addition & 1 deletion lua/lean/progress_bars.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function progress_bars.enable(opts)
text = options.character,
texthl = 'leanSignProgress',
})
vim.cmd[[hi def leanSignProgress guifg=orange ctermfg=215]]
vim.cmd.hi('def leanSignProgress guifg=orange ctermfg=215')
progress_bars.enabled = true
end

Expand Down
4 changes: 2 additions & 2 deletions lua/tests/abbreviations/abbreviations_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ describe('unicode abbreviation expansion', function()
end))

it('inserts nothing on <Tab> mid-line', helpers.clean_buffer('lean', 'foo bar baz quux,', function()
vim.cmd('normal $')
vim.cmd.normal('$')
helpers.insert[[ \comp<Tab> spam]]
wait_for_expansion()
assert.contents.are[[foo bar baz quux ∘ spam,]]
Expand Down Expand Up @@ -104,7 +104,7 @@ describe('unicode abbreviation expansion', function()

it('expands abbreviations in command mode', helpers.clean_buffer('lean', '', function()
helpers.insert[[foo ε bar]]
vim.cmd('normal $')
vim.cmd.normal('$')
helpers.feed[[q/a\e<Space><CR>ibaz]]
assert.current_line.is('foo bazε bar')
end))
Expand Down
2 changes: 1 addition & 1 deletion lua/tests/helpers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ end
---@param opts MoveCursorOpts
function helpers.move_cursor(opts)
vim.api.nvim_win_set_cursor(opts.window or 0, opts.to)
vim.cmd[[doautocmd CursorMoved]]
vim.cmd.doautocmd('CursorMoved')
end

---@class MoveCursorOpts
Expand Down
22 changes: 11 additions & 11 deletions lua/tests/infoview/autoopen_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ describe('infoview autoopen', function()
vim.tbl_contains(windows, infoview.get_current_infoview().window)
)

vim.cmd('split ' .. fixtures.lean_project.some_nested_existing_file)
vim.cmd.split(fixtures.lean_project.some_nested_existing_file)
table.insert(windows, vim.api.nvim_get_current_win())
assert.windows.are(windows)

vim.cmd('quit')
vim.cmd.quit()
end)

it('automatically opens additional infoviews for new tabs', function(_)
local tab1_infoview = infoview.get_current_infoview()

vim.cmd('tabnew')
vim.cmd.tabnew()
local tab2_window = vim.api.nvim_get_current_win()
assert.windows.are(tab2_window)

Expand All @@ -43,19 +43,19 @@ describe('infoview autoopen', function()

assert.windows.are(tab2_window, tab2_infoview.window)

vim.cmd('tabclose')
vim.cmd.tabclose()
end)

it('does not (auto-)open infoviews for non-Lean files', function(_)
vim.cmd('tabnew')
vim.cmd.tabnew()
assert.is.equal(1, #vim.api.nvim_tabpage_list_wins(0))

vim.cmd('edit some_other_file.foo')
vim.cmd.edit('some_other_file.foo')
local non_lean_window = vim.api.nvim_get_current_win()

assert.windows.are(non_lean_window)

vim.cmd('tabclose')
vim.cmd.tabclose()
end)

it('does not auto-reopen an infoview that has been closed', function(_)
Expand All @@ -66,10 +66,10 @@ describe('infoview autoopen', function()
infoview.close()
assert.windows.are(lean_window)

vim.cmd('split ' .. fixtures.lean_project.some_nested_existing_file)
vim.cmd.split(fixtures.lean_project.some_nested_existing_file)
assert.windows.are(lean_window, vim.api.nvim_get_current_win())

vim.cmd('quit')
vim.cmd.quit()
end)

it('allows infoviews to reopen manually after closing', function(_)
Expand All @@ -79,7 +79,7 @@ describe('infoview autoopen', function()
end)

it('can be disabled', function(_)
vim.cmd('tabnew')
vim.cmd.tabnew()
infoview.set_autoopen(false)
local tab2_window = vim.api.nvim_get_current_win()
vim.cmd('edit! ' .. fixtures.lean_project.some_nested_existing_file)
Expand All @@ -92,7 +92,7 @@ describe('infoview autoopen', function()
tab2_infoview:close()
assert.windows.are(tab2_window)

vim.cmd('tabclose')
vim.cmd.tabclose()
end)

it('can be re-enabled after being disabled', function(_)
Expand Down
8 changes: 4 additions & 4 deletions lua/tests/infoview/close_all_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,22 @@ describe('infoview.close_all', function()
it('closes many infoviews, some already closed', function(_)
local tabpages = {}

vim.cmd('tabnew temp1.lean')
vim.cmd.tabnew('temp1.lean')
table.insert(tabpages, vim.api.nvim_get_current_tabpage())
local temp1 = unpack(vim.api.nvim_tabpage_list_wins(tabpages[#tabpages]))
local temp1_infoview = infoview.open()

vim.cmd('tabnew temp2.lean')
vim.cmd.tabnew('temp2.lean')
table.insert(tabpages, vim.api.nvim_get_current_tabpage())
local temp2 = unpack(vim.api.nvim_tabpage_list_wins(tabpages[#tabpages]))
local temp2_infoview = infoview.open()

vim.cmd('tabnew temp3.lean')
vim.cmd.tabnew('temp3.lean')
table.insert(tabpages, vim.api.nvim_get_current_tabpage())
local temp3 = unpack(vim.api.nvim_tabpage_list_wins(tabpages[#tabpages]))
infoview.open():close()

vim.cmd('tabnew temp4.lean')
vim.cmd.tabnew('temp4.lean')
table.insert(tabpages, vim.api.nvim_get_current_tabpage())
local temp4 = unpack(vim.api.nvim_tabpage_list_wins(tabpages[#tabpages]))
local temp4_infoview = infoview.open()
Expand Down
8 changes: 4 additions & 4 deletions lua/tests/infoview/contents_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ describe('infoview content (auto-)update', function()
it('is shared between separate windows', function()
assert.current_window.is(lean_window)

vim.cmd('split')
vim.cmd.split()
local second_window = vim.api.nvim_get_current_win()
assert.are.same(vim.api.nvim_win_get_cursor(0), {3, 0})
assert.infoview_contents.are[[
Expand Down Expand Up @@ -92,7 +92,7 @@ describe('infoview content (auto-)update', function()
assert.current_window.is(lean_window)

local original_lines = infoview.get_current_infoview():get_lines()
vim.cmd('split some_non_lean_file.tmp')
vim.cmd.split('some_non_lean_file.tmp')
helpers.insert('some stuff')
assert.are.same(original_lines, infoview.get_current_infoview():get_lines())

Expand Down Expand Up @@ -150,7 +150,7 @@ describe('infoview content (auto-)update', function()
]]

vim.cmd('tabnew' .. fixtures.lean_project.path .. '/Test/Squares.lean')
vim.cmd.tabnew(fixtures.lean_project.path .. '/Test/Squares.lean')
helpers.move_cursor{ to = {3, 0} }
assert.infoview_contents.are[[
▶ 3:1-3:6: information:
Expand All @@ -174,7 +174,7 @@ describe('infoview content (auto-)update', function()
assert.is_not.equal(vim.api.nvim_win_get_tabpage(lean_window), tab2)

infoview.close()
vim.cmd('tabprevious')
vim.cmd.tabprevious()

helpers.move_cursor{ to = {3, 0} }
assert.infoview_contents.are[[
Expand Down
2 changes: 1 addition & 1 deletion lua/tests/infoview/layout/horizontal_top_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('infoview window', function()
{ 'leaf', lean_window },
},
}, vim.fn.winlayout())
vim.cmd[[wincmd L]]
vim.cmd.wincmd('L')

infoview.reposition()

Expand Down
2 changes: 1 addition & 1 deletion lua/tests/infoview/layout/landscape_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('infoview window', function()
it('opens on the right of stacked splits at full height', function(_)
assert.is.equal(1, #vim.api.nvim_tabpage_list_wins(0))
local top_window = vim.api.nvim_get_current_win()
vim.cmd[[botright split]]
vim.cmd('botright split')
local bottom_window = vim.api.nvim_get_current_win()

assert.are.same({ -- see :h winlayout
Expand Down
2 changes: 1 addition & 1 deletion lua/tests/infoview/layout/portrait_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe('infoview window', function()
it('opens on the bottom of stacked splits at full height', function(_)
assert.is.equal(1, #vim.api.nvim_tabpage_list_wins(0))
local top_window = vim.api.nvim_get_current_win()
vim.cmd[[botright split]]
vim.cmd('botright split')
local bottom_window = vim.api.nvim_get_current_win()

assert.are.same({ -- see :h winlayout
Expand Down
8 changes: 4 additions & 4 deletions lua/tests/infoview/layout/reposition_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('infoview window', function()
vim.o.columns = 24
vim.o.lines = 80
local current_infoview = infoview.open()
vim.cmd[[wincmd L]]
vim.cmd.wincmd('L')
assert.are.same(
{ 'row', { { 'leaf', current_infoview.window }, { 'leaf', lean_window } } },
vim.fn.winlayout()
Expand Down Expand Up @@ -100,7 +100,7 @@ describe('infoview window', function()
vim.o.columns = 80
vim.o.lines = 24
local current_infoview = infoview.open()
vim.cmd[[wincmd K]]
vim.cmd.wincmd('K')
assert.are.same(
{ 'col', { { 'leaf', lean_window }, { 'leaf', current_infoview.window } } },
vim.fn.winlayout()
Expand All @@ -123,7 +123,7 @@ describe('infoview window', function()
vim.o.lines = 24

infoview.open()
vim.cmd[[split]]
vim.cmd.split()

local layout = vim.fn.winlayout()

Expand Down Expand Up @@ -151,7 +151,7 @@ describe('infoview window', function()
end)

it('does not touch leaf windows', function(_)
vim.cmd[[wincmd o]]
vim.cmd.wincmd('o')
assert.is.equal(1, #vim.api.nvim_tabpage_list_wins(0))
local layout = vim.fn.winlayout()
infoview.reposition()
Expand Down
Loading

0 comments on commit 5de3aa2

Please sign in to comment.