refactor: smaller config footprint
This commit is contained in:
parent
478368f03a
commit
6102571a7f
11 changed files with 88 additions and 94 deletions
|
@ -4,9 +4,6 @@
|
|||
-- local null_ls = require('null-ls')
|
||||
|
||||
local config = {
|
||||
-- See :h cmp-usage
|
||||
autocomplete = {},
|
||||
|
||||
-- See https://github.com/rmagatti/auto-session#%EF%B8%8F-configuration
|
||||
auto_session = {},
|
||||
|
||||
|
@ -14,7 +11,7 @@ local config = {
|
|||
border = 'rounded',
|
||||
|
||||
-- https://github.com/numToStr/Comment.nvim#configuration-optional
|
||||
comments = {},
|
||||
comment_nvim = {},
|
||||
|
||||
-- See https://github.com/CosmicNvim/cosmic-ui#%EF%B8%8F-configuration
|
||||
cosmic_ui = {},
|
||||
|
@ -53,11 +50,12 @@ local config = {
|
|||
},
|
||||
|
||||
-- See Cosmic defaults lsp/providers/null_ls.lua
|
||||
-- and https://github.com/jose-elias-alvarez/null-ls.nvim/
|
||||
-- If adding additional sources, be sure to also copy the defaults that you would like to preserve from lsp/providers/null_ls.lua
|
||||
null_ls = {},
|
||||
},
|
||||
|
||||
-- See Cosmic defaults lsp/providers/tsserver.lua
|
||||
-- If adding additional sources, be sure to also copy the defaults that you would like to preserve from lsp/providers/null_ls.lua
|
||||
ts_utils = {},
|
||||
},
|
||||
|
||||
|
@ -96,9 +94,39 @@ local config = {
|
|||
|
||||
-- See :h notify.setup
|
||||
notify = {},
|
||||
--
|
||||
-- See :h cmp-usage
|
||||
nvim_cmp = {},
|
||||
|
||||
-- See :h nvim-tree.setup
|
||||
nvim_tree = {},
|
||||
|
||||
add_plugins = {
|
||||
'ggandor/lightspeed.nvim',
|
||||
{
|
||||
'romgrk/barbar.nvim',
|
||||
requires = { 'kyazdani42/nvim-web-devicons' },
|
||||
},
|
||||
},
|
||||
|
||||
disable_builtin_plugins = {
|
||||
--[[
|
||||
'auto-session',
|
||||
'nvim-cmp',
|
||||
'colorizer',
|
||||
'dashboard',
|
||||
'fugitive',
|
||||
'gitsigns',
|
||||
'comment-nvim',
|
||||
'nvim-tree',
|
||||
'galaxyline',
|
||||
'telescope',
|
||||
'terminal',
|
||||
'theme',
|
||||
'todo-comments',
|
||||
'treesitter',
|
||||
]]
|
||||
},
|
||||
}
|
||||
|
||||
return config
|
||||
|
|
|
@ -1,12 +1,30 @@
|
|||
-- Override Cosmic editor options
|
||||
|
||||
local opt = vim.opt
|
||||
local g = vim.g
|
||||
local map = require('cosmic.utils').map
|
||||
local opt = vim.opt
|
||||
|
||||
-- Default leader is <space>
|
||||
g.mapleader = ','
|
||||
|
||||
-- Default indent = 2
|
||||
opt.tabstop = 4
|
||||
opt.softtabstop = 4
|
||||
opt.shiftwidth = 4
|
||||
opt.softtabstop = 4
|
||||
opt.tabstop = 4
|
||||
|
||||
-- Add additional keymaps or disable existing ones
|
||||
-- To view maps set, use `:Telescope keymaps`
|
||||
-- or `:map`, `:map <leader>`
|
||||
|
||||
-- Example: Additional insert mapping:
|
||||
map('i', 'jj', '<esc>', { noremap = true, silent = true })
|
||||
|
||||
-- Mapping options:
|
||||
-- map('n', ...)
|
||||
-- map('v', ...)
|
||||
-- map('i', ...)
|
||||
-- map('t', ...)
|
||||
|
||||
-- Example: Disable find files keymap
|
||||
-- local cmd = vim.cmd
|
||||
-- cmd('unmap <leader>f')
|
||||
|
|
|
@ -1,18 +0,0 @@
|
|||
-- Add additional keymaps or disable existing ones
|
||||
-- To view maps set, use `:Telescope keymaps`
|
||||
-- or `:map`, `:map <leader>`
|
||||
|
||||
local cmd = vim.cmd
|
||||
local map = require('cosmic.utils').map
|
||||
|
||||
-- Example: Additional insert mapping:
|
||||
map('i', 'jj', '<esc>', { noremap = true, silent = true })
|
||||
|
||||
-- Mapping options:
|
||||
-- map('n', ...)
|
||||
-- map('v', ...)
|
||||
-- map('i', ...)
|
||||
-- map('t', ...)
|
||||
|
||||
-- Example: Disable find files keymap
|
||||
-- cmd('unmap <leader>f')
|
|
@ -1,31 +0,0 @@
|
|||
-- Add additional plugins as well as disable some core plugins
|
||||
|
||||
local plugins = {
|
||||
add = {
|
||||
'ggandor/lightspeed.nvim',
|
||||
{
|
||||
'romgrk/barbar.nvim',
|
||||
requires = { 'kyazdani42/nvim-web-devicons' },
|
||||
},
|
||||
},
|
||||
disable = { -- disabling some core plugins may mean you'll have to remap some keybindings
|
||||
--[[
|
||||
'auto-session',
|
||||
'autocomplete',
|
||||
'colorizer',
|
||||
'dashboard',
|
||||
'fugitive',
|
||||
'gitsigns',
|
||||
'kommentary',
|
||||
'nvim-tree',
|
||||
'statusline',
|
||||
'telescope',
|
||||
'terminal',
|
||||
'theme',
|
||||
'todo-comments',
|
||||
'treesitter',
|
||||
]]
|
||||
},
|
||||
}
|
||||
|
||||
return plugins
|
|
@ -4,8 +4,6 @@ There are five main configuraiton files that you may want to create.
|
|||
|
||||
- cosmic/config/config.lua
|
||||
- cosmic/config/editor.lua
|
||||
- cosmic/config/mappings.lua
|
||||
- cosmic/config/plugins.lua
|
||||
- cosmic/config/utils.lua
|
||||
|
||||
Please look at the examples in this directory in order to get started.
|
||||
|
@ -16,7 +14,5 @@ Please look at the examples in this directory in order to get started.
|
|||
# from project root
|
||||
cp ./lua/cosmic/config/examples/config.lua ./lua/cosmic/config/config.lua
|
||||
cp ./lua/cosmic/config/examples/editor.lua ./lua/cosmic/config/editor.lua
|
||||
cp ./lua/cosmic/config/examples/mappings.lua ./lua/cosmic/config/mappings.lua
|
||||
cp ./lua/cosmic/config/examples/plugins.lua ./lua/cosmic/config/plugins.lua
|
||||
cp ./lua/cosmic/config/examples/utils.lua ./lua/cosmic/config/utils.lua
|
||||
```
|
||||
|
|
|
@ -3,9 +3,8 @@ local cosmic_modules = {
|
|||
'cosmic.core.pluginsInit',
|
||||
'cosmic.core.commands',
|
||||
'cosmic.core.editor',
|
||||
'cosmic.config.editor',
|
||||
'cosmic.core.mappings',
|
||||
'cosmic.config.mappings',
|
||||
'cosmic.config.editor',
|
||||
}
|
||||
|
||||
for _, mod in ipairs(cosmic_modules) do
|
||||
|
|
|
@ -7,19 +7,19 @@ end
|
|||
local packer = cosmic_packer.packer
|
||||
local use = packer.use
|
||||
|
||||
local ok, user_plugins = pcall(require, 'cosmic.config.plugins')
|
||||
local ok, user_config = pcall(require, 'cosmic.config')
|
||||
if not ok then
|
||||
user_plugins = {
|
||||
user_config = {
|
||||
add = {},
|
||||
disable = {},
|
||||
}
|
||||
end
|
||||
|
||||
if not vim.tbl_islist(user_plugins.add) then
|
||||
user_plugins.add = {}
|
||||
if not vim.tbl_islist(user_config.add) then
|
||||
user_config.add_plugins = {}
|
||||
end
|
||||
if not vim.tbl_islist(user_plugins.disable) then
|
||||
user_plugins.disable = {}
|
||||
if not vim.tbl_islist(user_config.disable) then
|
||||
user_config.disable_builtin_plugins = {}
|
||||
end
|
||||
|
||||
local config = require('cosmic.config')
|
||||
|
@ -41,7 +41,7 @@ return packer.startup(function()
|
|||
require('cosmic.plugins.notify')
|
||||
end,
|
||||
after = config.theme,
|
||||
disable = vim.tbl_contains(user_plugins.disable, 'notify'),
|
||||
disable = vim.tbl_contains(user_config.disable_builtin_plugins, 'notify'),
|
||||
})
|
||||
|
||||
-- theme stuff
|
||||
|
@ -53,7 +53,7 @@ return packer.startup(function()
|
|||
require('cosmic.plugins.galaxyline')
|
||||
end,
|
||||
after = config.theme,
|
||||
disable = vim.tbl_contains(user_plugins.disable, 'statusline'),
|
||||
disable = vim.tbl_contains(user_config.disable_builtin_plugins, 'galaxyline'),
|
||||
})
|
||||
|
||||
-- file explorer
|
||||
|
@ -71,7 +71,7 @@ return packer.startup(function()
|
|||
'NvimTreeRefresh',
|
||||
'NvimTreeToggle',
|
||||
},
|
||||
disable = vim.tbl_contains(user_plugins.disable, 'nvim-tree'),
|
||||
disable = vim.tbl_contains(user_config.disable_builtin_plugins, 'nvim-tree'),
|
||||
})
|
||||
|
||||
use({
|
||||
|
@ -98,7 +98,7 @@ return packer.startup(function()
|
|||
config = function()
|
||||
require('cosmic.lsp.providers.null_ls')
|
||||
end,
|
||||
disable = vim.tbl_contains(user_plugins.disable, 'null-ls'),
|
||||
disable = vim.tbl_contains(user_config.disable_builtin_plugins, 'null-ls'),
|
||||
after = 'nvim-lspconfig',
|
||||
},
|
||||
{
|
||||
|
@ -107,7 +107,7 @@ return packer.startup(function()
|
|||
require('cosmic.plugins.lsp-signature')
|
||||
end,
|
||||
after = 'nvim-lspconfig',
|
||||
disable = vim.tbl_contains(user_plugins.disable, 'lsp_signature'),
|
||||
disable = vim.tbl_contains(user_config.disable_builtin_plugins, 'lsp_signature'),
|
||||
},
|
||||
},
|
||||
})
|
||||
|
@ -142,7 +142,7 @@ return packer.startup(function()
|
|||
},
|
||||
},
|
||||
event = 'InsertEnter',
|
||||
disable = vim.tbl_contains(user_plugins.disable, 'autocomplete'),
|
||||
disable = vim.tbl_contains(user_config.disable_builtin_plugins, 'nvim-cmp'),
|
||||
})
|
||||
|
||||
-- git commands
|
||||
|
@ -150,7 +150,7 @@ return packer.startup(function()
|
|||
'tpope/vim-fugitive',
|
||||
opt = true,
|
||||
cmd = 'Git',
|
||||
disable = vim.tbl_contains(user_plugins.disable, 'fugitive'),
|
||||
disable = vim.tbl_contains(user_config.disable_builtin_plugins, 'fugitive'),
|
||||
})
|
||||
|
||||
-- git column signs
|
||||
|
@ -162,7 +162,7 @@ return packer.startup(function()
|
|||
config = function()
|
||||
require('cosmic.plugins.gitsigns')
|
||||
end,
|
||||
disable = vim.tbl_contains(user_plugins.disable, 'gitsigns'),
|
||||
disable = vim.tbl_contains(user_config.disable_builtin_plugins, 'gitsigns'),
|
||||
})
|
||||
|
||||
-- floating terminal
|
||||
|
@ -173,7 +173,7 @@ return packer.startup(function()
|
|||
config = function()
|
||||
require('cosmic.plugins.terminal')
|
||||
end,
|
||||
disable = vim.tbl_contains(user_plugins.disable, 'terminal'),
|
||||
disable = vim.tbl_contains(user_config.disable_builtin_plugins, 'terminal'),
|
||||
})
|
||||
|
||||
-- file navigation
|
||||
|
@ -192,7 +192,7 @@ return packer.startup(function()
|
|||
require('cosmic.plugins.telescope')
|
||||
end,
|
||||
event = 'BufWinEnter',
|
||||
disable = vim.tbl_contains(user_plugins.disable, 'telescope'),
|
||||
disable = vim.tbl_contains(user_config.disable_builtin_plugins, 'telescope'),
|
||||
})
|
||||
|
||||
-- session/project management
|
||||
|
@ -201,7 +201,7 @@ return packer.startup(function()
|
|||
config = function()
|
||||
require('cosmic.plugins.dashboard')
|
||||
end,
|
||||
disable = vim.tbl_contains(user_plugins.disable, 'dashboard'),
|
||||
disable = vim.tbl_contains(user_config.disable_builtin_plugins, 'dashboard'),
|
||||
})
|
||||
|
||||
use({
|
||||
|
@ -209,7 +209,7 @@ return packer.startup(function()
|
|||
config = function()
|
||||
require('cosmic.plugins.auto-session')
|
||||
end,
|
||||
disable = vim.tbl_contains(user_plugins.disable, 'auto-session'),
|
||||
disable = vim.tbl_contains(user_config.disable_builtin_plugins, 'auto-session'),
|
||||
})
|
||||
|
||||
-- lang/syntax stuff
|
||||
|
@ -224,7 +224,7 @@ return packer.startup(function()
|
|||
config = function()
|
||||
require('cosmic.plugins.treesitter')
|
||||
end,
|
||||
disable = vim.tbl_contains(user_plugins.disable, 'treesitter'),
|
||||
disable = vim.tbl_contains(user_config.disable_builtin_plugins, 'treesitter'),
|
||||
})
|
||||
|
||||
-- comments and stuff
|
||||
|
@ -234,6 +234,7 @@ return packer.startup(function()
|
|||
require('cosmic.plugins.comments')
|
||||
end,
|
||||
event = 'BufWinEnter',
|
||||
disable = vim.tbl_contains(user_config.disable_builtin_plugins, 'comment-nvim'),
|
||||
})
|
||||
|
||||
-- todo highlights
|
||||
|
@ -244,7 +245,7 @@ return packer.startup(function()
|
|||
require('cosmic.plugins.todo-comments')
|
||||
end,
|
||||
event = 'BufWinEnter',
|
||||
disable = vim.tbl_contains(user_plugins.disable, 'todo-comments'),
|
||||
disable = vim.tbl_contains(user_config.disable_builtin_plugins, 'todo-comments'),
|
||||
})
|
||||
-- colorized hex codes
|
||||
use({
|
||||
|
@ -254,11 +255,11 @@ return packer.startup(function()
|
|||
config = function()
|
||||
require('colorizer').setup()
|
||||
end,
|
||||
disable = vim.tbl_contains(user_plugins.disable, 'colorizer'),
|
||||
disable = vim.tbl_contains(user_config.disable_builtin_plugins, 'colorizer'),
|
||||
})
|
||||
|
||||
if user_plugins.add and not vim.tbl_isempty(user_plugins.add) then
|
||||
for _, plugin in pairs(user_plugins.add) do
|
||||
if user_config.add_plugins and not vim.tbl_isempty(user_config.add_plugins) then
|
||||
for _, plugin in pairs(user_config.add_plugins) do
|
||||
use(plugin)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -31,6 +31,11 @@ require('null-ls').setup(utils.merge({
|
|||
null_ls.builtins.formatting.prettier.with({
|
||||
prefer_local = 'node_modules/.bin',
|
||||
}),
|
||||
-- null_ls.builtins.formatting.prettierd.with({
|
||||
-- env = {
|
||||
-- PRETTIERD_DEFAULT_CONFIG = vim.fn.getcwd() .. '/.prettierrc',
|
||||
-- },
|
||||
-- }),
|
||||
null_ls.builtins.formatting.stylua,
|
||||
null_ls.builtins.code_actions.gitsigns,
|
||||
},
|
||||
|
|
|
@ -16,4 +16,4 @@ require('Comment').setup(utils.merge({
|
|||
location = location,
|
||||
})
|
||||
end,
|
||||
}, config.comments or {}))
|
||||
}, config.comment_nvim or {}))
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
local cmp = require('cmp')
|
||||
local utils = require('cosmic.utils')
|
||||
local luasnip = require('luasnip')
|
||||
local config = require('cosmic.config')
|
||||
local user_config = require('cosmic.config')
|
||||
local icons = require('cosmic.theme.icons')
|
||||
|
||||
local has_words_before = function()
|
||||
|
@ -56,7 +56,7 @@ local default_cmp_opts = {
|
|||
}),
|
||||
},
|
||||
documentation = {
|
||||
border = config.border,
|
||||
border = user_config.border,
|
||||
winhighlight = 'FloatBorder:FloatBorder,Normal:Normal',
|
||||
},
|
||||
experimental = {
|
||||
|
@ -89,7 +89,7 @@ vim.cmd([[
|
|||
autocmd FileType TelescopePrompt lua require('cmp').setup.buffer { enabled = false }
|
||||
]])
|
||||
|
||||
local opts = utils.merge(default_cmp_opts, config.autocomplete or {})
|
||||
local opts = utils.merge(default_cmp_opts, user_config.nvim_cmp or {})
|
||||
|
||||
cmp.setup(opts)
|
||||
|
||||
|
|
|
@ -97,10 +97,6 @@ CosmicNvim comes with first-class support for the following themes:
|
|||
|
||||
[Cosmic configurations](./lua/cosmic/config/examples/config.lua)
|
||||
|
||||
[Plugin configurations](./lua/cosmic/config/examples/plugins.lua)
|
||||
|
||||
[Add additional mappings](./lua/cosmic/config/examples/mappings.lua)
|
||||
|
||||
[Add additional vim options](./lua/cosmic/config/examples/editor.lua)
|
||||
|
||||
## ✨ Cosmic Commands
|
||||
|
|
Loading…
Add table
Reference in a new issue