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 null_ls = require('null-ls')
|
||||||
|
|
||||||
local config = {
|
local config = {
|
||||||
-- See :h cmp-usage
|
|
||||||
autocomplete = {},
|
|
||||||
|
|
||||||
-- See https://github.com/rmagatti/auto-session#%EF%B8%8F-configuration
|
-- See https://github.com/rmagatti/auto-session#%EF%B8%8F-configuration
|
||||||
auto_session = {},
|
auto_session = {},
|
||||||
|
|
||||||
|
@ -14,7 +11,7 @@ local config = {
|
||||||
border = 'rounded',
|
border = 'rounded',
|
||||||
|
|
||||||
-- https://github.com/numToStr/Comment.nvim#configuration-optional
|
-- https://github.com/numToStr/Comment.nvim#configuration-optional
|
||||||
comments = {},
|
comment_nvim = {},
|
||||||
|
|
||||||
-- See https://github.com/CosmicNvim/cosmic-ui#%EF%B8%8F-configuration
|
-- See https://github.com/CosmicNvim/cosmic-ui#%EF%B8%8F-configuration
|
||||||
cosmic_ui = {},
|
cosmic_ui = {},
|
||||||
|
@ -53,11 +50,12 @@ local config = {
|
||||||
},
|
},
|
||||||
|
|
||||||
-- See Cosmic defaults lsp/providers/null_ls.lua
|
-- 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 = {},
|
null_ls = {},
|
||||||
},
|
},
|
||||||
|
|
||||||
-- See Cosmic defaults lsp/providers/tsserver.lua
|
-- 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 = {},
|
ts_utils = {},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -96,9 +94,39 @@ local config = {
|
||||||
|
|
||||||
-- See :h notify.setup
|
-- See :h notify.setup
|
||||||
notify = {},
|
notify = {},
|
||||||
|
--
|
||||||
|
-- See :h cmp-usage
|
||||||
|
nvim_cmp = {},
|
||||||
|
|
||||||
-- See :h nvim-tree.setup
|
-- See :h nvim-tree.setup
|
||||||
nvim_tree = {},
|
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
|
return config
|
||||||
|
|
|
@ -1,12 +1,30 @@
|
||||||
-- Override Cosmic editor options
|
-- Override Cosmic editor options
|
||||||
|
|
||||||
local opt = vim.opt
|
|
||||||
local g = vim.g
|
local g = vim.g
|
||||||
|
local map = require('cosmic.utils').map
|
||||||
|
local opt = vim.opt
|
||||||
|
|
||||||
-- Default leader is <space>
|
-- Default leader is <space>
|
||||||
g.mapleader = ','
|
g.mapleader = ','
|
||||||
|
|
||||||
-- Default indent = 2
|
-- Default indent = 2
|
||||||
opt.tabstop = 4
|
|
||||||
opt.softtabstop = 4
|
|
||||||
opt.shiftwidth = 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/config.lua
|
||||||
- cosmic/config/editor.lua
|
- cosmic/config/editor.lua
|
||||||
- cosmic/config/mappings.lua
|
|
||||||
- cosmic/config/plugins.lua
|
|
||||||
- cosmic/config/utils.lua
|
- cosmic/config/utils.lua
|
||||||
|
|
||||||
Please look at the examples in this directory in order to get started.
|
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
|
# from project root
|
||||||
cp ./lua/cosmic/config/examples/config.lua ./lua/cosmic/config/config.lua
|
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/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
|
cp ./lua/cosmic/config/examples/utils.lua ./lua/cosmic/config/utils.lua
|
||||||
```
|
```
|
||||||
|
|
|
@ -3,9 +3,8 @@ local cosmic_modules = {
|
||||||
'cosmic.core.pluginsInit',
|
'cosmic.core.pluginsInit',
|
||||||
'cosmic.core.commands',
|
'cosmic.core.commands',
|
||||||
'cosmic.core.editor',
|
'cosmic.core.editor',
|
||||||
'cosmic.config.editor',
|
|
||||||
'cosmic.core.mappings',
|
'cosmic.core.mappings',
|
||||||
'cosmic.config.mappings',
|
'cosmic.config.editor',
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, mod in ipairs(cosmic_modules) do
|
for _, mod in ipairs(cosmic_modules) do
|
||||||
|
|
|
@ -7,19 +7,19 @@ end
|
||||||
local packer = cosmic_packer.packer
|
local packer = cosmic_packer.packer
|
||||||
local use = packer.use
|
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
|
if not ok then
|
||||||
user_plugins = {
|
user_config = {
|
||||||
add = {},
|
add = {},
|
||||||
disable = {},
|
disable = {},
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
if not vim.tbl_islist(user_plugins.add) then
|
if not vim.tbl_islist(user_config.add) then
|
||||||
user_plugins.add = {}
|
user_config.add_plugins = {}
|
||||||
end
|
end
|
||||||
if not vim.tbl_islist(user_plugins.disable) then
|
if not vim.tbl_islist(user_config.disable) then
|
||||||
user_plugins.disable = {}
|
user_config.disable_builtin_plugins = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
local config = require('cosmic.config')
|
local config = require('cosmic.config')
|
||||||
|
@ -41,7 +41,7 @@ return packer.startup(function()
|
||||||
require('cosmic.plugins.notify')
|
require('cosmic.plugins.notify')
|
||||||
end,
|
end,
|
||||||
after = config.theme,
|
after = config.theme,
|
||||||
disable = vim.tbl_contains(user_plugins.disable, 'notify'),
|
disable = vim.tbl_contains(user_config.disable_builtin_plugins, 'notify'),
|
||||||
})
|
})
|
||||||
|
|
||||||
-- theme stuff
|
-- theme stuff
|
||||||
|
@ -53,7 +53,7 @@ return packer.startup(function()
|
||||||
require('cosmic.plugins.galaxyline')
|
require('cosmic.plugins.galaxyline')
|
||||||
end,
|
end,
|
||||||
after = config.theme,
|
after = config.theme,
|
||||||
disable = vim.tbl_contains(user_plugins.disable, 'statusline'),
|
disable = vim.tbl_contains(user_config.disable_builtin_plugins, 'galaxyline'),
|
||||||
})
|
})
|
||||||
|
|
||||||
-- file explorer
|
-- file explorer
|
||||||
|
@ -71,7 +71,7 @@ return packer.startup(function()
|
||||||
'NvimTreeRefresh',
|
'NvimTreeRefresh',
|
||||||
'NvimTreeToggle',
|
'NvimTreeToggle',
|
||||||
},
|
},
|
||||||
disable = vim.tbl_contains(user_plugins.disable, 'nvim-tree'),
|
disable = vim.tbl_contains(user_config.disable_builtin_plugins, 'nvim-tree'),
|
||||||
})
|
})
|
||||||
|
|
||||||
use({
|
use({
|
||||||
|
@ -98,7 +98,7 @@ return packer.startup(function()
|
||||||
config = function()
|
config = function()
|
||||||
require('cosmic.lsp.providers.null_ls')
|
require('cosmic.lsp.providers.null_ls')
|
||||||
end,
|
end,
|
||||||
disable = vim.tbl_contains(user_plugins.disable, 'null-ls'),
|
disable = vim.tbl_contains(user_config.disable_builtin_plugins, 'null-ls'),
|
||||||
after = 'nvim-lspconfig',
|
after = 'nvim-lspconfig',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -107,7 +107,7 @@ return packer.startup(function()
|
||||||
require('cosmic.plugins.lsp-signature')
|
require('cosmic.plugins.lsp-signature')
|
||||||
end,
|
end,
|
||||||
after = 'nvim-lspconfig',
|
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',
|
event = 'InsertEnter',
|
||||||
disable = vim.tbl_contains(user_plugins.disable, 'autocomplete'),
|
disable = vim.tbl_contains(user_config.disable_builtin_plugins, 'nvim-cmp'),
|
||||||
})
|
})
|
||||||
|
|
||||||
-- git commands
|
-- git commands
|
||||||
|
@ -150,7 +150,7 @@ return packer.startup(function()
|
||||||
'tpope/vim-fugitive',
|
'tpope/vim-fugitive',
|
||||||
opt = true,
|
opt = true,
|
||||||
cmd = 'Git',
|
cmd = 'Git',
|
||||||
disable = vim.tbl_contains(user_plugins.disable, 'fugitive'),
|
disable = vim.tbl_contains(user_config.disable_builtin_plugins, 'fugitive'),
|
||||||
})
|
})
|
||||||
|
|
||||||
-- git column signs
|
-- git column signs
|
||||||
|
@ -162,7 +162,7 @@ return packer.startup(function()
|
||||||
config = function()
|
config = function()
|
||||||
require('cosmic.plugins.gitsigns')
|
require('cosmic.plugins.gitsigns')
|
||||||
end,
|
end,
|
||||||
disable = vim.tbl_contains(user_plugins.disable, 'gitsigns'),
|
disable = vim.tbl_contains(user_config.disable_builtin_plugins, 'gitsigns'),
|
||||||
})
|
})
|
||||||
|
|
||||||
-- floating terminal
|
-- floating terminal
|
||||||
|
@ -173,7 +173,7 @@ return packer.startup(function()
|
||||||
config = function()
|
config = function()
|
||||||
require('cosmic.plugins.terminal')
|
require('cosmic.plugins.terminal')
|
||||||
end,
|
end,
|
||||||
disable = vim.tbl_contains(user_plugins.disable, 'terminal'),
|
disable = vim.tbl_contains(user_config.disable_builtin_plugins, 'terminal'),
|
||||||
})
|
})
|
||||||
|
|
||||||
-- file navigation
|
-- file navigation
|
||||||
|
@ -192,7 +192,7 @@ return packer.startup(function()
|
||||||
require('cosmic.plugins.telescope')
|
require('cosmic.plugins.telescope')
|
||||||
end,
|
end,
|
||||||
event = 'BufWinEnter',
|
event = 'BufWinEnter',
|
||||||
disable = vim.tbl_contains(user_plugins.disable, 'telescope'),
|
disable = vim.tbl_contains(user_config.disable_builtin_plugins, 'telescope'),
|
||||||
})
|
})
|
||||||
|
|
||||||
-- session/project management
|
-- session/project management
|
||||||
|
@ -201,7 +201,7 @@ return packer.startup(function()
|
||||||
config = function()
|
config = function()
|
||||||
require('cosmic.plugins.dashboard')
|
require('cosmic.plugins.dashboard')
|
||||||
end,
|
end,
|
||||||
disable = vim.tbl_contains(user_plugins.disable, 'dashboard'),
|
disable = vim.tbl_contains(user_config.disable_builtin_plugins, 'dashboard'),
|
||||||
})
|
})
|
||||||
|
|
||||||
use({
|
use({
|
||||||
|
@ -209,7 +209,7 @@ return packer.startup(function()
|
||||||
config = function()
|
config = function()
|
||||||
require('cosmic.plugins.auto-session')
|
require('cosmic.plugins.auto-session')
|
||||||
end,
|
end,
|
||||||
disable = vim.tbl_contains(user_plugins.disable, 'auto-session'),
|
disable = vim.tbl_contains(user_config.disable_builtin_plugins, 'auto-session'),
|
||||||
})
|
})
|
||||||
|
|
||||||
-- lang/syntax stuff
|
-- lang/syntax stuff
|
||||||
|
@ -224,7 +224,7 @@ return packer.startup(function()
|
||||||
config = function()
|
config = function()
|
||||||
require('cosmic.plugins.treesitter')
|
require('cosmic.plugins.treesitter')
|
||||||
end,
|
end,
|
||||||
disable = vim.tbl_contains(user_plugins.disable, 'treesitter'),
|
disable = vim.tbl_contains(user_config.disable_builtin_plugins, 'treesitter'),
|
||||||
})
|
})
|
||||||
|
|
||||||
-- comments and stuff
|
-- comments and stuff
|
||||||
|
@ -234,6 +234,7 @@ return packer.startup(function()
|
||||||
require('cosmic.plugins.comments')
|
require('cosmic.plugins.comments')
|
||||||
end,
|
end,
|
||||||
event = 'BufWinEnter',
|
event = 'BufWinEnter',
|
||||||
|
disable = vim.tbl_contains(user_config.disable_builtin_plugins, 'comment-nvim'),
|
||||||
})
|
})
|
||||||
|
|
||||||
-- todo highlights
|
-- todo highlights
|
||||||
|
@ -244,7 +245,7 @@ return packer.startup(function()
|
||||||
require('cosmic.plugins.todo-comments')
|
require('cosmic.plugins.todo-comments')
|
||||||
end,
|
end,
|
||||||
event = 'BufWinEnter',
|
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
|
-- colorized hex codes
|
||||||
use({
|
use({
|
||||||
|
@ -254,11 +255,11 @@ return packer.startup(function()
|
||||||
config = function()
|
config = function()
|
||||||
require('colorizer').setup()
|
require('colorizer').setup()
|
||||||
end,
|
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
|
if user_config.add_plugins and not vim.tbl_isempty(user_config.add_plugins) then
|
||||||
for _, plugin in pairs(user_plugins.add) do
|
for _, plugin in pairs(user_config.add_plugins) do
|
||||||
use(plugin)
|
use(plugin)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -31,6 +31,11 @@ require('null-ls').setup(utils.merge({
|
||||||
null_ls.builtins.formatting.prettier.with({
|
null_ls.builtins.formatting.prettier.with({
|
||||||
prefer_local = 'node_modules/.bin',
|
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.formatting.stylua,
|
||||||
null_ls.builtins.code_actions.gitsigns,
|
null_ls.builtins.code_actions.gitsigns,
|
||||||
},
|
},
|
||||||
|
|
|
@ -16,4 +16,4 @@ require('Comment').setup(utils.merge({
|
||||||
location = location,
|
location = location,
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
}, config.comments or {}))
|
}, config.comment_nvim or {}))
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
local cmp = require('cmp')
|
local cmp = require('cmp')
|
||||||
local utils = require('cosmic.utils')
|
local utils = require('cosmic.utils')
|
||||||
local luasnip = require('luasnip')
|
local luasnip = require('luasnip')
|
||||||
local config = require('cosmic.config')
|
local user_config = require('cosmic.config')
|
||||||
local icons = require('cosmic.theme.icons')
|
local icons = require('cosmic.theme.icons')
|
||||||
|
|
||||||
local has_words_before = function()
|
local has_words_before = function()
|
||||||
|
@ -56,7 +56,7 @@ local default_cmp_opts = {
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
documentation = {
|
documentation = {
|
||||||
border = config.border,
|
border = user_config.border,
|
||||||
winhighlight = 'FloatBorder:FloatBorder,Normal:Normal',
|
winhighlight = 'FloatBorder:FloatBorder,Normal:Normal',
|
||||||
},
|
},
|
||||||
experimental = {
|
experimental = {
|
||||||
|
@ -89,7 +89,7 @@ vim.cmd([[
|
||||||
autocmd FileType TelescopePrompt lua require('cmp').setup.buffer { enabled = false }
|
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)
|
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)
|
[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)
|
[Add additional vim options](./lua/cosmic/config/examples/editor.lua)
|
||||||
|
|
||||||
## ✨ Cosmic Commands
|
## ✨ Cosmic Commands
|
||||||
|
|
Loading…
Add table
Reference in a new issue