Lazy.nvim (#88)
* feat: init lazy.nvim * refactor: easy plugin init * feat: user defined plugins * refactor: clean up user config * refactor: clean up lsp plugins * fix: lsp signature * fix: null ls user config * feat: replace commands * feat: optimize lazy loading * fix: lsp_signature working * fix: documentation hover/sig help * fix: autopairs * feat: clean up luasnips * fix auto complete * moar laziness * feat: add markdown_inline to ensured_installed for TS * clean up * clean up auto-session
This commit is contained in:
parent
2aca7635e5
commit
daaafc1f8d
47 changed files with 913 additions and 1045 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -2,6 +2,8 @@ pack/**
|
|||
sessions/**
|
||||
.netrwhist
|
||||
plugin/
|
||||
minimal.lua
|
||||
.repro
|
||||
lua/cosmic/compiled.lua
|
||||
lua/cosmic/config/editor.lua
|
||||
lua/cosmic/config/config.lua
|
||||
|
|
8
init.lua
8
init.lua
|
@ -2,14 +2,6 @@ if vim.fn.has('nvim-0.8') == 0 then
|
|||
error('Need Neovim v0.8+ in order to run Cosmic!')
|
||||
end
|
||||
|
||||
do
|
||||
local ok, _ = pcall(require, 'impatient')
|
||||
|
||||
if not ok then
|
||||
vim.notify('impatient.nvim not installed', vim.log.levels.WARN)
|
||||
end
|
||||
end
|
||||
|
||||
local ok, err = pcall(require, 'cosmic')
|
||||
|
||||
if not ok then
|
||||
|
|
|
@ -4,18 +4,8 @@
|
|||
-- local null_ls = require('null-ls')
|
||||
|
||||
local config = {
|
||||
-- See https://github.com/rmagatti/auto-session#%EF%B8%8F-configuration
|
||||
auto_session = {},
|
||||
-- See :h nvim_open_win for possible border options
|
||||
border = 'rounded',
|
||||
-- https://github.com/numToStr/Comment.nvim#configuration-optional
|
||||
comment_nvim = {},
|
||||
-- See https://github.com/CosmicNvim/cosmic-ui#%EF%B8%8F-configuration
|
||||
cosmic_ui = {},
|
||||
-- See :h vim.diagnostic.config for all diagnostic configuration options
|
||||
diagnostic = {},
|
||||
-- See :h gitsigns-usage
|
||||
gitsigns = {},
|
||||
-- LSP settings
|
||||
lsp = {
|
||||
-- True/false or table of filetypes {'.ts', '.js',}
|
||||
|
@ -47,35 +37,61 @@ local config = {
|
|||
null_ls = {
|
||||
-- Disable default list of sources provided by CosmicNvim
|
||||
default_cosmic_sources = false,
|
||||
--disable formatting
|
||||
format = false,
|
||||
-- Add additional sources here
|
||||
sources = {},
|
||||
get_sources = function()
|
||||
local null_ls = require('null-ls')
|
||||
return {
|
||||
null_ls.builtins.diagnostics.shellcheck,
|
||||
null_ls.builtins.diagnostics.actionlint.with({
|
||||
condition = function()
|
||||
local cwd = vim.fn.expand('%:p:.')
|
||||
return cwd:find('.github/workflows')
|
||||
end,
|
||||
}),
|
||||
}
|
||||
end,
|
||||
},
|
||||
},
|
||||
-- See Cosmic defaults lsp/providers/tsserver.lua
|
||||
ts_utils = {},
|
||||
},
|
||||
-- See https://github.com/ray-x/lsp_signature.nvim#full-configuration-with-default-values
|
||||
lsp_signature = {},
|
||||
-- See https://github.com/nvim-lualine/lualine.nvim#default-configuration
|
||||
lualine = {},
|
||||
-- See https://github.com/L3MON4D3/LuaSnip/blob/577045e9adf325e58f690f4d4b4a293f3dcec1b3/README.md#config
|
||||
luasnip = {},
|
||||
-- See :h telescope.setup
|
||||
telescope = {},
|
||||
-- See https://github.com/folke/todo-comments.nvim#%EF%B8%8F-configuration
|
||||
todo_comments = {},
|
||||
-- See :h nvim-treesitter-quickstart
|
||||
treesitter = {},
|
||||
-- See :h cmp-usage
|
||||
nvim_cmp = {},
|
||||
-- See :h nvim-tree.setup
|
||||
nvim_tree = {},
|
||||
-- Add additional plugins
|
||||
-- adjust build in plugin settings
|
||||
plugins = {
|
||||
-- See https://github.com/rmagatti/auto-session#%EF%B8%8F-configuration
|
||||
auto_session = {},
|
||||
-- https://github.com/numToStr/Comment.nvim#configuration-optional
|
||||
comment_nvim = {},
|
||||
-- See https://github.com/CosmicNvim/cosmic-ui#%EF%B8%8F-configuration
|
||||
cosmic_ui = {},
|
||||
-- See :h vim.diagnostic.config for all diagnostic configuration options
|
||||
diagnostic = {},
|
||||
-- See :h gitsigns-usage
|
||||
gitsigns = {},
|
||||
-- See https://github.com/ray-x/lsp_signature.nvim#full-configuration-with-default-values
|
||||
lsp_signature = {},
|
||||
-- See https://github.com/nvim-lualine/lualine.nvim#default-configuration
|
||||
lualine = {},
|
||||
-- See https://github.com/L3MON4D3/LuaSnip/blob/577045e9adf325e58f690f4d4b4a293f3dcec1b3/README.md#config
|
||||
luasnip = {},
|
||||
-- See :h telescope.setup
|
||||
telescope = {},
|
||||
-- See https://github.com/folke/todo-comments.nvim#%EF%B8%8F-configuration
|
||||
todo_comments = {},
|
||||
-- See :h nvim-treesitter-quickstart
|
||||
treesitter = {},
|
||||
-- See :h cmp-usage
|
||||
nvim_cmp = {},
|
||||
-- See :h nvim-tree.setup
|
||||
nvim_tree = {},
|
||||
},
|
||||
-- Add additional plugins (lazy.nvim)
|
||||
add_plugins = {
|
||||
'ggandor/lightspeed.nvim',
|
||||
{
|
||||
'romgrk/barbar.nvim',
|
||||
requires = { 'kyazdani42/nvim-web-devicons' },
|
||||
dependencies = { 'kyazdani42/nvim-web-devicons' },
|
||||
},
|
||||
},
|
||||
-- Disable plugins enabled by CosmicNvim
|
||||
|
|
|
@ -7,7 +7,6 @@ vim.api.nvim_create_autocmd('VimResized', {
|
|||
|
||||
vim.cmd([[
|
||||
command! CosmicUpdate lua require('cosmic.utils.cosmic').update()
|
||||
command! CosmicReload lua require('cosmic.utils.cosmic').reload_user_config(true)
|
||||
command! CosmicReloadSync lua require('cosmic.utils.cosmic').reload_user_config_sync()
|
||||
command! CosmicSync lua require('cosmic.utils.cosmic').sync_plugins(true)
|
||||
command! LspFormat lua vim.lsp.buf.format()
|
||||
]])
|
||||
|
|
|
@ -2,11 +2,26 @@ local cosmic_modules = {
|
|||
'cosmic.core.disabled',
|
||||
'cosmic.core.editor',
|
||||
'cosmic.core.pluginsInit',
|
||||
'cosmic.lsp',
|
||||
'cosmic.core.commands',
|
||||
'cosmic.core.mappings',
|
||||
'cosmic.config.editor',
|
||||
}
|
||||
|
||||
-- set up lazy.nvim to install plugins
|
||||
local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim'
|
||||
if not vim.loop.fs_stat(lazypath) then
|
||||
vim.fn.system({
|
||||
'git',
|
||||
'clone',
|
||||
'--filter=blob:none',
|
||||
'--single-branch',
|
||||
'https://github.com/folke/lazy.nvim.git',
|
||||
lazypath,
|
||||
})
|
||||
end
|
||||
vim.opt.runtimepath:prepend(lazypath)
|
||||
|
||||
for _, mod in ipairs(cosmic_modules) do
|
||||
local ok, err = pcall(require, mod)
|
||||
if not ok and not mod:find('cosmic.config') then
|
||||
|
|
|
@ -1,252 +1,6 @@
|
|||
local user_config = require('cosmic.core.user')
|
||||
local cosmic_packer = require('cosmic.packer')
|
||||
local packer = cosmic_packer.packer
|
||||
local use = packer.use
|
||||
|
||||
return packer.startup(function()
|
||||
use({
|
||||
'wbthomason/packer.nvim',
|
||||
'lewis6991/impatient.nvim',
|
||||
'nvim-lua/plenary.nvim',
|
||||
})
|
||||
|
||||
use({
|
||||
'folke/noice.nvim',
|
||||
config = function()
|
||||
require('cosmic.plugins.noice')
|
||||
end,
|
||||
requires = {
|
||||
'MunifTanjim/nui.nvim',
|
||||
{
|
||||
'rcarriga/nvim-notify',
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
-- initialize theme plugins
|
||||
use({ -- color scheme
|
||||
'folke/tokyonight.nvim',
|
||||
as = 'tokyonight',
|
||||
config = function()
|
||||
-- set up theme
|
||||
require('cosmic.plugins.tokyonight')
|
||||
end,
|
||||
disable = vim.tbl_contains(user_config.disable_builtin_plugins, 'tokyonight'),
|
||||
})
|
||||
|
||||
-- theme stuff
|
||||
use({
|
||||
'nvim-lualine/lualine.nvim',
|
||||
config = function()
|
||||
require('cosmic.plugins.lualine')
|
||||
end,
|
||||
requires = { 'nvim-tree/nvim-web-devicons' },
|
||||
disable = vim.tbl_contains(user_config.disable_builtin_plugins, 'lualine'),
|
||||
})
|
||||
|
||||
-- file explorer
|
||||
use({
|
||||
'kyazdani42/nvim-tree.lua',
|
||||
config = function()
|
||||
require('cosmic.plugins.nvim-tree')
|
||||
end,
|
||||
cmd = {
|
||||
'NvimTreeClipboard',
|
||||
'NvimTreeClose',
|
||||
'NvimTreeFindFile',
|
||||
'NvimTreeOpen',
|
||||
'NvimTreeRefresh',
|
||||
'NvimTreeToggle',
|
||||
},
|
||||
disable = vim.tbl_contains(user_config.disable_builtin_plugins, 'nvim-tree'),
|
||||
event = 'VimEnter',
|
||||
})
|
||||
|
||||
use({
|
||||
'CosmicNvim/cosmic-ui',
|
||||
requires = {
|
||||
'MunifTanjim/nui.nvim',
|
||||
},
|
||||
config = function()
|
||||
require('cosmic.plugins.cosmic-ui')
|
||||
end,
|
||||
event = 'BufWinEnter',
|
||||
})
|
||||
|
||||
use({
|
||||
'neovim/nvim-lspconfig',
|
||||
config = function()
|
||||
require('cosmic.lsp')
|
||||
end,
|
||||
requires = {
|
||||
{ 'b0o/SchemaStore.nvim' },
|
||||
{ 'williamboman/nvim-lsp-installer' },
|
||||
{ 'jose-elias-alvarez/nvim-lsp-ts-utils' },
|
||||
{
|
||||
'jose-elias-alvarez/null-ls.nvim',
|
||||
config = function()
|
||||
require('cosmic.lsp.providers.null_ls')
|
||||
end,
|
||||
disable = vim.tbl_contains(user_config.disable_builtin_plugins, 'null-ls'),
|
||||
after = 'nvim-lspconfig',
|
||||
},
|
||||
},
|
||||
event = 'BufWinEnter',
|
||||
})
|
||||
|
||||
-- autocompletion
|
||||
use({
|
||||
'hrsh7th/nvim-cmp',
|
||||
config = function()
|
||||
require('cosmic.plugins.nvim-cmp')
|
||||
end,
|
||||
requires = {
|
||||
{
|
||||
'L3MON4D3/LuaSnip',
|
||||
config = function()
|
||||
require('cosmic.plugins.luasnip')
|
||||
end,
|
||||
requires = {
|
||||
'rafamadriz/friendly-snippets',
|
||||
},
|
||||
},
|
||||
{ 'hrsh7th/cmp-nvim-lsp', after = 'nvim-cmp' },
|
||||
{ 'saadparwaiz1/cmp_luasnip', after = 'nvim-cmp' },
|
||||
{ 'hrsh7th/cmp-buffer', after = 'nvim-cmp' },
|
||||
{ 'hrsh7th/cmp-nvim-lua', after = 'nvim-cmp' },
|
||||
{ 'hrsh7th/cmp-path', after = 'nvim-cmp' },
|
||||
{
|
||||
'windwp/nvim-autopairs',
|
||||
config = function()
|
||||
require('cosmic.plugins.auto-pairs')
|
||||
end,
|
||||
after = 'nvim-cmp',
|
||||
},
|
||||
},
|
||||
event = 'InsertEnter',
|
||||
disable = vim.tbl_contains(user_config.disable_builtin_plugins, 'nvim-cmp'),
|
||||
})
|
||||
|
||||
-- git commands
|
||||
use({
|
||||
'tpope/vim-fugitive',
|
||||
opt = true,
|
||||
cmd = 'Git',
|
||||
disable = vim.tbl_contains(user_config.disable_builtin_plugins, 'fugitive'),
|
||||
})
|
||||
|
||||
-- git column signs
|
||||
use({
|
||||
'lewis6991/gitsigns.nvim',
|
||||
requires = { 'nvim-lua/plenary.nvim' },
|
||||
opt = true,
|
||||
event = 'BufWinEnter',
|
||||
config = function()
|
||||
require('cosmic.plugins.gitsigns')
|
||||
end,
|
||||
disable = vim.tbl_contains(user_config.disable_builtin_plugins, 'gitsigns'),
|
||||
})
|
||||
|
||||
-- floating terminal
|
||||
use({
|
||||
'voldikss/vim-floaterm',
|
||||
opt = true,
|
||||
event = 'BufWinEnter',
|
||||
config = function()
|
||||
require('cosmic.plugins.terminal')
|
||||
end,
|
||||
disable = vim.tbl_contains(user_config.disable_builtin_plugins, 'terminal'),
|
||||
})
|
||||
|
||||
-- file navigation
|
||||
use({
|
||||
'nvim-telescope/telescope.nvim',
|
||||
requires = {
|
||||
'nvim-lua/popup.nvim',
|
||||
'nvim-lua/plenary.nvim',
|
||||
{
|
||||
'nvim-telescope/telescope-fzf-native.nvim',
|
||||
run = 'make',
|
||||
},
|
||||
},
|
||||
config = function()
|
||||
require('cosmic.plugins.telescope.mappings').init()
|
||||
require('cosmic.plugins.telescope')
|
||||
end,
|
||||
event = 'BufWinEnter',
|
||||
disable = vim.tbl_contains(user_config.disable_builtin_plugins, 'telescope'),
|
||||
})
|
||||
|
||||
-- session/project management
|
||||
use({
|
||||
'glepnir/dashboard-nvim',
|
||||
config = function()
|
||||
require('cosmic.plugins.dashboard')
|
||||
end,
|
||||
disable = vim.tbl_contains(user_config.disable_builtin_plugins, 'dashboard'),
|
||||
})
|
||||
|
||||
use({
|
||||
'rmagatti/auto-session',
|
||||
config = function()
|
||||
require('cosmic.plugins.auto-session')
|
||||
end,
|
||||
disable = vim.tbl_contains(user_config.disable_builtin_plugins, 'auto-session'),
|
||||
})
|
||||
|
||||
-- lang/syntax stuff
|
||||
use({
|
||||
'nvim-treesitter/nvim-treesitter',
|
||||
requires = {
|
||||
'windwp/nvim-ts-autotag',
|
||||
'JoosepAlviste/nvim-ts-context-commentstring',
|
||||
'nvim-treesitter/nvim-treesitter-refactor',
|
||||
},
|
||||
run = ':TSUpdate',
|
||||
config = function()
|
||||
require('cosmic.plugins.treesitter')
|
||||
end,
|
||||
disable = vim.tbl_contains(user_config.disable_builtin_plugins, 'treesitter'),
|
||||
})
|
||||
|
||||
-- comments and stuff
|
||||
use({
|
||||
'numToStr/Comment.nvim',
|
||||
config = function()
|
||||
require('cosmic.plugins.comments')
|
||||
end,
|
||||
event = 'BufWinEnter',
|
||||
disable = vim.tbl_contains(user_config.disable_builtin_plugins, 'comment-nvim'),
|
||||
})
|
||||
|
||||
-- todo highlights
|
||||
use({
|
||||
'folke/todo-comments.nvim',
|
||||
requires = 'nvim-lua/plenary.nvim',
|
||||
config = function()
|
||||
require('cosmic.plugins.todo-comments')
|
||||
end,
|
||||
event = 'BufWinEnter',
|
||||
disable = vim.tbl_contains(user_config.disable_builtin_plugins, 'todo-comments'),
|
||||
})
|
||||
-- colorized hex codes
|
||||
use({
|
||||
'norcalli/nvim-colorizer.lua',
|
||||
opt = true,
|
||||
cmd = { 'ColorizerToggle' },
|
||||
config = function()
|
||||
require('colorizer').setup()
|
||||
end,
|
||||
disable = vim.tbl_contains(user_config.disable_builtin_plugins, 'colorizer'),
|
||||
})
|
||||
|
||||
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
|
||||
|
||||
if cosmic_packer.first_install then
|
||||
packer.sync()
|
||||
end
|
||||
end)
|
||||
require('lazy').setup('cosmic.plugins', {
|
||||
defaults = { lazy = true },
|
||||
ui = {
|
||||
border = 'rounded',
|
||||
},
|
||||
})
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
-- DEFAULT USER SETTINGS
|
||||
local ok, user_config = pcall(require, 'cosmic.config.config')
|
||||
|
||||
if not ok then
|
||||
user_config = {}
|
||||
end
|
||||
local user_config = require('cosmic.config.config')
|
||||
|
||||
local default_config = {
|
||||
border = 'rounded',
|
||||
|
|
|
@ -1,15 +1,10 @@
|
|||
local mods = {
|
||||
'cosmic.compiled',
|
||||
'cosmic.core',
|
||||
}
|
||||
|
||||
for _, mod in ipairs(mods) do
|
||||
local ok, err = pcall(require, mod)
|
||||
if mod == 'cosmic.compiled' and not ok then
|
||||
vim.notify('Run :PackerCompile!', vim.log.levels.WARN, {
|
||||
title = 'CosmicNvim',
|
||||
})
|
||||
elseif not ok and not mod:find('cosmic.core.user') then
|
||||
if not ok and not mod:find('cosmic.core.user') then
|
||||
error(('Error loading %s...\n\n%s'):format(mod, err))
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,16 +1,12 @@
|
|||
local config = require('cosmic.core.user')
|
||||
|
||||
-- set up lsp servers
|
||||
require('cosmic.lsp.providers')
|
||||
require('cosmic.lsp.diagnostics')
|
||||
require('cosmic.lsp.commands')
|
||||
|
||||
-- currently handled by noice
|
||||
--
|
||||
vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, {
|
||||
border = config.border,
|
||||
})
|
||||
|
||||
-- handled via noice
|
||||
--[[ vim.lsp.handlers['textDocument/signatureHelp'] = vim.lsp.with(vim.lsp.handlers.signature_help, { ]]
|
||||
--[[ border = config.border, ]]
|
||||
--[[ border = user_config.border, ]]
|
||||
--[[ }) ]]
|
||||
--[[]]
|
||||
--[[ vim.lsp.handlers['textDocument/hover'] = vim.lsp.with(vim.lsp.handlers.hover, { ]]
|
||||
--[[ border = user_config.border, ]]
|
||||
--[[ }) ]]
|
||||
|
|
|
@ -34,9 +34,6 @@ function M.init(client, bufnr)
|
|||
set_keymap('n', '<leader>gf', '<cmd>lua vim.lsp.buf.formatting()<cr>')
|
||||
set_keymap('v', '<leader>gf', '<cmd>lua vim.lsp.buf.range_formatting()<cr>')
|
||||
|
||||
-- signature help
|
||||
set_keymap('n', '<C-K>', '<cmd>lua require("lsp_signature").signature()<cr>')
|
||||
|
||||
-- lsp workspace
|
||||
set_keymap('n', '<leader>wd', '<cmd>Telescope diagnostics<cr>')
|
||||
set_keymap('n', '<leader>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<cr>')
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
local capabilities = require('cmp_nvim_lsp').default_capabilities()
|
||||
local M = {}
|
||||
|
||||
function M.on_attach(client, bufnr)
|
||||
|
@ -15,7 +16,7 @@ M.flags = {
|
|||
debounce_text_changes = 150,
|
||||
}
|
||||
|
||||
M.capabilities = {}
|
||||
M.capabilities = capabilities
|
||||
|
||||
M.root_dir = function(fname)
|
||||
local util = require('lspconfig').util
|
||||
|
|
|
@ -1,46 +1,11 @@
|
|||
local u = require('cosmic.utils')
|
||||
local default_on_attach = require('cosmic.lsp.providers.defaults').on_attach
|
||||
local config = require('cosmic.core.user')
|
||||
local M = {}
|
||||
|
||||
function M.on_attach(client, bufnr)
|
||||
default_on_attach(client, bufnr)
|
||||
|
||||
local ts_utils = require('nvim-lsp-ts-utils')
|
||||
|
||||
-- defaults
|
||||
ts_utils.setup(u.merge({
|
||||
debug = false,
|
||||
disable_commands = false,
|
||||
enable_import_on_completion = true,
|
||||
|
||||
-- import all
|
||||
import_all_timeout = 5000, -- ms
|
||||
import_all_priorities = {
|
||||
buffers = 4, -- loaded buffer names
|
||||
buffer_content = 3, -- loaded buffer content
|
||||
local_files = 2, -- git files or files with relative path markers
|
||||
same_file = 1, -- add to existing import statement
|
||||
},
|
||||
import_all_scan_buffers = 100,
|
||||
import_all_select_source = false,
|
||||
|
||||
-- inlay hints
|
||||
auto_inlay_hints = true,
|
||||
inlay_hints_highlight = 'Comment',
|
||||
|
||||
-- update imports on file move
|
||||
update_imports_on_move = true,
|
||||
require_confirmation_on_move = false,
|
||||
watch_dir = nil,
|
||||
|
||||
-- filter diagnostics
|
||||
filter_out_diagnostics_by_severity = {},
|
||||
filter_out_diagnostics_by_code = {},
|
||||
}, config.lsp.ts_utils or {}))
|
||||
|
||||
-- required to fix code action ranges and filter diagnostics
|
||||
ts_utils.setup_client(client)
|
||||
-- ts utils must be setup on "on_attach"
|
||||
require('cosmic.plugins.nvim-lsp-ts-utils.config').setup(client)
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
local cmd = vim.cmd
|
||||
|
||||
local present, packer = pcall(require, 'packer')
|
||||
|
||||
local first_install = false
|
||||
|
||||
if not present then
|
||||
local packer_path = vim.fn.stdpath('data') .. '/site/pack/packer/start/packer.nvim'
|
||||
|
||||
print('Cloning packer..')
|
||||
-- remove the dir before cloning
|
||||
vim.fn.delete(packer_path, 'rf')
|
||||
vim.fn.system({
|
||||
'git',
|
||||
'clone',
|
||||
'https://github.com/wbthomason/packer.nvim',
|
||||
'--depth',
|
||||
'20',
|
||||
packer_path,
|
||||
})
|
||||
|
||||
cmd('packadd packer.nvim')
|
||||
present, packer = pcall(require, 'packer')
|
||||
|
||||
if present then
|
||||
print('Packer cloned successfully.')
|
||||
first_install = true
|
||||
else
|
||||
error("Couldn't clone packer !\nPacker path: " .. packer_path .. '\n' .. packer)
|
||||
end
|
||||
end
|
||||
|
||||
packer.init({
|
||||
display = {
|
||||
open_fn = function()
|
||||
return require('packer.util').float({ border = 'rounded' })
|
||||
end,
|
||||
prompt_border = 'rounded',
|
||||
},
|
||||
git = {
|
||||
clone_timeout = 800, -- Timeout, in seconds, for git clones
|
||||
},
|
||||
compile_path = vim.fn.stdpath('config') .. '/lua/cosmic/compiled.lua',
|
||||
snapshot_path = vim.fn.stdpath('config') .. '/snapshots',
|
||||
auto_clean = true,
|
||||
compile_on_sync = true,
|
||||
})
|
||||
|
||||
return {
|
||||
packer = packer,
|
||||
first_install = first_install,
|
||||
}
|
|
@ -1,14 +1,19 @@
|
|||
require('nvim-autopairs').setup({
|
||||
check_ts = true,
|
||||
ts_config = {
|
||||
lua = { 'string', 'source' },
|
||||
javascript = { 'string', 'template_string' },
|
||||
java = false,
|
||||
},
|
||||
disable_filetype = { 'TelescopePrompt', 'vim' },
|
||||
fast_wrap = {},
|
||||
})
|
||||
local user_config = require('cosmic.core.user')
|
||||
local u = require('cosmic.utils')
|
||||
|
||||
local cmp_autopairs = require('nvim-autopairs.completion.cmp')
|
||||
local cmp = require('cmp')
|
||||
cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done({ map_char = { tex = '' } }))
|
||||
return {
|
||||
'windwp/nvim-autopairs',
|
||||
config = function()
|
||||
require('nvim-autopairs').setup(u.merge({
|
||||
check_ts = true,
|
||||
ts_config = {
|
||||
lua = { 'string', 'source' },
|
||||
javascript = { 'string', 'template_string' },
|
||||
java = false,
|
||||
},
|
||||
disable_filetype = { 'TelescopePrompt', 'vim' },
|
||||
fast_wrap = {},
|
||||
}, user_config.plugins.nvim_autopairs or {}))
|
||||
end,
|
||||
enabled = not vim.tbl_contains(user_config.disable_builtin_plugins, 'autopairs'),
|
||||
}
|
||||
|
|
|
@ -1,12 +1,19 @@
|
|||
local config = require('cosmic.core.user')
|
||||
local user_config = require('cosmic.core.user')
|
||||
local u = require('cosmic.utils')
|
||||
|
||||
local defaults = {
|
||||
pre_save_cmds = { 'NvimTreeClose', 'cclose', 'lua vim.notify.dismiss()' },
|
||||
post_restore_cmds = { 'NvimTreeRefresh' },
|
||||
auto_session_enabled = false,
|
||||
auto_save_enabled = true,
|
||||
auto_restore_enabled = false,
|
||||
auto_session_use_git_branch = true,
|
||||
}
|
||||
|
||||
require('auto-session').setup(u.merge(defaults, config.auto_session or {}))
|
||||
return {
|
||||
'rmagatti/auto-session',
|
||||
lazy = false,
|
||||
config = function()
|
||||
require('auto-session').setup(u.merge(defaults, user_config.plugins.auto_session or {}))
|
||||
end,
|
||||
enabled = not vim.tbl_contains(user_config.disable_builtin_plugins, 'auto-session'),
|
||||
}
|
||||
|
|
11
lua/cosmic/plugins/colorizer/init.lua
Normal file
11
lua/cosmic/plugins/colorizer/init.lua
Normal file
|
@ -0,0 +1,11 @@
|
|||
local user_config = require('cosmic.core.user')
|
||||
local u = require('cosmic.utils')
|
||||
|
||||
return {
|
||||
'norcalli/nvim-colorizer.lua',
|
||||
cmd = { 'ColorizerToggle' },
|
||||
config = function()
|
||||
require('colorizer').setup(u.merge({}, user_config.plugins.colorizer or {}))
|
||||
end,
|
||||
enabled = not vim.tbl_contains(user_config.disable_builtin_plugins, 'colorizer'),
|
||||
}
|
|
@ -1,19 +1,26 @@
|
|||
local config = require('cosmic.core.user')
|
||||
local user_config = require('cosmic.core.user')
|
||||
local u = require('cosmic.utils')
|
||||
|
||||
require('Comment').setup(u.merge({
|
||||
pre_hook = function(ctx)
|
||||
local U = require('Comment.utils')
|
||||
local location = nil
|
||||
if ctx.ctype == U.ctype.block then
|
||||
location = require('ts_context_commentstring.utils').get_cursor_location()
|
||||
elseif ctx.cmotion == U.cmotion.v or ctx.cmotion == U.cmotion.V then
|
||||
location = require('ts_context_commentstring.utils').get_visual_start_location()
|
||||
end
|
||||
return {
|
||||
'numToStr/Comment.nvim',
|
||||
config = function()
|
||||
require('Comment').setup(u.merge({
|
||||
pre_hook = function(ctx)
|
||||
local U = require('Comment.utils')
|
||||
local location = nil
|
||||
if ctx.ctype == U.ctype.block then
|
||||
location = require('ts_context_commentstring.utils').get_cursor_location()
|
||||
elseif ctx.cmotion == U.cmotion.v or ctx.cmotion == U.cmotion.V then
|
||||
location = require('ts_context_commentstring.utils').get_visual_start_location()
|
||||
end
|
||||
|
||||
return require('ts_context_commentstring.internal').calculate_commentstring({
|
||||
key = ctx.ctype == U.ctype.line and '__default' or '__multiline',
|
||||
location = location,
|
||||
})
|
||||
return require('ts_context_commentstring.internal').calculate_commentstring({
|
||||
key = ctx.ctype == U.ctype.line and '__default' or '__multiline',
|
||||
location = location,
|
||||
})
|
||||
end,
|
||||
}, user_config.plugins.comment_nvim or {}))
|
||||
end,
|
||||
}, config.comment_nvim or {}))
|
||||
event = 'BufEnter',
|
||||
enabled = not vim.tbl_contains(user_config.disable_builtin_plugins, 'comment-nvim'),
|
||||
}
|
||||
|
|
|
@ -1,8 +1,18 @@
|
|||
local config = require('cosmic.core.user')
|
||||
local user_config = require('cosmic.core.user')
|
||||
local u = require('cosmic.utils')
|
||||
|
||||
local defaults = {
|
||||
border_style = 'rounded',
|
||||
}
|
||||
|
||||
require('cosmic-ui').setup(u.merge(defaults, config.cosmic_ui or {}))
|
||||
return {
|
||||
'CosmicNvim/cosmic-ui',
|
||||
dependencies = {
|
||||
'MunifTanjim/nui.nvim',
|
||||
},
|
||||
config = function()
|
||||
require('cosmic-ui').setup(u.merge(defaults, user_config.plugins.cosmic_ui or {}))
|
||||
end,
|
||||
event = 'VeryLazy',
|
||||
enabled = not vim.tbl_contains(user_config.disable_builtin_plugins, 'cosmic-ui'),
|
||||
}
|
||||
|
|
|
@ -1,45 +1,52 @@
|
|||
local user_config = require('cosmic.core.user')
|
||||
local icons = require('cosmic.utils.icons')
|
||||
local g = vim.g
|
||||
|
||||
g.dashboard_custom_header = {
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
' ██████╗ ██████╗ ███████╗███╗ ███╗██╗ ██████╗███╗ ██╗██╗ ██╗██╗███╗ ███╗',
|
||||
'██╔════╝██╔═══██╗██╔════╝████╗ ████║██║██╔════╝████╗ ██║██║ ██║██║████╗ ████║',
|
||||
'██║ ██║ ██║███████╗██╔████╔██║██║██║ ██╔██╗ ██║██║ ██║██║██╔████╔██║',
|
||||
'██║ ██║ ██║╚════██║██║╚██╔╝██║██║██║ ██║╚██╗██║╚██╗ ██╔╝██║██║╚██╔╝██║',
|
||||
'╚██████╗╚██████╔╝███████║██║ ╚═╝ ██║██║╚██████╗██║ ╚████║ ╚████╔╝ ██║██║ ╚═╝ ██║',
|
||||
' ╚═════╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝╚═╝ ╚═════╝╚═╝ ╚═══╝ ╚═══╝ ╚═╝╚═╝ ╚═╝',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
return {
|
||||
'glepnir/dashboard-nvim',
|
||||
config = function()
|
||||
g.dashboard_custom_header = {
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
' ██████╗ ██████╗ ███████╗███╗ ███╗██╗ ██████╗███╗ ██╗██╗ ██╗██╗███╗ ███╗',
|
||||
'██╔════╝██╔═══██╗██╔════╝████╗ ████║██║██╔════╝████╗ ██║██║ ██║██║████╗ ████║',
|
||||
'██║ ██║ ██║███████╗██╔████╔██║██║██║ ██╔██╗ ██║██║ ██║██║██╔████╔██║',
|
||||
'██║ ██║ ██║╚════██║██║╚██╔╝██║██║██║ ██║╚██╗██║╚██╗ ██╔╝██║██║╚██╔╝██║',
|
||||
'╚██████╗╚██████╔╝███████║██║ ╚═╝ ██║██║╚██████╗██║ ╚████║ ╚████╔╝ ██║██║ ╚═╝ ██║',
|
||||
' ╚═════╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝╚═╝ ╚═════╝╚═╝ ╚═══╝ ╚═══╝ ╚═╝╚═╝ ╚═╝',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
}
|
||||
|
||||
g.dashboard_default_executive = 'telescope'
|
||||
|
||||
g.dashboard_session_directory = vim.fn.stdpath('data') .. '/sessions'
|
||||
|
||||
g.dashboard_custom_section = {
|
||||
find_file = {
|
||||
description = { icons.file1 .. ' Find File <leader>ff' },
|
||||
command = 'lua require("cosmic.plugins.telescope.mappings").project_files()',
|
||||
},
|
||||
file_explorer = {
|
||||
description = { icons.file2 .. ' File Manager <C-n> ' },
|
||||
command = 'NvimTreeToggle',
|
||||
},
|
||||
find_string = {
|
||||
description = { icons.word .. ' Grep String <leader>fs' },
|
||||
command = 'Telescope grep_string',
|
||||
},
|
||||
last_session = {
|
||||
description = { icons.clock .. ' Load Session <leader>sl' },
|
||||
command = 'lua vim.cmd(":silent RestoreSession")',
|
||||
},
|
||||
}
|
||||
|
||||
g.dashboard_custom_footer = { '💫 github.com/CosmicNvim/CosmicNvim' }
|
||||
end,
|
||||
enabled = not vim.tbl_contains(user_config.disable_builtin_plugins, 'dashboard'),
|
||||
}
|
||||
|
||||
g.dashboard_default_executive = 'telescope'
|
||||
|
||||
g.dashboard_session_directory = vim.fn.stdpath('data') .. '/sessions'
|
||||
|
||||
g.dashboard_custom_section = {
|
||||
find_file = {
|
||||
description = { icons.file1 .. ' Find File <leader>ff' },
|
||||
command = 'lua require("cosmic.plugins.telescope.mappings").project_files()',
|
||||
},
|
||||
file_explorer = {
|
||||
description = { icons.file2 .. ' File Manager <C-n> ' },
|
||||
command = 'NvimTreeToggle',
|
||||
},
|
||||
find_string = {
|
||||
description = { icons.word .. ' Grep String <leader>fs' },
|
||||
command = 'Telescope grep_string',
|
||||
},
|
||||
last_session = {
|
||||
description = { icons.clock .. ' Load Session <leader>sl' },
|
||||
command = 'lua vim.cmd(":silent RestoreSession")',
|
||||
},
|
||||
}
|
||||
|
||||
g.dashboard_custom_footer = { '💫 github.com/CosmicNvim/CosmicNvim' }
|
||||
|
|
7
lua/cosmic/plugins/fugitive/init.lua
Normal file
7
lua/cosmic/plugins/fugitive/init.lua
Normal file
|
@ -0,0 +1,7 @@
|
|||
local user_config = require('cosmic.core.user')
|
||||
return {
|
||||
'tpope/vim-fugitive',
|
||||
opt = true,
|
||||
cmd = 'Git',
|
||||
enabled = not vim.tbl_contains(user_config.disable_builtin_plugins, 'fugitive'),
|
||||
}
|
68
lua/cosmic/plugins/gitsigns/config.lua
Normal file
68
lua/cosmic/plugins/gitsigns/config.lua
Normal file
|
@ -0,0 +1,68 @@
|
|||
local user_config = require('cosmic.core.user')
|
||||
local u = require('cosmic.utils')
|
||||
|
||||
require('gitsigns').setup(u.merge({
|
||||
signs = {
|
||||
add = { hl = 'GitSignsAdd', text = '│', numhl = 'GitSignsAddNr', linehl = 'GitSignsAddLn' },
|
||||
change = { hl = 'GitSignsChange', text = '│', numhl = 'GitSignsChangeNr', linehl = 'GitSignsChangeLn' },
|
||||
delete = { hl = 'GitSignsDelete', text = '_', numhl = 'GitSignsDeleteNr', linehl = 'GitSignsDeleteLn' },
|
||||
topdelete = { hl = 'GitSignsDelete', text = '‾', numhl = 'GitSignsDeleteNr', linehl = 'GitSignsDeleteLn' },
|
||||
changedelete = { hl = 'GitSignsChange', text = '~', numhl = 'GitSignsChangeNr', linehl = 'GitSignsChangeLn' },
|
||||
},
|
||||
signcolumn = true, -- Toggle with `:Gitsigns toggle_signs`
|
||||
numhl = false, -- Toggle with `:Gitsigns toggle_numhl`
|
||||
linehl = false, -- Toggle with `:Gitsigns toggle_linehl`
|
||||
word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff`
|
||||
keymaps = {
|
||||
-- Default keymap options
|
||||
noremap = true,
|
||||
|
||||
['n ]c'] = { expr = true, "&diff ? ']c' : '<cmd>Gitsigns next_hunk<CR>'" },
|
||||
['n [c'] = { expr = true, "&diff ? '[c' : '<cmd>Gitsigns prev_hunk<CR>'" },
|
||||
|
||||
['n <leader>hs'] = '<cmd>Gitsigns stage_hunk<CR>',
|
||||
['v <leader>hs'] = ':Gitsigns stage_hunk<CR>',
|
||||
['n <leader>hu'] = '<cmd>Gitsigns undo_stage_hunk<CR>',
|
||||
['n <leader>hr'] = '<cmd>Gitsigns reset_hunk<CR>',
|
||||
['v <leader>hr'] = ':Gitsigns reset_hunk<CR>',
|
||||
['n <leader>hR'] = '<cmd>Gitsigns reset_buffer<CR>',
|
||||
['n <leader>hp'] = '<cmd>Gitsigns preview_hunk<CR>',
|
||||
['n <leader>hb'] = '<cmd>lua require"gitsigns".blame_line{full=true}<CR>',
|
||||
['n <leader>hS'] = '<cmd>Gitsigns stage_buffer<CR>',
|
||||
['n <leader>hU'] = '<cmd>Gitsigns reset_buffer_index<CR>',
|
||||
|
||||
-- Text objects
|
||||
['o ih'] = ':<C-U>Gitsigns select_hunk<CR>',
|
||||
['x ih'] = ':<C-U>Gitsigns select_hunk<CR>',
|
||||
},
|
||||
watch_gitdir = {
|
||||
interval = 1000,
|
||||
follow_files = true,
|
||||
},
|
||||
attach_to_untracked = true,
|
||||
current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame`
|
||||
current_line_blame_opts = {
|
||||
virt_text = true,
|
||||
virt_text_pos = 'eol', -- 'eol' | 'overlay' | 'right_align'
|
||||
delay = 1000,
|
||||
ignore_whitespace = false,
|
||||
},
|
||||
current_line_blame_formatter_opts = {
|
||||
relative_time = false,
|
||||
},
|
||||
sign_priority = 6,
|
||||
update_debounce = 100,
|
||||
status_formatter = nil, -- Use default
|
||||
max_file_length = 40000,
|
||||
preview_config = {
|
||||
-- Options passed to nvim_open_win
|
||||
border = user_config.border,
|
||||
style = 'minimal',
|
||||
relative = 'cursor',
|
||||
row = 0,
|
||||
col = 1,
|
||||
},
|
||||
yadm = {
|
||||
enable = false,
|
||||
},
|
||||
}, user_config.plugins.gitsigns or {}))
|
|
@ -1,68 +1,12 @@
|
|||
local config = require('cosmic.core.user')
|
||||
local u = require('cosmic.utils')
|
||||
local user_config = require('cosmic.core.user')
|
||||
|
||||
require('gitsigns').setup(u.merge({
|
||||
signs = {
|
||||
add = { hl = 'GitSignsAdd', text = '│', numhl = 'GitSignsAddNr', linehl = 'GitSignsAddLn' },
|
||||
change = { hl = 'GitSignsChange', text = '│', numhl = 'GitSignsChangeNr', linehl = 'GitSignsChangeLn' },
|
||||
delete = { hl = 'GitSignsDelete', text = '_', numhl = 'GitSignsDeleteNr', linehl = 'GitSignsDeleteLn' },
|
||||
topdelete = { hl = 'GitSignsDelete', text = '‾', numhl = 'GitSignsDeleteNr', linehl = 'GitSignsDeleteLn' },
|
||||
changedelete = { hl = 'GitSignsChange', text = '~', numhl = 'GitSignsChangeNr', linehl = 'GitSignsChangeLn' },
|
||||
},
|
||||
signcolumn = true, -- Toggle with `:Gitsigns toggle_signs`
|
||||
numhl = false, -- Toggle with `:Gitsigns toggle_numhl`
|
||||
linehl = false, -- Toggle with `:Gitsigns toggle_linehl`
|
||||
word_diff = false, -- Toggle with `:Gitsigns toggle_word_diff`
|
||||
keymaps = {
|
||||
-- Default keymap options
|
||||
noremap = true,
|
||||
|
||||
['n ]c'] = { expr = true, "&diff ? ']c' : '<cmd>Gitsigns next_hunk<CR>'" },
|
||||
['n [c'] = { expr = true, "&diff ? '[c' : '<cmd>Gitsigns prev_hunk<CR>'" },
|
||||
|
||||
['n <leader>hs'] = '<cmd>Gitsigns stage_hunk<CR>',
|
||||
['v <leader>hs'] = ':Gitsigns stage_hunk<CR>',
|
||||
['n <leader>hu'] = '<cmd>Gitsigns undo_stage_hunk<CR>',
|
||||
['n <leader>hr'] = '<cmd>Gitsigns reset_hunk<CR>',
|
||||
['v <leader>hr'] = ':Gitsigns reset_hunk<CR>',
|
||||
['n <leader>hR'] = '<cmd>Gitsigns reset_buffer<CR>',
|
||||
['n <leader>hp'] = '<cmd>Gitsigns preview_hunk<CR>',
|
||||
['n <leader>hb'] = '<cmd>lua require"gitsigns".blame_line{full=true}<CR>',
|
||||
['n <leader>hS'] = '<cmd>Gitsigns stage_buffer<CR>',
|
||||
['n <leader>hU'] = '<cmd>Gitsigns reset_buffer_index<CR>',
|
||||
|
||||
-- Text objects
|
||||
['o ih'] = ':<C-U>Gitsigns select_hunk<CR>',
|
||||
['x ih'] = ':<C-U>Gitsigns select_hunk<CR>',
|
||||
},
|
||||
watch_gitdir = {
|
||||
interval = 1000,
|
||||
follow_files = true,
|
||||
},
|
||||
attach_to_untracked = true,
|
||||
current_line_blame = false, -- Toggle with `:Gitsigns toggle_current_line_blame`
|
||||
current_line_blame_opts = {
|
||||
virt_text = true,
|
||||
virt_text_pos = 'eol', -- 'eol' | 'overlay' | 'right_align'
|
||||
delay = 1000,
|
||||
ignore_whitespace = false,
|
||||
},
|
||||
current_line_blame_formatter_opts = {
|
||||
relative_time = false,
|
||||
},
|
||||
sign_priority = 6,
|
||||
update_debounce = 100,
|
||||
status_formatter = nil, -- Use default
|
||||
max_file_length = 40000,
|
||||
preview_config = {
|
||||
-- Options passed to nvim_open_win
|
||||
border = config.border,
|
||||
style = 'minimal',
|
||||
relative = 'cursor',
|
||||
row = 0,
|
||||
col = 1,
|
||||
},
|
||||
yadm = {
|
||||
enable = false,
|
||||
},
|
||||
}, config.gitsigns or {}))
|
||||
return {
|
||||
'lewis6991/gitsigns.nvim',
|
||||
dependencies = { 'nvim-lua/plenary.nvim' },
|
||||
opt = true,
|
||||
event = 'VeryLazy',
|
||||
config = function()
|
||||
require('cosmic.plugins.gitsigns.config')
|
||||
end,
|
||||
enabled = not vim.tbl_contains(user_config.disable_builtin_plugins, 'gitsigns'),
|
||||
}
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
local config = require('cosmic.core.user')
|
||||
local u = require('cosmic.utils')
|
||||
|
||||
require('lsp_signature').setup(u.merge({
|
||||
bind = true, -- This is mandatory, otherwise border config won't get registered.
|
||||
handler_opts = {
|
||||
border = config.border,
|
||||
},
|
||||
}, config.lsp_signature or {}))
|
|
@ -1,4 +1,4 @@
|
|||
local config = require('cosmic.core.user')
|
||||
local user_config = require('cosmic.core.user')
|
||||
local utils = require('cosmic.utils')
|
||||
local lsp_utils = require('cosmic.utils.lsp')
|
||||
local icons = require('cosmic.utils.icons')
|
||||
|
@ -30,63 +30,71 @@ local custom_sections = {
|
|||
},
|
||||
}
|
||||
|
||||
require('lualine').setup(utils.merge({
|
||||
options = {
|
||||
theme = 'tokyonight',
|
||||
},
|
||||
sections = {
|
||||
lualine_a = { 'mode' },
|
||||
lualine_b = {
|
||||
{
|
||||
'filetype',
|
||||
icon_only = true,
|
||||
padding = {
|
||||
left = 1,
|
||||
right = 0,
|
||||
},
|
||||
separator = '',
|
||||
return {
|
||||
'nvim-lualine/lualine.nvim',
|
||||
lazy = false,
|
||||
config = function()
|
||||
require('lualine').setup(utils.merge({
|
||||
options = {
|
||||
theme = 'tokyonight',
|
||||
},
|
||||
custom_sections.shortenedFilePath,
|
||||
},
|
||||
lualine_c = { custom_sections.diff },
|
||||
lualine_x = { 'diagnostics' },
|
||||
lualine_y = { lsp_utils.get_lsp_status_str },
|
||||
lualine_z = { 'location', 'progress' },
|
||||
},
|
||||
inactive_sections = {
|
||||
lualine_a = {},
|
||||
lualine_b = {
|
||||
{
|
||||
'filetype',
|
||||
icon_only = true,
|
||||
padding = {
|
||||
left = 1,
|
||||
right = 0,
|
||||
sections = {
|
||||
lualine_a = { 'mode' },
|
||||
lualine_b = {
|
||||
{
|
||||
'filetype',
|
||||
icon_only = true,
|
||||
padding = {
|
||||
left = 1,
|
||||
right = 0,
|
||||
},
|
||||
separator = '',
|
||||
},
|
||||
custom_sections.shortenedFilePath,
|
||||
},
|
||||
separator = '',
|
||||
lualine_c = { custom_sections.diff },
|
||||
lualine_x = { 'diagnostics' },
|
||||
lualine_y = { lsp_utils.get_lsp_status_str },
|
||||
lualine_z = { 'location', 'progress' },
|
||||
},
|
||||
custom_sections.shortenedFilePath,
|
||||
},
|
||||
lualine_c = { custom_sections.diff },
|
||||
lualine_x = { 'diagnostics' },
|
||||
lualine_y = { 'location', 'progress' },
|
||||
lualine_z = {},
|
||||
},
|
||||
winbar = {
|
||||
lualine_a = { utils.get_short_cwd },
|
||||
lualine_b = { custom_sections.branch },
|
||||
lualine_c = { custom_sections.relativeFilePath },
|
||||
lualine_x = { 'filetype' },
|
||||
lualine_y = {},
|
||||
lualine_z = {},
|
||||
},
|
||||
inactive_winbar = {
|
||||
lualine_a = { utils.get_short_cwd },
|
||||
lualine_b = { custom_sections.branch },
|
||||
lualine_c = { custom_sections.relativeFilePath },
|
||||
lualine_x = { 'filetype' },
|
||||
lualine_y = {},
|
||||
lualine_z = {},
|
||||
},
|
||||
extensions = { 'quickfix', 'fugitive', 'nvim-tree' },
|
||||
}, config.lualine or {}))
|
||||
inactive_sections = {
|
||||
lualine_a = {},
|
||||
lualine_b = {
|
||||
{
|
||||
'filetype',
|
||||
icon_only = true,
|
||||
padding = {
|
||||
left = 1,
|
||||
right = 0,
|
||||
},
|
||||
separator = '',
|
||||
},
|
||||
custom_sections.shortenedFilePath,
|
||||
},
|
||||
lualine_c = { custom_sections.diff },
|
||||
lualine_x = { 'diagnostics' },
|
||||
lualine_y = { 'location', 'progress' },
|
||||
lualine_z = {},
|
||||
},
|
||||
winbar = {
|
||||
lualine_a = { utils.get_short_cwd },
|
||||
lualine_b = { custom_sections.branch },
|
||||
lualine_c = { custom_sections.relativeFilePath },
|
||||
lualine_x = { 'filetype' },
|
||||
lualine_y = {},
|
||||
lualine_z = {},
|
||||
},
|
||||
inactive_winbar = {
|
||||
lualine_a = { utils.get_short_cwd },
|
||||
lualine_b = { custom_sections.branch },
|
||||
lualine_c = { custom_sections.relativeFilePath },
|
||||
lualine_x = { 'filetype' },
|
||||
lualine_y = {},
|
||||
lualine_z = {},
|
||||
},
|
||||
extensions = { 'quickfix', 'fugitive', 'nvim-tree' },
|
||||
}, user_config.plugins.lualine or {}))
|
||||
end,
|
||||
dependencies = { 'nvim-tree/nvim-web-devicons' },
|
||||
enabled = not vim.tbl_contains(user_config.disable_builtin_plugins, 'lualine'),
|
||||
}
|
||||
|
|
|
@ -1,33 +1,27 @@
|
|||
local config = require('cosmic.core.user')
|
||||
local ls = require('luasnip')
|
||||
local user_config = require('cosmic.core.user')
|
||||
local u = require('cosmic.utils')
|
||||
|
||||
-- some shorthands...
|
||||
--[[ local s = ls.snippet
|
||||
local sn = ls.snippet_node
|
||||
local t = ls.text_node
|
||||
local i = ls.insert_node
|
||||
local f = ls.function_node
|
||||
local c = ls.choice_node
|
||||
local d = ls.dynamic_node ]]
|
||||
return {
|
||||
'L3MON4D3/LuaSnip',
|
||||
config = function()
|
||||
local ls = require('luasnip')
|
||||
-- Every unspecified option will be set to the default.
|
||||
ls.config.set_config(u.merge({
|
||||
history = true,
|
||||
-- Update more often, :h events for more info.
|
||||
updateevents = 'TextChanged,TextChangedI',
|
||||
enable_autosnippets = true,
|
||||
}, user_config.plugins.luasnip or {}))
|
||||
|
||||
-- Every unspecified option will be set to the default.
|
||||
ls.config.set_config(u.merge({
|
||||
history = true,
|
||||
-- Update more often, :h events for more info.
|
||||
updateevents = 'TextChanged,TextChangedI',
|
||||
enable_autosnippets = true,
|
||||
}, config.luasnip or {}))
|
||||
-- extend html snippets to react files
|
||||
require('luasnip').filetype_extend('javascriptreact', { 'html' })
|
||||
require('luasnip').filetype_extend('typescriptreact', { 'html' })
|
||||
|
||||
ls.snippets = {
|
||||
all = {},
|
||||
html = {},
|
||||
-- load snippets (friendly-snippets)
|
||||
require('luasnip.loaders.from_vscode').lazy_load()
|
||||
end,
|
||||
dependencies = {
|
||||
'rafamadriz/friendly-snippets',
|
||||
},
|
||||
enabled = not vim.tbl_contains(user_config.disable_builtin_plugins, 'luasnip'),
|
||||
}
|
||||
|
||||
-- enable html snippets in javascript/javascript(REACT)
|
||||
ls.snippets.javascript = ls.snippets.html
|
||||
ls.snippets.javascriptreact = ls.snippets.html
|
||||
ls.snippets.typescriptreact = ls.snippets.html
|
||||
|
||||
-- You can also use lazy loading so you only get in memory snippets of languages you use
|
||||
require('luasnip.loaders.from_vscode').lazy_load()
|
||||
|
|
|
@ -1,20 +1,41 @@
|
|||
require('noice').setup({
|
||||
views = {
|
||||
notify = {
|
||||
merge = true,
|
||||
},
|
||||
},
|
||||
lsp = {
|
||||
-- override markdown rendering so that **cmp** and other plugins use **Treesitter**
|
||||
hover = {
|
||||
enabled = false,
|
||||
},
|
||||
override = {
|
||||
['vim.lsp.util.convert_input_to_markdown_lines'] = true,
|
||||
['vim.lsp.util.stylize_markdown'] = true,
|
||||
['cmp.entry.get_documentation'] = true,
|
||||
},
|
||||
},
|
||||
})
|
||||
local user_config = require('cosmic.core.user')
|
||||
local u = require('cosmic.utils')
|
||||
|
||||
require('cosmic.plugins.noice.mappings')
|
||||
return {
|
||||
'folke/noice.nvim',
|
||||
config = function()
|
||||
local config = u.merge({
|
||||
presets = {
|
||||
lsp_doc_border = true,
|
||||
},
|
||||
views = {
|
||||
notify = {
|
||||
merge = true,
|
||||
},
|
||||
},
|
||||
lsp = {
|
||||
-- override markdown rendering so that **cmp** and other plugins use **Treesitter**
|
||||
hover = {
|
||||
enabled = true,
|
||||
},
|
||||
signature = {
|
||||
enabled = true,
|
||||
},
|
||||
override = {
|
||||
['vim.lsp.util.convert_input_to_markdown_lines'] = true,
|
||||
['vim.lsp.util.stylize_markdown'] = true,
|
||||
-- @TODO: why doesn't this work?
|
||||
['cmp.entry.get_documentation'] = false,
|
||||
},
|
||||
},
|
||||
}, user_config.plugins.noice or {})
|
||||
|
||||
require('noice').setup(config)
|
||||
require('cosmic.plugins.noice.mappings')
|
||||
end,
|
||||
event = 'VeryLazy',
|
||||
dependencies = {
|
||||
'MunifTanjim/nui.nvim',
|
||||
'rcarriga/nvim-notify',
|
||||
},
|
||||
}
|
||||
|
|
|
@ -1,17 +1,13 @@
|
|||
vim.keymap.set('n', '<c-f>', function()
|
||||
if not require('noice.lsp').scroll(4) then
|
||||
return '<c-f>'
|
||||
end
|
||||
end, {
|
||||
silent = true,
|
||||
expr = true,
|
||||
})
|
||||
local map = require('cosmic.utils').map
|
||||
|
||||
vim.keymap.set('n', '<c-b>', function()
|
||||
if not require('noice.lsp').scroll(-4) then
|
||||
return '<c-b>'
|
||||
map('n', '<c-k>', function()
|
||||
if not require('noice.lsp').scroll(4) then
|
||||
return '<c-k>'
|
||||
end
|
||||
end, {
|
||||
silent = true,
|
||||
expr = true,
|
||||
})
|
||||
end)
|
||||
|
||||
map('n', '<c-j>', function()
|
||||
if not require('noice.lsp').scroll(-4) then
|
||||
return '<c-j>'
|
||||
end
|
||||
end)
|
||||
|
|
|
@ -21,7 +21,7 @@ if config_opts.default_cosmic_sources then
|
|||
}),
|
||||
null_ls.builtins.formatting.stylua,
|
||||
null_ls.builtins.code_actions.gitsigns,
|
||||
}, config_opts.sources or {})
|
||||
}, config_opts.get_sources() or {})
|
||||
end
|
||||
|
||||
require('null-ls').setup(u.merge(defaults, config_opts))
|
||||
null_ls.setup(u.merge(defaults, config_opts))
|
10
lua/cosmic/plugins/null-ls/init.lua
Normal file
10
lua/cosmic/plugins/null-ls/init.lua
Normal file
|
@ -0,0 +1,10 @@
|
|||
local user_config = require('cosmic.core.user')
|
||||
|
||||
return {
|
||||
'jose-elias-alvarez/null-ls.nvim',
|
||||
config = function()
|
||||
require('cosmic.plugins.null-ls.config')
|
||||
end,
|
||||
event = 'BufEnter',
|
||||
enabled = not vim.tbl_contains(user_config.disable_builtin_plugins, 'null_ls'),
|
||||
}
|
141
lua/cosmic/plugins/nvim-cmp/config.lua
Normal file
141
lua/cosmic/plugins/nvim-cmp/config.lua
Normal file
|
@ -0,0 +1,141 @@
|
|||
local cmp = require('cmp')
|
||||
local u = require('cosmic.utils')
|
||||
local luasnip = require('luasnip')
|
||||
local user_config = require('cosmic.core.user')
|
||||
local icons = require('cosmic.utils.icons')
|
||||
local cmp_autopairs = require('nvim-autopairs.completion.cmp')
|
||||
|
||||
local has_words_before = function()
|
||||
unpack = unpack or table.unpack
|
||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match('%s') == nil
|
||||
end
|
||||
|
||||
local default_cmp_opts = {
|
||||
enabled = function()
|
||||
-- disable completion in comments
|
||||
local context = require('cmp.config.context')
|
||||
-- keep command mode completion enabled when cursor is in a comment
|
||||
if vim.api.nvim_get_mode().mode == 'c' then
|
||||
return true
|
||||
else
|
||||
return not context.in_treesitter_capture('comment') and not context.in_syntax_group('Comment')
|
||||
end
|
||||
end,
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
luasnip.lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
['<C-d>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }),
|
||||
['<C-u>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }),
|
||||
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
|
||||
['<C-e>'] = cmp.mapping({
|
||||
i = cmp.mapping.abort(),
|
||||
c = cmp.mapping.close(),
|
||||
}),
|
||||
-- disabled for autopairs mapping
|
||||
['<CR>'] = cmp.mapping.confirm({
|
||||
behavior = cmp.ConfirmBehavior.Insert,
|
||||
select = true,
|
||||
}),
|
||||
['<Tab>'] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif luasnip.expand_or_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
elseif has_words_before() then
|
||||
cmp.complete()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, {
|
||||
'i',
|
||||
's',
|
||||
}),
|
||||
['<S-Tab>'] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip.jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, {
|
||||
'i',
|
||||
's',
|
||||
}),
|
||||
}),
|
||||
window = {
|
||||
completion = {
|
||||
border = user_config.border,
|
||||
winhighlight = 'FloatBorder:FloatBorder,Normal:Normal',
|
||||
},
|
||||
documentation = {
|
||||
border = user_config.border,
|
||||
winhighlight = 'FloatBorder:FloatBorder,Normal:Normal',
|
||||
},
|
||||
},
|
||||
experimental = {
|
||||
ghost_text = true,
|
||||
},
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'luasnip' },
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'nvim_lua' },
|
||||
{ name = 'path' },
|
||||
}, {
|
||||
{ name = 'buffer' },
|
||||
}),
|
||||
formatting = {
|
||||
format = function(entry, vim_item)
|
||||
-- Kind icons
|
||||
vim_item.kind = string.format('%s %s', icons.kind_icons[vim_item.kind], vim_item.kind)
|
||||
vim_item.menu = ({
|
||||
nvim_lsp = '[lsp]',
|
||||
luasnip = '[snip]',
|
||||
buffer = '[buf]',
|
||||
path = '[path]',
|
||||
nvim_lua = '[nvim_api]',
|
||||
})[entry.source.name]
|
||||
return vim_item
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
||||
-- set up autopairs
|
||||
cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done())
|
||||
|
||||
cmp.setup(u.merge(default_cmp_opts, user_config.plugins.nvim_cmp or {}))
|
||||
|
||||
-- Set configuration for specific filetype.
|
||||
cmp.setup.filetype('gitcommit', {
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'cmp_git' }, -- You can specify the `cmp_git` source if you were installed it.
|
||||
}, {
|
||||
{ name = 'buffer' },
|
||||
}),
|
||||
})
|
||||
|
||||
cmp.setup.filetype('TelescopePrompt', {
|
||||
enabled = false,
|
||||
})
|
||||
|
||||
-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
|
||||
cmp.setup.cmdline({ '/', '?' }, {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = {
|
||||
{ name = 'buffer' },
|
||||
},
|
||||
})
|
||||
|
||||
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
|
||||
cmp.setup.cmdline(':', {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'path' },
|
||||
}, {
|
||||
{ name = 'cmdline' },
|
||||
}),
|
||||
})
|
|
@ -1,135 +1,20 @@
|
|||
local cmp = require('cmp')
|
||||
local u = require('cosmic.utils')
|
||||
local luasnip = require('luasnip')
|
||||
local user_config = require('cosmic.core.user')
|
||||
local icons = require('cosmic.utils.icons')
|
||||
|
||||
local has_words_before = function()
|
||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match('%s') == nil
|
||||
end
|
||||
|
||||
local default_cmp_opts = {
|
||||
enabled = function()
|
||||
-- disable completion in comments
|
||||
local context = require('cmp.config.context')
|
||||
-- keep command mode completion enabled when cursor is in a comment
|
||||
if vim.api.nvim_get_mode().mode == 'c' then
|
||||
return true
|
||||
else
|
||||
return not context.in_treesitter_capture('comment') and not context.in_syntax_group('Comment')
|
||||
end
|
||||
return {
|
||||
'hrsh7th/nvim-cmp',
|
||||
config = function()
|
||||
require('cosmic.plugins.nvim-cmp.config')
|
||||
end,
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
luasnip.lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert({
|
||||
['<C-d>'] = cmp.mapping(cmp.mapping.scroll_docs(-4), { 'i', 'c' }),
|
||||
['<C-u>'] = cmp.mapping(cmp.mapping.scroll_docs(4), { 'i', 'c' }),
|
||||
['<C-Space>'] = cmp.mapping(cmp.mapping.complete(), { 'i', 'c' }),
|
||||
['<C-e>'] = cmp.mapping({
|
||||
i = cmp.mapping.abort(),
|
||||
c = cmp.mapping.close(),
|
||||
}),
|
||||
-- disabled for autopairs mapping
|
||||
['<CR>'] = cmp.mapping.confirm({
|
||||
behavior = cmp.ConfirmBehavior.Insert,
|
||||
select = true,
|
||||
}),
|
||||
['<Tab>'] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif luasnip.expand_or_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
elseif has_words_before() then
|
||||
cmp.complete()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, {
|
||||
'i',
|
||||
's',
|
||||
}),
|
||||
['<S-Tab>'] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip.jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, {
|
||||
'i',
|
||||
's',
|
||||
}),
|
||||
}),
|
||||
window = {
|
||||
completion = {
|
||||
border = user_config.border,
|
||||
winhighlight = 'FloatBorder:FloatBorder,Normal:Normal',
|
||||
},
|
||||
documentation = {
|
||||
border = user_config.border,
|
||||
winhighlight = 'FloatBorder:FloatBorder,Normal:Normal',
|
||||
},
|
||||
},
|
||||
experimental = {
|
||||
ghost_text = true,
|
||||
},
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'nvim_lua' },
|
||||
{ name = 'luasnip' },
|
||||
{ name = 'buffer' },
|
||||
{ name = 'path' },
|
||||
}),
|
||||
formatting = {
|
||||
format = function(entry, vim_item)
|
||||
-- Kind icons
|
||||
vim_item.kind = string.format('%s %s', icons.kind_icons[vim_item.kind], vim_item.kind)
|
||||
vim_item.menu = ({
|
||||
nvim_lsp = '[lsp]',
|
||||
luasnip = '[snip]',
|
||||
buffer = '[buf]',
|
||||
path = '[path]',
|
||||
nvim_lua = '[nvim_api]',
|
||||
})[entry.source.name]
|
||||
return vim_item
|
||||
end,
|
||||
dependencies = {
|
||||
'hrsh7th/cmp-nvim-lsp',
|
||||
'saadparwaiz1/cmp_luasnip',
|
||||
'hrsh7th/cmp-buffer',
|
||||
'hrsh7th/cmp-nvim-lua',
|
||||
'hrsh7th/cmp-cmdline',
|
||||
'hrsh7th/cmp-path',
|
||||
-- has configs
|
||||
'L3MON4D3/LuaSnip',
|
||||
},
|
||||
event = 'InsertEnter',
|
||||
enabled = not vim.tbl_contains(user_config.disable_builtin_plugins, 'nvim-cmp'),
|
||||
}
|
||||
|
||||
cmp.setup(u.merge(default_cmp_opts, user_config.nvim_cmp or {}))
|
||||
|
||||
-- Set configuration for specific filetype.
|
||||
cmp.setup.filetype('gitcommit', {
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'cmp_git' }, -- You can specify the `cmp_git` source if you were installed it.
|
||||
}, {
|
||||
{ name = 'buffer' },
|
||||
}),
|
||||
})
|
||||
|
||||
cmp.setup.filetype('TelescopePrompt', {
|
||||
enabled = false,
|
||||
})
|
||||
|
||||
-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
|
||||
cmp.setup.cmdline({ '/', '?' }, {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = {
|
||||
{ name = 'buffer' },
|
||||
},
|
||||
})
|
||||
|
||||
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
|
||||
cmp.setup.cmdline(':', {
|
||||
mapping = cmp.mapping.preset.cmdline(),
|
||||
sources = cmp.config.sources({
|
||||
{ name = 'path' },
|
||||
}, {
|
||||
{ name = 'cmdline' },
|
||||
}),
|
||||
})
|
||||
|
|
9
lua/cosmic/plugins/nvim-lsp-installer/init.lua
Normal file
9
lua/cosmic/plugins/nvim-lsp-installer/init.lua
Normal file
|
@ -0,0 +1,9 @@
|
|||
local user_config = require('cosmic.core.user')
|
||||
return {
|
||||
'williamboman/nvim-lsp-installer',
|
||||
config = function()
|
||||
require('cosmic.plugins.nvim-lsp-installer.config')
|
||||
end,
|
||||
event = 'BufEnter',
|
||||
enabled = not vim.tbl_contains(user_config.disable_builtin_plugins, 'nvim-lsp-installer'),
|
||||
}
|
42
lua/cosmic/plugins/nvim-lsp-ts-utils/config.lua
Normal file
42
lua/cosmic/plugins/nvim-lsp-ts-utils/config.lua
Normal file
|
@ -0,0 +1,42 @@
|
|||
local u = require('cosmic.utils')
|
||||
local config = require('cosmic.core.user')
|
||||
local M = {}
|
||||
|
||||
M.setup = function(client)
|
||||
local ts_utils = require('nvim-lsp-ts-utils')
|
||||
|
||||
ts_utils.setup(u.merge({
|
||||
debug = false,
|
||||
disable_commands = false,
|
||||
enable_import_on_completion = true,
|
||||
|
||||
-- import all
|
||||
import_all_timeout = 5000, -- ms
|
||||
import_all_priorities = {
|
||||
buffers = 4, -- loaded buffer names
|
||||
buffer_content = 3, -- loaded buffer content
|
||||
local_files = 2, -- git files or files with relative path markers
|
||||
same_file = 1, -- add to existing import statement
|
||||
},
|
||||
import_all_scan_buffers = 100,
|
||||
import_all_select_source = false,
|
||||
|
||||
-- inlay hints
|
||||
auto_inlay_hints = true,
|
||||
inlay_hints_highlight = 'Comment',
|
||||
|
||||
-- update imports on file move
|
||||
update_imports_on_move = true,
|
||||
require_confirmation_on_move = false,
|
||||
watch_dir = nil,
|
||||
|
||||
-- filter diagnostics
|
||||
filter_out_diagnostics_by_severity = {},
|
||||
filter_out_diagnostics_by_code = {},
|
||||
}, config.lsp.ts_utils or {}))
|
||||
|
||||
-- required to fix code action ranges and filter diagnostics
|
||||
ts_utils.setup_client(client)
|
||||
end
|
||||
|
||||
return M
|
6
lua/cosmic/plugins/nvim-lsp-ts-utils/init.lua
Normal file
6
lua/cosmic/plugins/nvim-lsp-ts-utils/init.lua
Normal file
|
@ -0,0 +1,6 @@
|
|||
local user_config = require('cosmic.core.user')
|
||||
|
||||
return {
|
||||
'jose-elias-alvarez/nvim-lsp-ts-utils',
|
||||
enabled = not vim.tbl_contains(user_config.disable_builtin_plugins, 'nvim-lsp-ts-utils'),
|
||||
}
|
6
lua/cosmic/plugins/nvim-lspconfig/init.lua
Normal file
6
lua/cosmic/plugins/nvim-lspconfig/init.lua
Normal file
|
@ -0,0 +1,6 @@
|
|||
local user_config = require('cosmic.core.user')
|
||||
|
||||
return {
|
||||
'neovim/nvim-lspconfig',
|
||||
enabled = not vim.tbl_contains(user_config.disable_builtin_plugins, 'nvim-lspconfig'),
|
||||
}
|
|
@ -1,8 +1,6 @@
|
|||
local config = require('cosmic.core.user')
|
||||
local user_config = require('cosmic.core.user')
|
||||
local icons = require('cosmic.utils.icons')
|
||||
local u = require('cosmic.utils')
|
||||
local augroup_name = 'CosmicNvimNvimTree'
|
||||
local group = vim.api.nvim_create_augroup(augroup_name, { clear = true })
|
||||
|
||||
-- set up args
|
||||
local args = {
|
||||
|
@ -46,11 +44,17 @@ local args = {
|
|||
},
|
||||
}
|
||||
|
||||
-- Autoclose nvim is nvim-tree is only buffer open
|
||||
vim.api.nvim_create_autocmd('BufEnter', {
|
||||
command = [[if winnr('$') == 1 && bufname() == 'NvimTree_' . tabpagenr() | quit | endif]],
|
||||
group = group,
|
||||
nested = true,
|
||||
})
|
||||
|
||||
require('nvim-tree').setup(u.merge(args, config.nvim_tree or {}))
|
||||
return {
|
||||
'kyazdani42/nvim-tree.lua',
|
||||
config = function()
|
||||
require('nvim-tree').setup(u.merge(args, user_config.plugins.nvim_tree or {}))
|
||||
end,
|
||||
cmd = {
|
||||
'NvimTreeClipboard',
|
||||
'NvimTreeFindFile',
|
||||
'NvimTreeOpen',
|
||||
'NvimTreeRefresh',
|
||||
'NvimTreeToggle',
|
||||
},
|
||||
enabled = not vim.tbl_contains(user_config.disable_builtin_plugins, 'nvim-tree'),
|
||||
}
|
||||
|
|
1
lua/cosmic/plugins/schemastore/init.lua
Normal file
1
lua/cosmic/plugins/schemastore/init.lua
Normal file
|
@ -0,0 +1 @@
|
|||
return { 'b0o/SchemaStore.nvim' }
|
137
lua/cosmic/plugins/telescope/config.lua
Normal file
137
lua/cosmic/plugins/telescope/config.lua
Normal file
|
@ -0,0 +1,137 @@
|
|||
local actions = require('telescope.actions')
|
||||
local user_config = require('cosmic.core.user')
|
||||
local icons = require('cosmic.utils.icons')
|
||||
local u = require('cosmic.utils')
|
||||
|
||||
local default_mappings = {
|
||||
n = {
|
||||
['Q'] = actions.smart_add_to_qflist + actions.open_qflist,
|
||||
['q'] = actions.smart_send_to_qflist + actions.open_qflist,
|
||||
['<tab>'] = actions.toggle_selection + actions.move_selection_next,
|
||||
['<s-tab>'] = actions.toggle_selection + actions.move_selection_previous,
|
||||
['v'] = actions.file_vsplit,
|
||||
['s'] = actions.file_split,
|
||||
['<cr>'] = actions.file_edit,
|
||||
},
|
||||
}
|
||||
|
||||
local opts_cursor = {
|
||||
initial_mode = 'normal',
|
||||
sorting_strategy = 'ascending',
|
||||
layout_strategy = 'cursor',
|
||||
results_title = false,
|
||||
layout_config = {
|
||||
width = 0.5,
|
||||
height = 0.4,
|
||||
},
|
||||
}
|
||||
|
||||
local opts_vertical = {
|
||||
initial_mode = 'normal',
|
||||
sorting_strategy = 'ascending',
|
||||
layout_strategy = 'vertical',
|
||||
results_title = false,
|
||||
layout_config = {
|
||||
width = 0.3,
|
||||
height = 0.5,
|
||||
prompt_position = 'top',
|
||||
mirror = true,
|
||||
},
|
||||
}
|
||||
|
||||
local opts_flex = {
|
||||
layout_strategy = 'flex',
|
||||
layout_config = {
|
||||
width = 0.7,
|
||||
height = 0.7,
|
||||
},
|
||||
}
|
||||
|
||||
require('telescope').setup(u.merge({
|
||||
defaults = {
|
||||
prompt_prefix = '🔍 ',
|
||||
selection_caret = icons.folder.arrow_closed,
|
||||
file_ignore_patterns = {
|
||||
'.git/',
|
||||
},
|
||||
dynamic_preview_title = true,
|
||||
vimgrep_arguments = {
|
||||
'rg',
|
||||
'--ignore',
|
||||
'--hidden',
|
||||
'--color=never',
|
||||
'--no-heading',
|
||||
'--with-filename',
|
||||
'--line-number',
|
||||
'--column',
|
||||
'--smart-case',
|
||||
'--trim',
|
||||
},
|
||||
},
|
||||
extensions = {
|
||||
fzf = {
|
||||
fuzzy = true, -- false will only do exact matching
|
||||
override_generic_sorter = true, -- override the generic sorter
|
||||
override_file_sorter = true, -- override the file sorter
|
||||
case_mode = 'smart_case', -- or "ignore_case" or "respect_case"
|
||||
-- the default case_mode is "smart_case"
|
||||
},
|
||||
},
|
||||
pickers = {
|
||||
buffers = u.merge(opts_flex, {
|
||||
prompt_title = '✨ Search Buffers ✨',
|
||||
mappings = u.merge({
|
||||
n = {
|
||||
['d'] = actions.delete_buffer,
|
||||
},
|
||||
}, default_mappings),
|
||||
sort_mru = true,
|
||||
preview_title = false,
|
||||
}),
|
||||
lsp_code_actions = u.merge(opts_cursor, {
|
||||
prompt_title = 'Code Actions',
|
||||
}),
|
||||
lsp_range_code_actions = u.merge(opts_vertical, {
|
||||
prompt_title = 'Code Actions',
|
||||
}),
|
||||
lsp_document_diagnostics = u.merge(opts_vertical, {
|
||||
prompt_title = 'Document Diagnostics',
|
||||
mappings = default_mappings,
|
||||
}),
|
||||
lsp_implementations = u.merge(opts_cursor, {
|
||||
prompt_title = 'Implementations',
|
||||
mappings = default_mappings,
|
||||
}),
|
||||
lsp_definitions = u.merge(opts_cursor, {
|
||||
prompt_title = 'Definitions',
|
||||
mappings = default_mappings,
|
||||
}),
|
||||
lsp_references = u.merge(opts_vertical, {
|
||||
prompt_title = 'References',
|
||||
mappings = default_mappings,
|
||||
}),
|
||||
find_files = u.merge(opts_flex, {
|
||||
prompt_title = '✨ Search Project ✨',
|
||||
mappings = default_mappings,
|
||||
hidden = true,
|
||||
}),
|
||||
diagnostics = u.merge(opts_vertical, {
|
||||
mappings = default_mappings,
|
||||
}),
|
||||
git_files = u.merge(opts_flex, {
|
||||
prompt_title = '✨ Search Git Project ✨',
|
||||
mappings = default_mappings,
|
||||
hidden = true,
|
||||
}),
|
||||
live_grep = u.merge(opts_flex, {
|
||||
prompt_title = '✨ Live Grep ✨',
|
||||
mappings = default_mappings,
|
||||
}),
|
||||
grep_string = u.merge(opts_vertical, {
|
||||
prompt_title = '✨ Grep String ✨',
|
||||
mappings = default_mappings,
|
||||
}),
|
||||
},
|
||||
}, user_config.plugins.telescope or {}))
|
||||
|
||||
require('telescope').load_extension('fzf')
|
|
@ -1,137 +1,18 @@
|
|||
local actions = require('telescope.actions')
|
||||
local config = require('cosmic.core.user')
|
||||
local icons = require('cosmic.utils.icons')
|
||||
local u = require('cosmic.utils')
|
||||
|
||||
local default_mappings = {
|
||||
n = {
|
||||
['Q'] = actions.smart_add_to_qflist + actions.open_qflist,
|
||||
['q'] = actions.smart_send_to_qflist + actions.open_qflist,
|
||||
['<tab>'] = actions.toggle_selection + actions.move_selection_next,
|
||||
['<s-tab>'] = actions.toggle_selection + actions.move_selection_previous,
|
||||
['v'] = actions.file_vsplit,
|
||||
['s'] = actions.file_split,
|
||||
['<cr>'] = actions.file_edit,
|
||||
},
|
||||
}
|
||||
|
||||
local opts_cursor = {
|
||||
initial_mode = 'normal',
|
||||
sorting_strategy = 'ascending',
|
||||
layout_strategy = 'cursor',
|
||||
results_title = false,
|
||||
layout_config = {
|
||||
width = 0.5,
|
||||
height = 0.4,
|
||||
},
|
||||
}
|
||||
|
||||
local opts_vertical = {
|
||||
initial_mode = 'normal',
|
||||
sorting_strategy = 'ascending',
|
||||
layout_strategy = 'vertical',
|
||||
results_title = false,
|
||||
layout_config = {
|
||||
width = 0.3,
|
||||
height = 0.5,
|
||||
prompt_position = 'top',
|
||||
mirror = true,
|
||||
},
|
||||
}
|
||||
|
||||
local opts_flex = {
|
||||
layout_strategy = 'flex',
|
||||
layout_config = {
|
||||
width = 0.7,
|
||||
height = 0.7,
|
||||
},
|
||||
}
|
||||
|
||||
require('telescope').setup(u.merge({
|
||||
defaults = {
|
||||
prompt_prefix = '🔍 ',
|
||||
selection_caret = icons.folder.arrow_closed,
|
||||
file_ignore_patterns = {
|
||||
'.git/',
|
||||
},
|
||||
dynamic_preview_title = true,
|
||||
vimgrep_arguments = {
|
||||
'rg',
|
||||
'--ignore',
|
||||
'--hidden',
|
||||
'--color=never',
|
||||
'--no-heading',
|
||||
'--with-filename',
|
||||
'--line-number',
|
||||
'--column',
|
||||
'--smart-case',
|
||||
'--trim',
|
||||
local user_config = require('cosmic.core.user')
|
||||
return {
|
||||
'nvim-telescope/telescope.nvim',
|
||||
dependencies = {
|
||||
'nvim-lua/popup.nvim',
|
||||
'nvim-lua/plenary.nvim',
|
||||
{
|
||||
'nvim-telescope/telescope-fzf-native.nvim',
|
||||
build = 'make',
|
||||
},
|
||||
},
|
||||
extensions = {
|
||||
fzf = {
|
||||
fuzzy = true, -- false will only do exact matching
|
||||
override_generic_sorter = true, -- override the generic sorter
|
||||
override_file_sorter = true, -- override the file sorter
|
||||
case_mode = 'smart_case', -- or "ignore_case" or "respect_case"
|
||||
-- the default case_mode is "smart_case"
|
||||
},
|
||||
},
|
||||
pickers = {
|
||||
buffers = u.merge(opts_flex, {
|
||||
prompt_title = '✨ Search Buffers ✨',
|
||||
mappings = u.merge({
|
||||
n = {
|
||||
['d'] = actions.delete_buffer,
|
||||
},
|
||||
}, default_mappings),
|
||||
sort_mru = true,
|
||||
preview_title = false,
|
||||
}),
|
||||
lsp_code_actions = u.merge(opts_cursor, {
|
||||
prompt_title = 'Code Actions',
|
||||
}),
|
||||
lsp_range_code_actions = u.merge(opts_vertical, {
|
||||
prompt_title = 'Code Actions',
|
||||
}),
|
||||
lsp_document_diagnostics = u.merge(opts_vertical, {
|
||||
prompt_title = 'Document Diagnostics',
|
||||
mappings = default_mappings,
|
||||
}),
|
||||
lsp_implementations = u.merge(opts_cursor, {
|
||||
prompt_title = 'Implementations',
|
||||
mappings = default_mappings,
|
||||
}),
|
||||
lsp_definitions = u.merge(opts_cursor, {
|
||||
prompt_title = 'Definitions',
|
||||
mappings = default_mappings,
|
||||
}),
|
||||
lsp_references = u.merge(opts_vertical, {
|
||||
prompt_title = 'References',
|
||||
mappings = default_mappings,
|
||||
}),
|
||||
find_files = u.merge(opts_flex, {
|
||||
prompt_title = '✨ Search Project ✨',
|
||||
mappings = default_mappings,
|
||||
hidden = true,
|
||||
}),
|
||||
diagnostics = u.merge(opts_vertical, {
|
||||
mappings = default_mappings,
|
||||
}),
|
||||
git_files = u.merge(opts_flex, {
|
||||
prompt_title = '✨ Search Git Project ✨',
|
||||
mappings = default_mappings,
|
||||
hidden = true,
|
||||
}),
|
||||
live_grep = u.merge(opts_flex, {
|
||||
prompt_title = '✨ Live Grep ✨',
|
||||
mappings = default_mappings,
|
||||
}),
|
||||
grep_string = u.merge(opts_vertical, {
|
||||
prompt_title = '✨ Grep String ✨',
|
||||
mappings = default_mappings,
|
||||
}),
|
||||
},
|
||||
}, config.telescope or {}))
|
||||
|
||||
require('telescope').load_extension('fzf')
|
||||
config = function()
|
||||
require('cosmic.plugins.telescope.mappings').init()
|
||||
require('cosmic.plugins.telescope.config')
|
||||
end,
|
||||
event = 'VeryLazy',
|
||||
enabled = not vim.tbl_contains(user_config.disable_builtin_plugins, 'telescope'),
|
||||
}
|
||||
|
|
|
@ -1,11 +1,21 @@
|
|||
local user_config = require('cosmic.core.user')
|
||||
local g = vim.g
|
||||
local title = vim.env.SHELL
|
||||
|
||||
g.floaterm_width = 0.7
|
||||
g.floaterm_height = 0.8
|
||||
g.floaterm_title = '[' .. title .. ']:($1/$2)'
|
||||
g.floaterm_borderchars = '─│─│╭╮╯╰'
|
||||
g.floaterm_opener = 'vsplit'
|
||||
return {
|
||||
'voldikss/vim-floaterm',
|
||||
keys = {
|
||||
{ '<C-l>', '<cmd>FloatermToggle<cr>', desc = 'Floating Terminal' },
|
||||
},
|
||||
config = function()
|
||||
g.floaterm_width = 0.7
|
||||
g.floaterm_height = 0.8
|
||||
g.floaterm_title = '[' .. title .. ']:($1/$2)'
|
||||
g.floaterm_borderchars = '─│─│╭╮╯╰'
|
||||
g.floaterm_opener = 'vsplit'
|
||||
|
||||
require('cosmic.plugins.terminal.mappings')
|
||||
require('cosmic.plugins.terminal.highlights')
|
||||
require('cosmic.plugins.terminal.mappings')
|
||||
require('cosmic.plugins.terminal.highlights')
|
||||
end,
|
||||
enabled = not vim.tbl_contains(user_config.disable_builtin_plugins, 'terminal'),
|
||||
}
|
||||
|
|
|
@ -1,26 +1,34 @@
|
|||
local config = require('cosmic.core.user')
|
||||
local user_config = require('cosmic.core.user')
|
||||
local icons = require('cosmic.utils.icons')
|
||||
local u = require('cosmic.utils')
|
||||
|
||||
require('todo-comments').setup(u.merge({
|
||||
keywords = {
|
||||
FIX = {
|
||||
icon = icons.debug, -- icon used for the sign, and in search results
|
||||
color = 'error', -- can be a hex color, or a named color (see below)
|
||||
alt = { 'FIXME', 'BUG', 'FIXIT', 'ISSUE', 'fix', 'fixme', 'bug' }, -- a set of other keywords that all map to this FIX keywords
|
||||
-- signs = false, -- configure signs for some keywords individually
|
||||
},
|
||||
TODO = { icon = icons.check, color = 'info' },
|
||||
HACK = { icon = icons.flame, color = 'warning' },
|
||||
WARN = { icon = icons.warn, color = 'warning', alt = { 'WARNING', 'XXX' } },
|
||||
PERF = { icon = icons.perf, alt = { 'OPTIM', 'PERFORMANCE', 'OPTIMIZE' } },
|
||||
NOTE = { icon = icons.note, color = 'hint', alt = { 'INFO' } },
|
||||
},
|
||||
colors = {
|
||||
error = { 'DiagnosticError', 'ErrorMsg', '#DC2626' },
|
||||
warning = { 'DiagnosticWarn', 'WarningMsg', '#FBBF24' },
|
||||
info = { 'DiagnosticInfo', '#2563EB' },
|
||||
hint = { 'DiagnosticHint', '#10B981' },
|
||||
default = { 'Identifier', '#7C3AED' },
|
||||
},
|
||||
}, config.todo_comments or {}))
|
||||
return {
|
||||
'folke/todo-comments.nvim',
|
||||
dependencies = 'nvim-lua/plenary.nvim',
|
||||
config = function()
|
||||
require('todo-comments').setup(u.merge({
|
||||
keywords = {
|
||||
FIX = {
|
||||
icon = icons.debug, -- icon used for the sign, and in search results
|
||||
color = 'error', -- can be a hex color, or a named color (see below)
|
||||
alt = { 'FIXME', 'BUG', 'FIXIT', 'ISSUE', 'fix', 'fixme', 'bug' }, -- a set of other keywords that all map to this FIX keywords
|
||||
-- signs = false, -- configure signs for some keywords individually
|
||||
},
|
||||
TODO = { icon = icons.check, color = 'info' },
|
||||
HACK = { icon = icons.flame, color = 'warning' },
|
||||
WARN = { icon = icons.warn, color = 'warning', alt = { 'WARNING', 'XXX' } },
|
||||
PERF = { icon = icons.perf, alt = { 'OPTIM', 'PERFORMANCE', 'OPTIMIZE' } },
|
||||
NOTE = { icon = icons.note, color = 'hint', alt = { 'INFO' } },
|
||||
},
|
||||
colors = {
|
||||
error = { 'DiagnosticError', 'ErrorMsg', '#DC2626' },
|
||||
warning = { 'DiagnosticWarn', 'WarningMsg', '#FBBF24' },
|
||||
info = { 'DiagnosticInfo', '#2563EB' },
|
||||
hint = { 'DiagnosticHint', '#10B981' },
|
||||
default = { 'Identifier', '#7C3AED' },
|
||||
},
|
||||
}, user_config.plugins.todo_comments or {}))
|
||||
end,
|
||||
event = 'BufEnter',
|
||||
enabled = not vim.tbl_contains(user_config.disable_builtin_plugins, 'todo-comments'),
|
||||
}
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
local config = {
|
||||
local user_config = require('cosmic.core.user')
|
||||
local u = require('cosmic.utils')
|
||||
|
||||
local config = u.merge({
|
||||
|
||||
-- use the night style
|
||||
style = 'night',
|
||||
light_style = 'moon',
|
||||
sidebars = { 'qf', 'packer', 'help' },
|
||||
}
|
||||
}, user_config.plugins.tokyonight or {})
|
||||
|
||||
return config
|
||||
|
|
|
@ -1,5 +1,13 @@
|
|||
local config = require('cosmic.plugins.tokyonight.config')
|
||||
|
||||
require('tokyonight').setup(config)
|
||||
|
||||
vim.cmd('color tokyonight')
|
||||
local user_config = require('cosmic.core.user')
|
||||
return {
|
||||
{ -- color scheme
|
||||
'folke/tokyonight.nvim',
|
||||
lazy = false,
|
||||
config = function()
|
||||
local config = require('cosmic.plugins.tokyonight.config')
|
||||
require('tokyonight').setup(config)
|
||||
vim.cmd('color tokyonight')
|
||||
end,
|
||||
enabled = not vim.tbl_contains(user_config.disable_builtin_plugins, 'tokyonight'),
|
||||
},
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
local config = require('cosmic.core.user')
|
||||
local user_config = require('cosmic.core.user')
|
||||
local u = require('cosmic.utils')
|
||||
|
||||
local defaults = {
|
||||
|
@ -11,6 +11,7 @@ local defaults = {
|
|||
'json',
|
||||
'lua',
|
||||
'markdown',
|
||||
'markdown_inline',
|
||||
'php',
|
||||
'python',
|
||||
'regex',
|
||||
|
@ -38,4 +39,17 @@ local defaults = {
|
|||
},
|
||||
}
|
||||
|
||||
require('nvim-treesitter.configs').setup(u.merge(defaults, config.treesitter or {}))
|
||||
return {
|
||||
'nvim-treesitter/nvim-treesitter',
|
||||
dependencies = {
|
||||
'windwp/nvim-ts-autotag',
|
||||
'JoosepAlviste/nvim-ts-context-commentstring',
|
||||
'nvim-treesitter/nvim-treesitter-refactor',
|
||||
},
|
||||
event = 'BufEnter',
|
||||
build = ':TSUpdate',
|
||||
config = function()
|
||||
require('nvim-treesitter.configs').setup(u.merge(defaults, user_config.plugins.treesitter or {}))
|
||||
end,
|
||||
enabled = not vim.tbl_contains(user_config.disable_builtin_plugins, 'treesitter'),
|
||||
}
|
||||
|
|
2
lua/cosmic/plugins/user/init.lua
Normal file
2
lua/cosmic/plugins/user/init.lua
Normal file
|
@ -0,0 +1,2 @@
|
|||
local user_config = require('cosmic.core.user')
|
||||
return user_config.add_plugins
|
|
@ -1,9 +1,4 @@
|
|||
local M = {}
|
||||
local augroup_name = 'CosmicNvimUtils'
|
||||
local group = vim.api.nvim_create_augroup(augroup_name, { clear = true })
|
||||
local function clear_cache()
|
||||
vim.cmd(':LuaCacheClear')
|
||||
end
|
||||
|
||||
local function get_install_dir()
|
||||
local config_dir = os.getenv('COSMICNVIM_INSTALL_DIR')
|
||||
|
@ -13,54 +8,8 @@ local function get_install_dir()
|
|||
return config_dir
|
||||
end
|
||||
|
||||
local function unload(module_pattern, reload)
|
||||
reload = reload or false
|
||||
for module, _ in pairs(package.loaded) do
|
||||
if module:match(module_pattern) then
|
||||
package.loaded[module] = nil
|
||||
if reload then
|
||||
require(module)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function post_reload(msg)
|
||||
local Logger = require('cosmic.utils.logger')
|
||||
unload('cosmic.utils', true)
|
||||
unload('cosmic.theme', true)
|
||||
unload('cosmic.plugins.statusline', true)
|
||||
msg = msg or 'User config reloaded!'
|
||||
Logger:log(msg)
|
||||
end
|
||||
|
||||
function M.reload_user_config_sync()
|
||||
clear_cache()
|
||||
unload('cosmic.core.user', true)
|
||||
unload('cosmic.core.pluginsInit', true)
|
||||
vim.api.nvim_create_autocmd('User PackerComplete', {
|
||||
callback = function()
|
||||
post_reload()
|
||||
end,
|
||||
group = group,
|
||||
once = true,
|
||||
})
|
||||
vim.cmd(':PackerSync')
|
||||
end
|
||||
|
||||
function M.reload_user_config(compile)
|
||||
compile = compile or false
|
||||
unload('cosmic.core.user', true)
|
||||
if compile then
|
||||
vim.api.nvim_create_autocmd('User PackerCompileDone', {
|
||||
callback = function()
|
||||
post_reload()
|
||||
end,
|
||||
group = group,
|
||||
once = true,
|
||||
})
|
||||
vim.cmd(':PackerCompile')
|
||||
end
|
||||
function M.sync_plugins()
|
||||
vim.cmd(':Lazy sync')
|
||||
end
|
||||
|
||||
-- update instance of CosmicNvim
|
||||
|
|
Loading…
Add table
Reference in a new issue