refactor(config): move defaults to appropriate places

This commit is contained in:
Matt Leong 2021-11-05 16:59:34 -07:00
parent c44df0d6c4
commit 16884c1c09
8 changed files with 65 additions and 76 deletions

View file

@ -9,18 +9,8 @@ config.statusline = {
main_icon = '', main_icon = '',
} }
config.treesitter = { See cosmic defaults: cosmic/core/treesitter/init.lua
ensure_installed = { config.treesitter = {}
'typescript',
'javascript',
'tsx',
'html',
'css',
'lua',
'json',
'scss',
},
}
config.lsp = { config.lsp = {
@ -31,20 +21,8 @@ config.lsp = {
rename_notification = false, rename_notification = false,
-- see :h vim.diagnostic.config for all diagnostic configuration options -- see :h vim.diagnostic.config for all diagnostic configuration options
-- see cosmic defaults: cosmic/lsp/diagnostics.lua
diagnostic = { diagnostic = {
-- disable diagnostic virtual text
virtual_text = false,
-- disable diagnostic signs
signs = false,
-- enable diagnostic update on insert
update_in_insert = true,
-- disable underline for diagnostic
underline = false,
}, },
servers = { servers = {

View file

@ -15,47 +15,10 @@ local default_config = {
statusline = { statusline = {
main_icon = require('cosmic.core.theme.icons').ghost, main_icon = require('cosmic.core.theme.icons').ghost,
}, },
treesitter = {
ensure_installed = {
'typescript',
'javascript',
'tsx',
'html',
'css',
'lua',
'json',
'scss',
},
},
lsp = { lsp = {
format_on_save = true, -- true/false or table of filetypes {'.ts', '.js',} format_on_save = true, -- true/false or table of filetypes {'.ts', '.js',}
rename_notification = true, rename_notification = true,
-- vim.diagnostic.config settiings -- vim.diagnostic.config settiings
diagnostic = {
underline = true,
signs = true,
update_in_insert = false,
severity_sort = true,
float = {
show_header = false,
source = 'always',
border = 'single',
},
virtual_text = {
spacing = 4,
source = 'always',
severity = {
min = vim.diagnostic.severity.HINT,
},
-- todo: icons for diagnostics?
--[[ format = function(diagnostic)
if diagnostic.severity == vim.diagnostic.severity.ERROR then
return ('E: %s'):format(diagnostic.message)
end
return diagnostic.message
end, ]]
},
},
servers = { servers = {
-- enable/disable server + formatting -- enable/disable server + formatting
-- rust_analyzer = true, -- enable non-default servers -- rust_analyzer = true, -- enable non-default servers

View file

@ -1,6 +1,9 @@
require('auto-session').setup({ local config = require('cosmic.config')
local defaults = {
pre_save_cmds = { 'NvimTreeClose', 'cclose', 'lua vim.notify.dismiss()' }, pre_save_cmds = { 'NvimTreeClose', 'cclose', 'lua vim.notify.dismiss()' },
auto_session_enabled = false, auto_session_enabled = false,
auto_save_enabled = true, auto_save_enabled = true,
auto_restore_enabled = false, auto_restore_enabled = false,
}) }
require('auto-session').setup(vim.tbl_deep_extend('force', defaults, config.session or {}))

View file

@ -9,7 +9,12 @@ local highlight = utils.highlight
local icons = require('cosmic.core.theme.icons') local icons = require('cosmic.core.theme.icons')
local config = require('cosmic.config') local config = require('cosmic.config')
local main_icon = config.statusline.main_icon local defaults = vim.tbl_deep_extend('force', {
statusline = {
main_icon = icons.ghost,
},
}, config.statusline or {})
local main_icon = defaults.statusline.main_icon
local get_mode = function() local get_mode = function()
local mode_colors = { local mode_colors = {

View file

@ -5,13 +5,13 @@ local icons = {
arrow_right_filled = '', -- e0b0 arrow_right_filled = '', -- e0b0
arrow_left = '', -- e0b3 arrow_left = '', -- e0b3
arrow_right = '', -- e0b1 arrow_right = '', -- e0b1
ghost = ' ', ghost = '',
warn = '', warn = '',
info = '', info = '',
error = '', error = '',
hint = '', hint = '',
perf = '', perf = '',
note = ' ', note = '',
branch = '', branch = '',
file = '', file = '',
dotdotdot = '', dotdotdot = '',
@ -22,9 +22,9 @@ local icons = {
flame = '', flame = '',
check = '', check = '',
trace = '', trace = '',
file1 = ' ', file1 = '',
file2 = ' ', file2 = '',
clock = ' ', clock = '',
word = '', word = '',
git = { git = {
unstaged = '', unstaged = '',

View file

@ -1,6 +1,16 @@
local config = require('cosmic.config') local config = require('cosmic.config')
require('nvim-treesitter.configs').setup({
ensure_installed = config.treesitter.ensure_installed, local defaults = {
ensure_installed = {
'typescript',
'javascript',
'tsx',
'html',
'css',
'lua',
'json',
'scss',
},
highlight = { highlight = {
enable = true, enable = true,
use_languagetree = true, use_languagetree = true,
@ -18,4 +28,6 @@ require('nvim-treesitter.configs').setup({
highlight_definitions = { enable = true }, highlight_definitions = { enable = true },
highlight_current_scope = { enable = false }, highlight_current_scope = { enable = false },
}, },
}) }
require('nvim-treesitter.configs').setup(vim.tbl_deep_extend('force', defaults, config.treesitter or {}))

View file

@ -1,7 +1,35 @@
local config = require('cosmic.config') local config = require('cosmic.config')
local icons = require('cosmic.core.theme.icons') local icons = require('cosmic.core.theme.icons')
vim.diagnostic.config(config.lsp.diagnostic) local defaults = {
underline = true,
signs = true,
update_in_insert = false,
severity_sort = true,
float = {
show_header = false,
source = 'always',
border = 'single',
},
virtual_text = {
spacing = 4,
source = 'always',
severity = {
min = vim.diagnostic.severity.HINT,
},
-- todo: icons for diagnostics?
--[[ format = function(diagnostic)
if diagnostic.severity == vim.diagnostic.severity.ERROR then
return ('E: %s'):format(diagnostic.message)
end
return diagnostic.message
end, ]]
},
}
local opts = vim.tbl_deep_extend('force', defaults, config.lsp.diagnostic or {})
vim.diagnostic.config(opts)
local function do_diagnostic_signs() local function do_diagnostic_signs()
local signs = { local signs = {