feat: cleaner string formats
This commit is contained in:
parent
42ceab06c0
commit
3b6e4213b9
7 changed files with 11 additions and 12 deletions
2
init.lua
2
init.lua
|
@ -1,5 +1,5 @@
|
|||
local ok, err = pcall(require, 'cosmic')
|
||||
|
||||
if not ok then
|
||||
error(string.format('Error loading core...\n\n%s', err))
|
||||
error(('Error loading core...\n\n%s'):format(err))
|
||||
end
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
-- Override Cosmic editor options
|
||||
--[[
|
||||
|
||||
local opt = vim.opt
|
||||
local g = vim.g
|
||||
|
||||
|
@ -8,4 +9,5 @@ g.mapleader = ','
|
|||
opt.tabstop = 4
|
||||
opt.softtabstop = 4
|
||||
opt.shiftwidth = 4
|
||||
|
||||
]]
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
local ok, user_config = pcall(require, 'cosmic.config.config')
|
||||
|
||||
if not ok then
|
||||
error(string.format('Error loading user config...\n\n%s', user_config))
|
||||
error(('Error loading user config...\n\n%s'):format(user_config))
|
||||
error('No user config, using default instead...')
|
||||
end
|
||||
|
||||
|
@ -29,7 +29,7 @@ local default_config = {
|
|||
-- todo: icons for diagnostics?
|
||||
--[[ format = function(diagnostic)
|
||||
if diagnostic.severity == vim.diagnostic.severity.ERROR then
|
||||
return string.format('E: %s', diagnostic.message)
|
||||
return ('E: %s'):format(diagnostic.message)
|
||||
end
|
||||
return diagnostic.message
|
||||
end, ]]
|
||||
|
|
|
@ -12,6 +12,6 @@ local cosmic_modules = {
|
|||
for _, mod in ipairs(cosmic_modules) do
|
||||
local ok, err = pcall(require, mod)
|
||||
if not ok then
|
||||
error(string.format('Error loading %s...\n\n%s', mod, err))
|
||||
error(('Error loading %s...\n\n%s'):format(mod, err))
|
||||
end
|
||||
end
|
||||
|
|
|
@ -25,15 +25,12 @@ function M.on_attach(client, bufnr)
|
|||
else
|
||||
format_filetypes = '*'
|
||||
end
|
||||
vim.cmd(string.format(
|
||||
[[
|
||||
vim.cmd(([[
|
||||
augroup CosmicFormat
|
||||
autocmd!
|
||||
autocmd BufWritePre %s lua vim.lsp.buf.formatting_sync(nil, 200)
|
||||
augroup end
|
||||
]],
|
||||
format_filetypes
|
||||
))
|
||||
]]):format(format_filetypes))
|
||||
end
|
||||
else
|
||||
client.resolved_capabilities.document_formatting = false
|
||||
|
|
|
@ -9,7 +9,7 @@ local use = packer.use
|
|||
|
||||
local ok, user_plugins = pcall(require, 'cosmic.config.plugins')
|
||||
if not ok then
|
||||
error(string.format('Error loading user custom plugins...\n\n%s', user_plugins))
|
||||
error(('Error loading user custom plugins...\n\n%s'):format(user_plugins))
|
||||
return false
|
||||
end
|
||||
|
||||
|
|
|
@ -34,9 +34,9 @@ end
|
|||
|
||||
function M.highlight(group, bg, fg, gui)
|
||||
if gui ~= nil and gui ~= '' then
|
||||
vim.api.nvim_command(string.format('hi %s guibg=%s guifg=%s gui=%s', group, bg, fg, gui))
|
||||
vim.api.nvim_command(('hi %s guibg=%s guifg=%s gui=%s'):format(group, bg, fg, gui))
|
||||
else
|
||||
vim.api.nvim_command(string.format('hi %s guibg=%s guifg=%s', group, bg, fg))
|
||||
vim.api.nvim_command(('hi %s guibg=%s guifg=%s'):format(group, bg, fg))
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue