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