Use function style for vim.cmd instead of string style

This commit is contained in:
Kenneth Benzie 2024-04-07 19:12:38 +01:00
parent fe19c35f36
commit eee4944354
5 changed files with 10 additions and 11 deletions

View File

@ -27,7 +27,7 @@ vim.api.nvim_create_autocmd('BufRead', {
vim.api.nvim_create_autocmd('TermOpen', { vim.api.nvim_create_autocmd('TermOpen', {
group = group, pattern = 'term://*', group = group, pattern = 'term://*',
callback = function() callback = function()
vim.cmd [[ startinsert ]] vim.cmd.startinsert()
end end
}) })

View File

@ -32,7 +32,7 @@ function build.set_dir(dirname)
-- Restart clangd language server -- Restart clangd language server
-- TODO: Configure cmake language server? -- TODO: Configure cmake language server?
on_exit = function() on_exit = function()
vim.cmd [[ LspRestart clangd ]] vim.cmd.LspRestart('clangd')
echo('Build directory selected: ' .. dirname, 'DiagnosticInfo') echo('Build directory selected: ' .. dirname, 'DiagnosticInfo')
end, end,

View File

@ -29,7 +29,7 @@ vim.keymap.set('', '<leader>p', '"+p', { remap = false })
vim.keymap.set('', '<leader>P', '"+P', { remap = false }) vim.keymap.set('', '<leader>P', '"+P', { remap = false })
-- Undo neovim's default mapping of Y to y$ -- Undo neovim's default mapping of Y to y$
vim.cmd('unmap Y') vim.cmd.unmap('Y')
-- Make nvim :terminal more like vim :terminal -- Make nvim :terminal more like vim :terminal
vim.keymap.set('t', '<C-w>N', '<C-\\><C-n>', { remap = true }) vim.keymap.set('t', '<C-w>N', '<C-\\><C-n>', { remap = true })

View File

@ -25,8 +25,8 @@ local noice = {
}) })
-- Override highlight groups -- Override highlight groups
vim.cmd [[ highlight NoiceCmdlinePopupBorder guibg=#080808 ]] vim.cmd.highlight('NoiceCmdlinePopupBorder', 'guibg=#080808')
vim.cmd [[ highlight link NoiceCmdlinePopupBorder NoiceCmdlinePopupBorderSearch ]] vim.cmd.highlight('link', 'NoiceCmdlinePopupBorder', 'NoiceCmdlinePopupBorderSearch')
end end
} }

View File

@ -27,12 +27,11 @@ modes[116] = { name = 'Terminal', color = 'light_blue' }
modes[33] = { name = 'Shell', color = 'light_grey' } modes[33] = { name = 'Shell', color = 'light_grey' }
local function highlight(group, color, attrs) local function highlight(group, color, attrs)
local command = 'highlight ' .. group .. local args = { group, 'guifg=' .. color.fg, 'guibg=' .. color.bg }
' guifg=' .. color.fg .. ' guibg=' .. color.bg
if attrs then if attrs then
command = command .. ' gui=' .. attrs table.insert(args, 'gui=' .. attrs)
end end
vim.cmd(command) vim.cmd.highlight(args)
end end
-- StatusLineLight is shows the mode and cursor information, it is dynamically -- StatusLineLight is shows the mode and cursor information, it is dynamically
@ -170,7 +169,7 @@ vim.api.nvim_create_autocmd({ 'BufEnter', 'WinEnter', 'BufWinEnter' }, {
pattern = '*', pattern = '*',
group = group, group = group,
callback = function() callback = function()
vim.cmd [[ setlocal statusline=%{%v:lua.require('statusline').active()%} ]] vim.cmd.setlocal("statusline=%{%v:lua.require('statusline').active()%}")
end end
}) })
@ -179,7 +178,7 @@ vim.api.nvim_create_autocmd({ 'BufLeave', 'WinLeave' }, {
pattern = '*', pattern = '*',
group = group, group = group,
callback = function() callback = function()
vim.cmd [[ setlocal statusline=%{%v:lua.require('statusline').inactive()%} ]] vim.cmd.setlocal("statusline=%{%v:lua.require('statusline').inactive()%}")
end end
}) })