46 lines
1.4 KiB
Lua
46 lines
1.4 KiB
Lua
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('No user config, using default instead...')
|
|
end
|
|
|
|
if user_config == true then
|
|
user_config = {}
|
|
end
|
|
|
|
-- these settings will be merged with any settings definined in config.lua
|
|
local default_config = {
|
|
statusline = {
|
|
main_icon = require('cosmic.core.theme.icons').ghost,
|
|
},
|
|
lsp = {
|
|
format_on_save = false, -- true/false or table of filetypes {'.ts', '.js',}
|
|
servers = {
|
|
eslint = true, -- enable/disable server
|
|
-- rust_analyzer = true, -- enable non-default servers (todo: support for custom server configs)
|
|
efm = {
|
|
format = true, -- true or false
|
|
disable_formatters = { 'eslint' }, -- e.g. 'eslint', 'prettier', 'stylua'
|
|
},
|
|
tsserver = {
|
|
format = false, -- disable formatting all together
|
|
},
|
|
},
|
|
},
|
|
}
|
|
|
|
local config = vim.tbl_deep_extend('force', default_config, user_config)
|
|
-- default servers that can be formatted
|
|
local formatting_servers = { 'efm', 'eslint', 'tsserver', 'sumneko_lua', 'rust_analyzer', 'gopls', 'pyright' }
|
|
local user_servers = vim.tbl_keys(config.lsp.servers)
|
|
|
|
function config.lsp.can_client_format(client_name)
|
|
if not user_servers[client_name] or vim.tbl_contains(formatting_servers, client_name) then
|
|
return false
|
|
end
|
|
|
|
return (user_servers[client_name].format == true)
|
|
end
|
|
|
|
return config
|