Compare commits

...

10 commits

Author SHA1 Message Date
9fc3847a6e
tinker with cosmic-ui 2025-03-05 09:44:00 -05:00
64530b3b86
more reorganizing 2025-03-05 09:36:07 -05:00
3e4b37345d
basic surgery 2025-03-05 09:03:20 -05:00
Matthew Leong
e3ad1d08f6 feat: fix keymap descs 2024-10-22 10:41:52 -07:00
Matthew Leong
1f9910235e feat: v0.7 2024-10-22 09:11:00 -07:00
Matthew Leong
cc95c5013f fix: whichkey 2024-10-22 09:07:23 -07:00
Matthew Leong
cb845d1d66 feat: update to ts_ls 2024-10-22 08:32:48 -07:00
Matthew Leong
383f1249c3 feat: update hotkeys 2024-08-28 11:56:32 -07:00
Matthew Leong
3e568e50f0 feat: update which-key 2024-07-16 11:19:35 -07:00
Matthew Leong
5d19ac0e71 feat: update terminal key maps 2024-07-03 10:56:28 -07:00
70 changed files with 540 additions and 1081 deletions

View file

@ -1,9 +1,31 @@
if vim.fn.has('nvim-0.11') == 0 then
error('Need Neovim v0.11+ (Nightly) in order to run Cosmic!')
end
local modules = {
'editor',
'plugins_init',
'commands',
'lsp',
-- load mappings only after editor configs are loaded
'mappings',
}
local ok, err = pcall(require, 'cosmic')
if not ok then
error(('Error loading core...\n\n%s'):format(err))
-- set up lazy.nvim to install plugins
local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim'
if not vim.uv.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)
-- set up cosmicnvim
for _, mod in ipairs(modules) do
local ok, err = pcall(require, mod)
-- config files may or may not be present
if not ok then
error(('Error loading %s...\n\n%s'):format(mod, err))
end
end

View file

@ -1,46 +1,87 @@
{
"Comment.nvim": { "branch": "master", "commit": "e30b7f2008e52442154b66f7c519bfd2f1e32acb" },
"LuaSnip": { "branch": "master", "commit": "50fcf17db7c75af80e6b6109acfbfb4504768780" },
"SchemaStore.nvim": { "branch": "main", "commit": "93ccaf12b9fb6df87d13da2782d83b34a3cbb893" },
"auto-session": { "branch": "main", "commit": "e5ffe230235c7d35c2f33078b7cd927a4fb579c4" },
<<<<<<< HEAD
"LuaSnip": { "branch": "master", "commit": "ac7cbc0e85710db7cba6510b1d8e6a1a551444f7" },
"SchemaStore.nvim": { "branch": "main", "commit": "3e54f4bbebea598646b141aa8aeca8a01b6ba601" },
"auto-session": { "branch": "main", "commit": "3cd531ce4d46fb156268ddedf5f3e6822ef26af7" },
=======
"LuaSnip": { "branch": "master", "commit": "45db5addf8d0a201e1cf247cae4cdce605ad3768" },
"SchemaStore.nvim": { "branch": "main", "commit": "ae75241aed204d829fe15595bbf05e6fbf3d49dd" },
"auto-session": { "branch": "main", "commit": "0e9aa77525b5217e8eacb36007edd3d02bb2a91a" },
>>>>>>> v0.7
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
"cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" },
"cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" },
"cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" },
"cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" },
"cosmic-ui": { "branch": "main", "commit": "c0b14531999f2bfef3d927c4dcd57a1a8fed5ee9" },
"friendly-snippets": { "branch": "main", "commit": "682157939e57bd6a2c86277dfd4d6fbfce63dbac" },
"gitsigns.nvim": { "branch": "main", "commit": "fa42613096ebfa5fee1ea87d70f8625ab9685d01" },
"lazy.nvim": { "branch": "main", "commit": "33be7ac3173c7c20b94ce7e1b9734c1a1e85f292" },
"lazydev.nvim": { "branch": "main", "commit": "6184ebbbc8045d70077659b7d30c705a588dc62f" },
"lualine.nvim": { "branch": "master", "commit": "0a5a66803c7407767b799067986b4dc3036e1983" },
"luvit-meta": { "branch": "main", "commit": "ce76f6f6cdc9201523a5875a4471dcfe0186eb60" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "37a336b653f8594df75c827ed589f1c91d91ff6c" },
"mason.nvim": { "branch": "main", "commit": "0950b15060067f752fde13a779a994f59516ce3d" },
"noice.nvim": { "branch": "main", "commit": "cade1f972ba226e7753a7a113f3f1a942908e73c" },
"none-ls-extras.nvim": { "branch": "main", "commit": "336e84b9e43c0effb735b08798ffac382920053b" },
<<<<<<< HEAD
"friendly-snippets": { "branch": "main", "commit": "de8fce94985873666bd9712ea3e49ee17aadb1ed" },
"gitsigns.nvim": { "branch": "main", "commit": "ee7634ab4f0a6606438fe13e16cbf2065589a5ed" },
"lazy.nvim": { "branch": "main", "commit": "cf8ecc2c5e4332760431a33534240b0cbc6680ab" },
"lualine.nvim": { "branch": "master", "commit": "b431d228b7bbcdaea818bdc3e25b8cdbe861f056" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "25c11854aa25558ee6c03432edfa0df0217324be" },
"mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" },
"neodev.nvim": { "branch": "main", "commit": "46aa467dca16cf3dfe27098042402066d2ae242d" },
"noice.nvim": { "branch": "main", "commit": "df448c649ef6bc5a6a633a44f2ad0ed8d4442499" },
"none-ls-extras.nvim": { "branch": "main", "commit": "f2bb002c8aa644d1f253772ff5d4e75e45ff7f4f" },
"none-ls-shellcheck.nvim": { "branch": "main", "commit": "0f84461241e76e376a95fb7391deac82dc3efdbf" },
"none-ls.nvim": { "branch": "main", "commit": "f1b438ab1709cf9d8875843559d20265013ac755" },
"nui.nvim": { "branch": "main", "commit": "a2bc1e9d0359caa5d11ad967cd1e30e8d4676226" },
"nvim-autopairs": { "branch": "master", "commit": "c15de7e7981f1111642e7e53799e1211d4606cb9" },
"nvim-cmp": { "branch": "main", "commit": "a110e12d0b58eefcf5b771f533fc2cf3050680ac" },
"none-ls.nvim": { "branch": "main", "commit": "dcc8cd4efdcb29275681a3c95786a816330dbca6" },
"nui.nvim": { "branch": "main", "commit": "b58e2bfda5cea347c9d58b7f11cf3012c7b3953f" },
"nvim-autopairs": { "branch": "master", "commit": "ee297f215e95a60b01fde33275cc3c820eddeebe" },
"nvim-cmp": { "branch": "main", "commit": "29fb4854573355792df9e156cb779f0d31308796" },
"nvim-colorizer.lua": { "branch": "master", "commit": "a065833f35a3a7cc3ef137ac88b5381da2ba302e" },
"nvim-lspconfig": { "branch": "master", "commit": "9c9eb07fecc578e25e28db8dc9002b43fff2ed79" },
"nvim-notify": { "branch": "master", "commit": "d333b6f167900f6d9d42a59005d82919830626bf" },
"nvim-tree.lua": { "branch": "master", "commit": "8b2c5c678be4b49dff6a2df794877000113fd77b" },
"nvim-treesitter": { "branch": "master", "commit": "09700b88b41ed96391de3d2010d74dc54fd5c210" },
"nvim-treesitter-refactor": { "branch": "master", "commit": "65ad2eca822dfaec2a3603119ec3cc8826a7859e" },
"nvim-ts-autotag": { "branch": "main", "commit": "ddfccbf0df1b9349c2b9e9b17f4afa8f9b6c1ed1" },
"nvim-ts-context-commentstring": { "branch": "main", "commit": "cb064386e667def1d241317deed9fd1b38f0dc2e" },
"nvim-web-devicons": { "branch": "master", "commit": "c0cfc1738361b5da1cd0a962dd6f774cc444f856" },
"nvim-lspconfig": { "branch": "master", "commit": "0d62a16429dba5fded93a076237079b81527e8f3" },
"nvim-notify": { "branch": "master", "commit": "fbef5d32be8466dd76544a257d3f3dce20082a07" },
"nvim-tree.lua": { "branch": "master", "commit": "2a268f631da85e83b7a95291be589bcddfc785d8" },
"nvim-treesitter": { "branch": "master", "commit": "bab7b0f20bd3e805b77231a77f516c7d69382693" },
"nvim-treesitter-refactor": { "branch": "master", "commit": "d8b74fa87afc6a1e97b18da23e762efb032dc270" },
"nvim-ts-autotag": { "branch": "main", "commit": "e239a560f338be31337e7abc3ee42515daf23f5e" },
"nvim-ts-context-commentstring": { "branch": "main", "commit": "9c74db656c3d0b1c4392fc89a016b1910539e7c0" },
"nvim-web-devicons": { "branch": "master", "commit": "19d257cf889f79f4022163c3fbb5e08639077bd8" },
"nx.nvim": { "branch": "main", "commit": "f8a3a21b3d540889401a40d1f2803083794c0372" },
"plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" },
"plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" },
"popup.nvim": { "branch": "master", "commit": "b7404d35d5d3548a82149238289fa71f7f6de4ac" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "9ef21b2e6bb6ebeaf349a0781745549bbb870d27" },
"telescope.nvim": { "branch": "master", "commit": "61a4a615366c470a4e9ca8f8b45718b6b92af73f" },
"todo-comments.nvim": { "branch": "main", "commit": "51e10f838e84b4756c16311d0b1ef0972c6482d2" },
"toggleterm.nvim": { "branch": "main", "commit": "cd55bf6aab3f88c259fa29ea86bbdcb1a325687d" },
"tokyonight.nvim": { "branch": "main", "commit": "30d7be361a7fbf187a881f17e574e9213d5108ea" },
"vim-fugitive": { "branch": "master", "commit": "64d6cafb9dcbacce18c26d7daf617ebb96b273f3" },
"which-key.nvim": { "branch": "main", "commit": "0099511294f16b81c696004fa6a403b0ae61f7a0" }
"telescope-fzf-native.nvim": { "branch": "main", "commit": "cf48d4dfce44e0b9a2e19a008d6ec6ea6f01a83b" },
"telescope.nvim": { "branch": "master", "commit": "df534c3042572fb958586facd02841e10186707c" },
"todo-comments.nvim": { "branch": "main", "commit": "ae0a2afb47cf7395dc400e5dc4e05274bf4fb9e0" },
"tokyonight.nvim": { "branch": "main", "commit": "4867d10ead04e69872b24818d0d306539305cf87" },
"vim-fugitive": { "branch": "master", "commit": "d4877e54cef67f5af4f950935b1ade19ed6b7370" },
"which-key.nvim": { "branch": "main", "commit": "8badb359f7ab8711e2575ef75dfe6fbbd87e4821" }
=======
"friendly-snippets": { "branch": "main", "commit": "00ebcaa159e817150bd83bfe2d51fa3b3377d5c4" },
"gitsigns.nvim": { "branch": "main", "commit": "899e993850084ea33d001ec229d237bc020c19ae" },
"lazy.nvim": { "branch": "main", "commit": "077102c5bfc578693f12377846d427f49bc50076" },
"lazydev.nvim": { "branch": "main", "commit": "491452cf1ca6f029e90ad0d0368848fac717c6d2" },
"lualine.nvim": { "branch": "master", "commit": "b431d228b7bbcdaea818bdc3e25b8cdbe861f056" },
"luvit-meta": { "branch": "main", "commit": "ce76f6f6cdc9201523a5875a4471dcfe0186eb60" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "482350b050bd413931c2cdd4857443c3da7d57cb" },
"mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" },
"noice.nvim": { "branch": "main", "commit": "448bb9c524a7601035449210838e374a30153172" },
"none-ls-extras.nvim": { "branch": "main", "commit": "dfdc998a8c7bb728abab156942bd43ed2345845a" },
"none-ls-shellcheck.nvim": { "branch": "main", "commit": "0f84461241e76e376a95fb7391deac82dc3efdbf" },
"none-ls.nvim": { "branch": "main", "commit": "203f5ebde4a1af48ba2eb146401b5be2e7866942" },
"nui.nvim": { "branch": "main", "commit": "61574ce6e60c815b0a0c4b5655b8486ba58089a1" },
"nvim-autopairs": { "branch": "master", "commit": "19606af7c039271d5aa96bceff101e7523af3136" },
"nvim-cmp": { "branch": "main", "commit": "ae644feb7b67bf1ce4260c231d1d4300b19c6f30" },
"nvim-colorizer.lua": { "branch": "master", "commit": "a065833f35a3a7cc3ef137ac88b5381da2ba302e" },
"nvim-lspconfig": { "branch": "master", "commit": "2a6f00ff66e276ab3289be8bb9f844f7ab385848" },
"nvim-notify": { "branch": "master", "commit": "d333b6f167900f6d9d42a59005d82919830626bf" },
"nvim-tree.lua": { "branch": "master", "commit": "d43ab67d0eb4317961c5e9d15fffe908519debe0" },
"nvim-treesitter": { "branch": "master", "commit": "7a64148896289a91cb2a92e9da3f76d5512a3fb8" },
"nvim-treesitter-refactor": { "branch": "master", "commit": "65ad2eca822dfaec2a3603119ec3cc8826a7859e" },
"nvim-ts-autotag": { "branch": "main", "commit": "e239a560f338be31337e7abc3ee42515daf23f5e" },
"nvim-ts-context-commentstring": { "branch": "main", "commit": "375c2d86cee6674afd75b4f727ce3a80065552f7" },
"nvim-web-devicons": { "branch": "master", "commit": "3722e3d1fb5fe1896a104eb489e8f8651260b520" },
"nx.nvim": { "branch": "main", "commit": "f8a3a21b3d540889401a40d1f2803083794c0372" },
"plenary.nvim": { "branch": "master", "commit": "ec289423a1693aeae6cd0d503bac2856af74edaa" },
"popup.nvim": { "branch": "master", "commit": "b7404d35d5d3548a82149238289fa71f7f6de4ac" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "cf48d4dfce44e0b9a2e19a008d6ec6ea6f01a83b" },
"telescope.nvim": { "branch": "master", "commit": "5972437de807c3bc101565175da66a1aa4f8707a" },
"todo-comments.nvim": { "branch": "main", "commit": "8f45f353dc3649cb9b44cecda96827ea88128584" },
"toggleterm.nvim": { "branch": "main", "commit": "137d06fb103952a0fb567882bb8527e2f92d327d" },
"tokyonight.nvim": { "branch": "main", "commit": "b0e7c7382a7e8f6456f2a95655983993ffda745e" },
"vim-fugitive": { "branch": "master", "commit": "0444df68cd1cdabc7453d6bd84099458327e5513" },
"which-key.nvim": { "branch": "main", "commit": "6c1584eb76b55629702716995cca4ae2798a9cca" }
>>>>>>> v0.7
}

View file

@ -7,6 +7,5 @@ vim.api.nvim_create_autocmd('VimResized', {
})
vim.cmd([[
command! CosmicUpdate lua require('cosmic.utils.cosmic').update()
command! CosmicDisableFormatOnSave lua require('cosmic.utils.lsp').toggle_format_on_save()
command! CosmicDisableFormatOnSave lua require('utils.lsp').toggle_format_on_save()
]])

19
lua/config.lua Normal file
View file

@ -0,0 +1,19 @@
local config = {
border = 'none',
disable_builtin_plugins = {},
add_plugins = {},
plugins = {},
lsp = {
inlay_hint = false,
format_timeout = 500,
rename_notification = true,
-- table of callbacks pushed via plugins
on_attach_mappings = {},
},
}
function config.lsp.add_on_attach_mapping(callback)
table.insert(config.lsp.on_attach_mappings, callback)
end
return config

View file

@ -1,124 +0,0 @@
-- Override Cosmic configuration options
local config = {
-- See :h nvim_open_win for possible border options
border = 'rounded',
-- LSP settings
lsp = {
-- Enable/disable inlay hints
inlay_hint = false,
-- Time in MS before format timeout
format_timeout = 3000,
-- Set to false to disable rename notification
rename_notification = true,
-- Enable non-default servers, use default lsp config
-- Check here for configs that will be used by default: https://github.com/williamboman/nvim-lsp-installer/tree/main/lua/nvim-lsp-installer/servers
-- lsp servers that should be installed
ensure_installed = {
'rust_analyzer',
},
-- See Cosmic defaults cosmic/plugins/null-ls/init.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 cosmic/plugins/null-ls/init.lua
null_ls = {
-- Disable default list of sources provided by CosmicNvim
default_cosmic_sources = false,
--disable formatting
format_on_save = false,
-- Add additional sources here
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,
},
-- lsp servers that should be enabled
servers = {
-- Enable rust_analyzer
rust_analyzer = true,
-- Enable tsserver w/custom settings
tsserver = {
-- Disable formatting (defaults to true)
format_on_save = false,
-- OR add/override server options
opts = {
on_attach = function(client, bufnr) end,
flags = {
debounce_text_changes = 150,
},
settings = {},
},
},
},
},
-- adjust default 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/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 = {},
},
-- Disable plugins default enabled by CosmicNvim
disable_builtin_plugins = {
--[[
'auto-session',
'colorizer',
'comment-nvim',
'dashboard',
'fugitive',
'gitsigns',
'lualine',
'noice',
'nvim-cmp',
'nvim-tree',
'telescope',
'terminal',
'theme',
'todo-comments',
'treesitter',
]]
},
-- Add additional plugins (lazy.nvim)
add_plugins = {
'ggandor/lightspeed.nvim',
{
'romgrk/barbar.nvim',
dependencies = { 'nvim-tree/nvim-web-devicons' },
},
},
}
return config

View file

@ -1,31 +0,0 @@
-- Override Cosmic editor options
local g = vim.g
local map = require('cosmic.utils').set_keymap
local opt = vim.opt
-- Default leader is <space>
g.mapleader = ','
-- Default indent = 2
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>')
-- Mapping options:
-- map('n', ...)
-- map('v', ...)
-- map('i', ...)
-- map('t', ...)
-- Example: Disable find files keymap
-- vim.keymap.del('n', '<leader>f')
-- See :h vim.keymap for more info

View file

@ -1,16 +0,0 @@
# Configuration
There are two main configuration files that you may want to create.
- cosmic/config/config.lua
- cosmic/config/editor.lua
Please look at the examples in this directory in order to get started.
## Quick Start
```bash
# from project root
cp ./lua/cosmic/config/examples/config.lua ./lua/cosmic/config/config.lua
cp ./lua/cosmic/config/examples/editor.lua ./lua/cosmic/config/editor.lua
```

View file

@ -1,32 +0,0 @@
local cosmic_modules = {
'cosmic.core.editor',
'cosmic.core.pluginsInit',
'cosmic.core.commands',
'cosmic.lsp',
'cosmic.config.editor',
-- load mappings only after editor configs are loaded
'cosmic.core.mappings',
}
-- set up lazy.nvim to install plugins
local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim'
if not vim.uv.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)
-- set up cosmicnvim
for _, mod in ipairs(cosmic_modules) do
local ok, err = pcall(require, mod)
-- cosmic.config files may or may not be present
if not ok and not mod:find('cosmic.config') then
error(('Error loading %s...\n\n%s'):format(mod, err))
end
end

View file

@ -1,64 +0,0 @@
-- DEFAULT USER SETTINGS
local ok, user_config = pcall(require, 'cosmic.config.config')
if not ok then
user_config = {}
end
local default_config = {
border = 'rounded',
disable_builtin_plugins = {},
add_plugins = {},
plugins = {},
lsp = {
inlay_hint = false,
format_timeout = 500,
rename_notification = true,
-- table of callbacks pushed via plugins
on_attach_mappings = {},
-- lsp servers that should be installed
ensure_installed = {
'astro',
'eslint',
'prettierd',
'cssls',
'gopls',
'graphql',
'html',
'jsonls',
'tsserver',
'lua_ls',
'pyright',
'svelte',
'tailwindcss',
'yamlls',
},
-- lsp servers that should be enabled
servers = {
astro = true,
tailwindcss = true,
eslint = true,
jsonls = {
format_on_save = false,
},
pyright = true,
lua_ls = {
format_on_save = false,
},
gopls = true,
html = true,
tsserver = {
format_on_save = false,
},
},
},
}
local u = require('cosmic.utils')
local config = u.merge(default_config, user_config)
function config.lsp.add_on_attach_mapping(callback)
table.insert(config.lsp.on_attach_mappings, callback)
end
return config

View file

@ -1 +0,0 @@
require('cosmic.core')

View file

@ -1,14 +0,0 @@
local defaults = require('cosmic.lsp.servers.defaults')
local can_format_on_save = require('cosmic.utils.lsp').can_client_format_on_save
return {
on_attach = function(client, bufnr)
defaults.on_attach(client, bufnr)
if can_format_on_save(client) then
vim.api.nvim_create_autocmd('BufWritePre', {
buffer = bufnr,
command = 'EslintFixAll',
group = defaults.augroup,
})
end
end,
}

View file

@ -1,34 +0,0 @@
local path = require('lspconfig/util').path
local function get_python_path(workspace)
-- Use activated virtualenv.
if vim.env.VIRTUAL_ENV then
return path.join(vim.env.VIRTUAL_ENV, 'bin', 'python')
end
-- Find and use virtualenv in workspace directory.
for _, pattern in ipairs({ '*', '.*' }) do
local match = vim.fn.glob(path.join(workspace, pattern, 'pyvenv.cfg'))
if match ~= '' then
return path.join(path.dirname(match), 'bin', 'python')
end
end
-- Fallback to system Python.
return exepath('python3') or exepath('python') or 'python'
end
return {
settings = {
python = {
analysis = {
typeCheckingMode = 'off',
useLibraryCodeForTypes = true,
completeFunctionParens = true,
},
},
},
before_init = function(_, config)
config.settings.python.pythonPath = get_python_path(config.root_dir)
end,
}

View file

@ -1,21 +0,0 @@
local user_config = require('cosmic.core.user')
local u = require('cosmic.utils')
local defaults = {
pre_save_cmds = { 'NvimTreeClose', 'cclose', 'lua vim.notify.dismiss()' },
auto_session_enabled = true,
auto_restore_enabled = true,
auto_save_enabled = true,
}
return {
'rmagatti/auto-session',
lazy = false,
config = function()
require('auto-session').setup(u.merge(defaults, user_config.plugins.auto_session or {}))
end,
init = function()
require('cosmic.plugins.auto-session.mappings')
end,
enabled = not vim.tbl_contains(user_config.disable_builtin_plugins, 'auto-session'),
}

View file

@ -1,11 +0,0 @@
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'),
}

View file

@ -1,6 +0,0 @@
local user_config = require('cosmic.core.user')
return {
'tpope/vim-fugitive',
cmd = 'Git',
enabled = not vim.tbl_contains(user_config.disable_builtin_plugins, 'fugitive'),
}

View file

@ -1,47 +0,0 @@
return {
'williamboman/mason-lspconfig.nvim',
config = function()
local user_config = require('cosmic.core.user')
require('mason').setup({
ui = {
border = user_config.border,
},
})
require('mason-lspconfig').setup({
ensure_installed = user_config.lsp.ensure_installed,
})
-- set up lsp servers
local u = require('cosmic.utils')
local default_config = require('cosmic.lsp.servers.defaults')
local lspconfig = require('lspconfig')
local start_server = function(server)
local server_config = default_config
-- set up default cosmic options
local ok, cosmic_server_config = pcall(require, 'cosmic.lsp.servers.' .. server)
if ok then
server_config = u.merge(server_config, cosmic_server_config)
end
-- override options if user defines them
if type(user_config.lsp.servers[server]) == 'table' and user_config.lsp.servers[server].opts ~= nil then
server_config = u.merge(server_config, user_config.lsp.servers[server].opts)
end
lspconfig[server].setup(server_config)
end
for config_server, config_opt in pairs(user_config.lsp.servers) do
if not config_opt == false then
start_server(config_server)
end
end
end,
dependencies = {
'williamboman/mason.nvim',
},
lazy = false,
--[[ event = 'BufEnter', ]]
}

View file

@ -1,72 +0,0 @@
local user_config = require('cosmic.core.user')
local u = require('cosmic.utils')
local map = require('cosmic.utils').set_keymap
return {
'folke/noice.nvim',
config = function()
local config = u.merge({
presets = {
lsp_doc_border = true,
long_message_to_split = true,
},
views = {
notify = {
merge = true,
},
},
messages = {
-- NOTE: If you enable messages, then the cmdline is enabled automatically.
-- This is a current Neovim limitation.
enabled = true, -- enables the Noice messages UI
view = 'mini', -- default view for messages
view_error = 'notify', -- view for errors
view_warn = 'notify', -- view for warnings
view_history = 'messages', -- view for :messages
view_search = 'virtualtext', -- view for search count messages. Set to `false` to disable
},
lsp = {
-- override markdown rendering so that **cmp** and other plugins use **Treesitter**
hover = {
enabled = true,
},
signature = {
enabled = true,
},
message = {
-- Messages shown by lsp servers
enabled = true,
view = 'mini',
opts = {},
},
override = {
['vim.lsp.util.convert_input_to_markdown_lines'] = true,
['vim.lsp.util.stylize_markdown'] = true,
['cmp.entry.get_documentation'] = true,
},
},
}, user_config.plugins.noice or {})
require('noice').setup(config)
map('n', '<c-j>', function()
if not require('noice.lsp').scroll(4) then
return '<c-j>'
end
end)
map('n', '<c-k>', function()
if not require('noice.lsp').scroll(-4) then
return '<c-k>'
end
end)
end,
event = 'VeryLazy',
dependencies = {
'MunifTanjim/nui.nvim',
{ 'rcarriga/nvim-notify', opts = {
timeout = 1000,
fps = 60,
} },
},
}

View file

@ -1,6 +0,0 @@
local user_config = require('cosmic.core.user')
return {
'neovim/nvim-lspconfig',
enabled = not vim.tbl_contains(user_config.disable_builtin_plugins, 'nvim-lspconfig'),
}

View file

@ -1,63 +0,0 @@
local user_config = require('cosmic.core.user')
local icons = require('cosmic.utils.icons')
local u = require('cosmic.utils')
-- set up args
local args = {
respect_buf_cwd = true,
diagnostics = {
enable = true,
show_on_dirs = true,
icons = {
hint = icons.hint,
info = icons.info,
warning = icons.warn,
error = icons.error,
},
},
update_focused_file = {
enable = true,
},
view = {
width = 40,
number = true,
relativenumber = true,
},
git = {
ignore = true,
},
renderer = {
highlight_git = true,
special_files = {},
icons = {
glyphs = {
default = '',
symlink = icons.symlink,
git = icons.git,
folder = icons.folder,
},
},
},
}
return {
'kyazdani42/nvim-tree.lua',
config = function()
require('nvim-tree').setup(u.merge(args, user_config.plugins.nvim_tree or {}))
end,
init = function()
local map = require('cosmic.utils').set_keymap
map('n', '<C-n>', ':NvimTreeToggle<CR>', { desc = 'Toggle Tree' })
map('n', '<leader>nt', ':NvimTreeToggle<CR>', { desc = 'Toggle Tree' })
map('n', '<leader>nr', ':NvimTreeRefresh<CR>', { desc = 'Refresh Tree' })
end,
cmd = {
'NvimTreeClipboard',
'NvimTreeFindFile',
'NvimTreeOpen',
'NvimTreeRefresh',
'NvimTreeToggle',
},
enabled = not vim.tbl_contains(user_config.disable_builtin_plugins, 'nvim-tree'),
}

View file

@ -1,18 +0,0 @@
local user_config = require('cosmic.core.user')
local u = require('cosmic.utils')
return {
'Equilibris/nx.nvim',
dependencies = {
'nvim-telescope/telescope.nvim',
},
opts = u.merge({
-- See below for config options
nx_cmd_root = 'yarn nx',
}, user_config.plugins.nx or {}),
-- Plugin will load when you use these keys
keys = {
{ '<leader>nx', '<cmd>Telescope nx actions<CR>', desc = 'nx actions' },
},
enabled = not vim.tbl_contains(user_config.disable_builtin_plugins, 'nx'),
}

View file

@ -1,11 +0,0 @@
local M = {}
M.project_files = function()
local opts = {} -- define here if you want to define something
local ok = pcall(require('telescope.builtin').git_files, opts)
if not ok then
require('telescope.builtin').find_files(opts)
end
end
return M

View file

@ -1,44 +0,0 @@
local user_config = require('cosmic.core.user')
local map = require('cosmic.utils').set_keymap
local create_buf_map = require('cosmic.utils').create_buf_map
return {
'akinsho/toggleterm.nvim',
config = function()
require('toggleterm').setup({
direction = 'float',
float_opts = {
border = user_config.border,
},
highlights = {
FloatBorder = {
link = 'FloatBorder',
},
},
})
local terminal_utils = require('cosmic.plugins.toggleterm.utils')
map('t', '<esc>', [[<C-\><C-n>]], { desc = 'Visual mode' })
-- toggle terminals
map('n', '<leader>k', ':ToggleTerm<CR>', { desc = 'Toggle Terminal' })
map('t', '<leader>k', [[<C-\><C-n>]] .. ':ToggleTerm<CR>', { desc = 'Toggle Terminal' })
-- new terminal
map('n', '<leader>kn', terminal_utils.new_terminal, { desc = 'New terminal' })
map('t', '<leader>kn', terminal_utils.new_terminal, { desc = 'New terminal' })
-- select terminal to open
map('n', '<leader>kk', ':TermSelect<CR>', { desc = 'Choose open terminal' })
map('t', '<leader>kk', [[<C-\><C-n>]] .. ':TermSelect<CR>', { desc = 'Choose open terminal' })
-- rename terminal
map('n', '<leader>kr', ':ToggleTermSetName<CR>', { desc = 'Rename terminal', buffer = 0 })
map('t', '<leader>kr', [[<C-\><C-n>]] .. ':ToggleTermSetName<CR>', { desc = 'Rename terminal', buffer = 0 })
-- terminal only mappings
vim.cmd("autocmd! TermOpen term://* lua require('cosmic.plugins.toggleterm.utils').set_terminal_keymaps()")
-- @TODO: close all
end,
lazy = false,
}

View file

@ -1,12 +0,0 @@
local M = {}
local map = require('cosmic.utils').set_keymap
local Terminal = require('toggleterm.terminal').Terminal
function M.new_terminal()
local terminal = Terminal:new()
terminal:toggle()
end
function M.set_terminal_keymaps() end
return M

View file

@ -1,13 +0,0 @@
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'),
},
}

View file

@ -1,2 +0,0 @@
local user_config = require('cosmic.core.user')
return user_config.add_plugins

View file

@ -1,77 +0,0 @@
local user_config = require('cosmic.core.user')
return {
'folke/which-key.nvim',
config = function()
local wk = require('which-key')
wk.setup({
window = {
border = user_config.border,
position = 'bottom',
margin = { 1, 0, 1, 0 },
padding = { 3, 2, 3, 2 },
winblend = 20,
},
layout = {
height = { min = 4, max = 25 },
width = { min = 20, max = 50 },
spacing = 8,
align = 'center',
},
})
wk.register({
['<leader>'] = {
b = {
name = '+buffer',
},
c = {
name = '+quickfix',
},
f = {
name = '+find',
},
h = {
name = '+gitsigns',
t = {
name = '+toggle',
},
},
l = {
name = '+lsp',
d = {
name = '+diagnostics',
},
t = {
name = '+toggle',
},
w = {
name = '+workspace',
},
},
g = {
name = '+goto',
},
n = {
name = '+tree',
},
s = {
name = '+session',
},
t = {
name = '+tab',
},
p = {
name = '+lazy (plugins)',
},
v = {
name = '+git (vsc)',
t = {
name = '+toggle',
},
},
},
})
end,
event = 'VeryLazy',
enabled = not vim.tbl_contains(user_config.disable_builtin_plugins, 'which-key'),
}

View file

@ -1,42 +0,0 @@
local M = {}
function M.get_install_dir()
local config_dir = os.getenv('COSMICNVIM_INSTALL_DIR')
if not config_dir then
return vim.fn.stdpath('config')
end
return config_dir
end
-- update instance of CosmicNvim
function M.update()
local Job = require('plenary.job')
local path = M.get_install_dir()
local errors = {}
Job
:new({
command = 'git',
args = { 'pull', '--ff-only' },
cwd = path,
on_start = function()
vim.notify('Updating...')
end,
on_exit = function()
if vim.tbl_isempty(errors) then
vim.notify('Updated! Running CosmicReloadSync...')
M.reload_user_config_sync()
else
table.insert(errors, 1, 'Something went wrong! Please pull changes manually.')
table.insert(errors, 2, '')
vim.notify('Update failed!', vim.log.levels.ERROR)
end
end,
on_stderr = function(_, err)
table.insert(errors, err)
end,
})
:sync()
end
return M

View file

@ -1,84 +0,0 @@
local icons = {
rounded_left_filled = '',
rounded_right_filled = '',
arrow_left_filled = '', -- e0b2
arrow_right_filled = '', -- e0b0
arrow_left = '', -- e0b3
arrow_right = '', -- e0b1
ghost = '',
cosmic = '💫',
star = '',
scorpio = '♏︎',
rocket = '🚀',
warn = '',
info = '',
error = '',
hint = '',
perf = '',
note = '',
branch = '',
file = '',
dotdotdot = '',
information = '',
symlink = '',
line_number = '',
debug = '',
flame = '',
check = '',
trace = '',
file1 = '',
file2 = '',
clock = '',
word = '',
diff_add = '',
diff_modified = '',
diff_remove = '',
git = {
unstaged = '',
staged = '',
unmerged = '',
renamed = '',
untracked = '',
deleted = '',
ignored = '',
},
folder = {
arrow_open = '',
arrow_closed = '',
default = '',
open = '',
empty = '',
empty_open = '',
symlink = '',
symlink_open = '',
},
kind_icons = {
Text = '',
Method = 'm',
Function = '',
Constructor = '',
Field = '',
Variable = '',
Class = '',
Interface = '',
Module = '',
Property = '',
Unit = '',
Value = '',
Enum = '',
Keyword = '',
Snippet = '',
Color = '',
File = '',
Reference = '',
Folder = '',
EnumMember = '',
Constant = '',
Struct = '',
Event = '',
Operator = '',
TypeParameter = '',
},
}
return icons

View file

@ -1,7 +1,7 @@
local user_config = require('cosmic.core.user')
local config = require('config')
local found = false
for _, plugin in ipairs(user_config.add_plugins) do
for _, plugin in ipairs(config.add_plugins) do
if plugin[1] == 'pmizio/typescript-tools.nvim' then
found = true
break
@ -79,7 +79,7 @@ if found then
end
-- print(vim.inspect(externalFiles))
-- send configuration request of monodon plugin to tsserver
-- send configuration request of monodon plugin to ts_ls
local constants = require('typescript-tools.protocol.constants')
local method = constants.CustomMethods.ConfigurePlugin
local args = {
@ -91,7 +91,7 @@ if found then
---@diagnostic disable-next-line: missing-parameter
tsclient.request(method, args, function()
print('tsserver handled configuration request', method)
print('ts_ls handled configuration request', method)
end)
print('NX Plugin initialized!')
end

View file

@ -1,6 +1,6 @@
local u = require('cosmic.utils')
local icons = require('cosmic.utils.icons')
local user_config = require('cosmic.core.user')
local u = require('utils')
local icons = require('utils.icons')
local config = require('config')
local function format_diagnostic(diagnostic)
local icon = icons.error
@ -22,7 +22,7 @@ local function format_diagnostic(diagnostic)
return message .. ' '
end
local config = u.merge({
local diagnostic_config = u.merge({
underline = true,
update_in_insert = false,
severity_sort = true,
@ -41,7 +41,7 @@ local config = u.merge({
},
},
float = {
border = user_config.border,
border = config.border,
focusable = false,
header = { icons.debug .. ' Diagnostics:', 'DiagnosticInfo' },
scope = 'line',
@ -58,7 +58,7 @@ local config = u.merge({
},
format = format_diagnostic,
},
}, user_config.diagnostic or {})
}, config.diagnostic or {})
-- set up diagnostics
vim.diagnostic.config(config)
vim.diagnostic.config(diagnostic_config)

View file

@ -1,4 +1,4 @@
require('cosmic.lsp.diagnostics')
require('cosmic.lsp.commands')
require('lsp.diagnostics')
require('lsp.commands')
-- LSP server initialization can be found in mason-lspconfig setup

View file

@ -1,5 +1,5 @@
local utils = require('cosmic.utils')
local lsp_utils = require('cosmic.utils.lsp')
local utils = require('utils')
local lsp_utils = require('utils.lsp')
local M = {}
-- Mappings.
@ -57,7 +57,7 @@ function M.init(client, bufnr)
buf_map(
'n',
'<leader>lwl',
'<cmd>lua require("cosmic.utils.logger"):log(vim.inspect(vim.lsp.buf.list_workspace_folders()))<cr>',
'<cmd>lua require("utils.logger"):log(vim.inspect(vim.lsp.buf.list_workspace_folders()))<cr>',
{ desc = 'Show workspace folders' }
)
end

6
lua/lsp/servers.lua Normal file
View file

@ -0,0 +1,6 @@
return {
'lua_ls',
'eslint',
'ts_ls',
'svelte',
}

View file

@ -1,9 +1,9 @@
local M = {}
local augroup_name = 'CosmicNvimLspFormat'
local user_config = require('cosmic.core.user')
local u = require('cosmic.utils')
local lsp_utils = require('cosmic.utils.lsp')
local lsp_mappings = require('cosmic.lsp.mappings')
local config = require('config')
local u = require('utils')
local lsp_utils = require('utils.lsp')
local lsp_mappings = require('lsp.mappings')
M.augroup = vim.api.nvim_create_augroup(augroup_name, { clear = true })
@ -17,14 +17,14 @@ function M.on_attach(client, bufnr)
-- Enable completion triggered by <c-x><c-o>
buf_set_option('omnifunc', 'v:lua.vim.lsp.omnifunc')
if user_config.lsp.inlay_hint and client.supports_method('textDocument/inlayHint') then
if config.lsp.inlay_hint and client.supports_method('textDocument/inlayHint') then
vim.lsp.inlay_hint.enable(true, { bufnr = bufnr })
end
if client.supports_method('textDocument/formatting') then
-- set up :LspFormat for clients that are capable
vim.cmd(
string.format("command! -nargs=? LspFormat lua require('cosmic.utils.lsp').buf_format(%s, <q-args>)", bufnr)
string.format("command! -nargs=? LspFormat lua require('utils.lsp').buf_format(%s, <q-args>)", bufnr)
)
-- set up auto format on save
@ -34,15 +34,10 @@ function M.on_attach(client, bufnr)
})
vim.api.nvim_create_autocmd('BufWritePre', {
callback = function()
if lsp_utils.format_on_save_enabled then
vim.lsp.buf.format({
timeout_ms = user_config.lsp.format_timeout,
bufnr = bufnr,
filter = function()
return lsp_utils.can_client_format_on_save(client)
end,
})
end
vim.lsp.buf.format({
timeout_ms = config.lsp.format_timeout,
bufnr = bufnr,
})
end,
buffer = bufnr,
group = M.augroup,
@ -53,7 +48,7 @@ function M.on_attach(client, bufnr)
lsp_mappings.init(client, bufnr)
-- set up any additional mappings/overrides from user config
for _, callback in pairs(user_config.lsp.on_attach_mappings) do
for _, callback in pairs(config.lsp.on_attach_mappings) do
callback(client, bufnr)
end
end

View file

@ -0,0 +1,12 @@
local defaults = require('lsp.servers.defaults')
return {
on_attach = function(client, bufnr)
defaults.on_attach(client, bufnr)
vim.api.nvim_create_autocmd('BufWritePre', {
buffer = bufnr,
command = 'EslintFixAll',
group = defaults.augroup,
})
end,
}

View file

@ -1,4 +1,4 @@
local map = require('cosmic.utils').set_keymap
local map = require('utils').set_keymap
-- Quickfix mappings
map('n', '<leader>ck', ':cexpr []<cr>', { desc = 'Clear list' })
@ -9,9 +9,11 @@ map('n', '<leader>cp', ':cprev<cr>zz', { desc = 'Prev Item' })
map('n', '<leader>cn', ':cnext<cr>zz', { desc = 'Next Item' })
-- buffer navigation
map('n', '<leader>bp', ':bprev<cr>', { desc = 'Prev buffer' })
map('n', '<leader>bn', ':bnext<cr>', { desc = 'Next buffer' })
map('n', '<leader>bd', ':bdelete<cr>', { desc = 'Delete buffer' })
map('n', '<leader>kp', ':bprev<cr>', { desc = 'Prev buffer' })
map('n', '<leader>kn', ':bnext<cr>', { desc = 'Next buffer' })
map('n', '<leader>kd', ':bdelete<cr>', { desc = 'Delete buffer' })
map('n', '<leader>kc', ':new<cr>', { desc = 'New buffer' })
map('n', '<leader>ko', '<cmd>%bd|e#<cr>', { desc = 'Close all buffers but the current one' }) -- https://stackoverflow.com/a/42071865/516188
-- tab navigation
map('n', '<leader>tp', ':tabprevious<cr>', { desc = 'Prev tab' })
@ -33,14 +35,3 @@ map('n', '<C-Up>', ':resize -2<CR>', { desc = 'Resize -2' })
map('n', '<C-Down>', ':resize +2<CR>', { desc = 'Resize +2' })
map('n', '<C-Left>', ':vertical resize -2<CR>', { desc = 'Vertical Resize -2' })
map('n', '<C-Right>', ':vertical resize +2<CR>', { desc = 'Vertical Resize +2' })
-- map('n', '<C-h>', [[<Cmd>wincmd h<CR>]], {})
-- map('n', '<C-j>', [[<Cmd>wincmd j<CR>]], {})
-- map('n', '<C-k>', [[<Cmd>wincmd k<CR>]], {})
-- map('n', '<C-l>', [[<Cmd>wincmd l<CR>]], {})
--[[ map('n', '<C-h>', '<C-w>h', {}) ]]
--[[ map('n', '<C-j>', '<C-w>j', {}) ]]
--[[ map('n', '<C-k>', '<C-w>k', {}) ]]
--[[ map('n', '<C-l>', '<C-w>l', {}) ]]
map('n', '<leader>bo', '<cmd>%bd|e#<cr>', { desc = 'Close all buffers but the current one' }) -- https://stackoverflow.com/a/42071865/516188

View file

@ -1,5 +1,5 @@
local user_config = require('cosmic.core.user')
local u = require('cosmic.utils')
local config = require('config')
local u = require('utils')
return {
'windwp/nvim-autopairs',
@ -13,7 +13,7 @@ return {
},
disable_filetype = { 'TelescopePrompt', 'vim' },
fast_wrap = {},
}, user_config.plugins.nvim_autopairs or {}))
}, config.plugins.nvim_autopairs or {}))
end,
enabled = not vim.tbl_contains(user_config.disable_builtin_plugins, 'autopairs'),
enabled = not vim.tbl_contains(config.disable_builtin_plugins, 'autopairs'),
}

View file

@ -0,0 +1,21 @@
local config = require('config')
local u = require('utils')
local defaults = {
pre_save_cmds = { 'NvimTreeClose', 'cclose', 'lua vim.notify.dismiss()' },
auto_session_enabled = true,
auto_restore_enabled = true,
auto_save_enabled = true,
}
return {
'rmagatti/auto-session',
lazy = false,
config = function()
require('auto-session').setup(u.merge(defaults, config.plugins.auto_session or {}))
end,
init = function()
require('plugins.auto-session.mappings')
end,
enabled = not vim.tbl_contains(config.disable_builtin_plugins, 'auto-session'),
}

View file

@ -1,4 +1,4 @@
local map = require('cosmic.utils').set_keymap
local map = require('utils').set_keymap
-- session
map('n', '<leader>sl', '<cmd>silent RestoreSession<cr>', { desc = 'Restore session' })
@ -6,6 +6,6 @@ map('n', '<leader>ss', '<cmd>SaveSession<cr>', { desc = 'Save session' })
map(
'n',
'<leader>si',
'<cmd>lua require("cosmic.utils.logger"):log("Session name: " .. require("auto-session-library").current_session_name())<cr>',
'<cmd>lua require("utils.logger"):log("Session name: " .. require("auto-session-library").current_session_name())<cr>',
{ desc = 'Print session' }
)

11
lua/plugins/colorizer.lua Normal file
View file

@ -0,0 +1,11 @@
local config = require('config')
local u = require('utils')
return {
'norcalli/nvim-colorizer.lua',
cmd = { 'ColorizerToggle' },
config = function()
require('colorizer').setup(u.merge({}, config.plugins.colorizer or {}))
end,
enabled = not vim.tbl_contains(config.disable_builtin_plugins, 'colorizer'),
}

View file

@ -1,5 +1,5 @@
local user_config = require('cosmic.core.user')
local u = require('cosmic.utils')
local config = require('config')
local u = require('utils')
return {
'numToStr/Comment.nvim',
@ -19,8 +19,8 @@ return {
location = location,
})
end,
}, user_config.plugins.comment_nvim or {}))
}, config.plugins.comment_nvim or {}))
end,
event = 'VeryLazy',
enabled = not vim.tbl_contains(user_config.disable_builtin_plugins, 'comment-nvim'),
enabled = not vim.tbl_contains(config.disable_builtin_plugins, 'comment-nvim'),
}

View file

@ -1,8 +1,8 @@
local user_config = require('cosmic.core.user')
local utils = require('cosmic.utils')
local config = require('config')
local utils = require('utils')
local defaults = {
border_style = 'rounded',
local plugin_config = {
border_style = 'single',
}
return {
@ -11,10 +11,10 @@ return {
'MunifTanjim/nui.nvim',
},
init = function()
user_config.lsp.add_on_attach_mapping(function(client, bufnr)
config.lsp.add_on_attach_mapping(function(client, bufnr)
local buf_map = utils.create_buf_map(bufnr)
buf_map('n', 'gn', '<cmd>lua require("cosmic-ui").rename()<cr>', { desc = 'Rename' })
buf_map('n', '<leader>r', '<cmd>lua require("cosmic-ui").rename()<cr>', { desc = 'Rename' })
buf_map('n', '<leader>la', '<cmd>lua require("cosmic-ui").code_actions()<cr>', { desc = 'Code Actions' })
buf_map(
'v',
@ -25,8 +25,7 @@ return {
end)
end,
config = function()
require('cosmic-ui').setup(utils.merge(defaults, user_config.plugins.cosmic_ui or {}))
require('cosmic-ui').setup(plugin_config)
end,
event = 'VeryLazy',
enabled = not vim.tbl_contains(user_config.disable_builtin_plugins, 'cosmic-ui'),
}

View file

@ -1,5 +1,5 @@
local user_config = require('cosmic.core.user')
local icons = require('cosmic.utils.icons')
local config = require('config')
local icons = require('utils.icons')
local g = vim.g
return {
@ -12,7 +12,7 @@ return {
g.dashboard_custom_section = {
find_file = {
description = { icons.file1 .. ' Find File <leader>ff' },
command = 'lua require("cosmic.plugins.telescope.mappings").project_files()',
command = 'lua require("plugins.telescope.mappings").project_files()',
},
file_explorer = {
description = { icons.file2 .. ' File Manager <C-n> ' },
@ -55,5 +55,5 @@ return {
})
end,
event = 'VimEnter',
enabled = not vim.tbl_contains(user_config.disable_builtin_plugins, 'dashboard'),
enabled = not vim.tbl_contains(config.disable_builtin_plugins, 'dashboard'),
}

6
lua/plugins/fugitive.lua Normal file
View file

@ -0,0 +1,6 @@
local config = require('config')
return {
'tpope/vim-fugitive',
cmd = 'Git',
enabled = not vim.tbl_contains(config.disable_builtin_plugins, 'fugitive'),
}

View file

@ -1,5 +1,5 @@
local user_config = require('cosmic.core.user')
local u = require('cosmic.utils')
local config = require('config')
local u = require('utils')
return {
'lewis6991/gitsigns.nvim',
@ -8,16 +8,16 @@ return {
config = function()
local gs = require('gitsigns')
gs.setup(u.merge({
signs = {
add = { text = '' },
change = { text = '' },
delete = { text = '_' },
topdelete = { text = '' },
changedelete = { text = '~' },
},
--[[ 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' }, ]]
--[[ }, ]]
preview_config = {
-- Options passed to nvim_open_win
border = user_config.border,
border = config.border,
style = 'minimal',
relative = 'cursor',
row = 0,
@ -53,30 +53,30 @@ return {
})
-- Actions
map('n', '<leader>hs', gs.stage_hunk, { desc = 'Stage hunk' })
map('n', '<leader>hr', gs.reset_hunk, { desc = 'Reset hunk' })
map('v', '<leader>hs', function()
map('n', '<leader>vs', gs.stage_hunk, { desc = 'Stage hunk' })
map('n', '<leader>vr', gs.reset_hunk, { desc = 'Reset hunk' })
map('v', '<leader>vs', function()
gs.stage_hunk({ vim.fn.line('.'), vim.fn.line('v') })
end, {
desc = 'Stage hunk selection',
})
map('v', '<leader>hr', function()
map('v', '<leader>vr', function()
gs.reset_hunk({ vim.fn.line('.'), vim.fn.line('v') })
end, {
desc = 'Reset hunk selection',
})
map('n', '<leader>hS', gs.stage_buffer, { desc = 'Stage buffer' })
map('n', '<leader>hu', gs.undo_stage_hunk, { desc = 'Undo stage hunk' })
map('n', '<leader>hR', gs.reset_buffer, { desc = 'Reset buffer' })
map('n', '<leader>hp', gs.preview_hunk, { desc = 'Preview hunk' })
map('n', '<leader>hb', function()
map('n', '<leader>vS', gs.stage_buffer, { desc = 'Stage buffer' })
map('n', '<leader>vu', gs.undo_stage_hunk, { desc = 'Undo stage hunk' })
map('n', '<leader>vR', gs.reset_buffer, { desc = 'Reset buffer' })
map('n', '<leader>vp', gs.preview_hunk, { desc = 'Preview hunk' })
map('n', '<leader>vb', function()
gs.blame_line({ full = true })
end, {
desc = 'Blame line',
})
map('n', '<leader>htb', gs.toggle_current_line_blame, { desc = 'Toggle blame current line' })
map('n', '<leader>hd', gs.diffthis, { desc = 'Diff buffer' })
map('n', '<leader>hD', function()
map('n', '<leader>vtb', gs.toggle_current_line_blame, { desc = 'Toggle blame current line' })
map('n', '<leader>vd', gs.diffthis, { desc = 'Diff buffer' })
map('n', '<leader>vD', function()
gs.diffthis('~')
end, { desc = 'Diff project' })
map('n', '<leader>td', gs.toggle_deleted, { desc = 'Toggle delete' })
@ -84,7 +84,7 @@ return {
--[[ -- Text object ]]
map({ 'o', 'x' }, 'ih', ':<C-U>Gitsigns select_hunk<CR>', { desc = 'Select hunk' })
end,
}, user_config.plugins.gitsigns or {}))
}, config.plugins.gitsigns or {}))
end,
enabled = not vim.tbl_contains(user_config.disable_builtin_plugins, 'gitsigns'),
enabled = not vim.tbl_contains(config.disable_builtin_plugins, 'gitsigns'),
}

View file

@ -1,4 +1,4 @@
local user_config = require('cosmic.core.user')
local config = require('config')
return {
'folke/lazydev.nvim',
ft = 'lua', -- only load on lua files
@ -13,6 +13,6 @@ return {
},
},
dependencies = { { 'Bilal2453/luvit-meta', lazy = true } },
enabled = not vim.tbl_contains(user_config.disable_builtin_plugins, 'lazydev'),
enabled = not vim.tbl_contains(config.disable_builtin_plugins, 'lazydev'),
event = 'VeryLazy',
}

View file

@ -1,7 +1,7 @@
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')
local config = require('config')
local utils = require('utils')
local lsp_utils = require('utils.lsp')
local icons = require('utils.icons')
local custom_sections = {
branch = { 'b:gitsigns_head', icon = icons.branch },
@ -103,7 +103,7 @@ return {
lualine_z = {},
},
extensions = { 'quickfix', 'fugitive', 'nvim-tree' },
}, user_config.plugins.lualine or {}))
}, config.plugins.lualine or {}))
vim.api.nvim_create_autocmd('RecordingEnter', {
callback = function()
@ -136,6 +136,5 @@ return {
end,
})
end,
dependencies = { 'nvim-tree/nvim-web-devicons' },
enabled = not vim.tbl_contains(user_config.disable_builtin_plugins, 'lualine'),
enabled = not vim.tbl_contains(config.disable_builtin_plugins, 'lualine'),
}

View file

@ -1,5 +1,5 @@
local user_config = require('cosmic.core.user')
local u = require('cosmic.utils')
local config = require('config')
local u = require('utils')
return {
'nvimtools/none-ls.nvim',
@ -8,13 +8,13 @@ return {
'gbprod/none-ls-shellcheck.nvim',
},
config = function()
local defaults = require('cosmic.lsp.servers.defaults')
local defaults = require('lsp.servers.defaults')
local null_ls = require('null-ls')
local config_opts = u.merge({
default_cosmic_sources = true,
}, user_config.lsp.null_ls or {})
}, config.lsp.null_ls or {})
if config_opts.default_cosmic_sources then
local function get_user_config_sources()
local function get_config_sources()
if not config_opts.add_sources then
return {}
end
@ -32,12 +32,12 @@ return {
extra_filetypes = { 'astro' },
}),
null_ls.builtins.formatting.stylua,
}, get_user_config_sources())
}, get_config_sources())
end
null_ls.setup(u.merge(defaults, config_opts))
end,
--[[ event = 'BufEnter', ]]
lazy = false,
enabled = not vim.tbl_contains(user_config.disable_builtin_plugins, 'null_ls'),
enabled = not vim.tbl_contains(config.disable_builtin_plugins, 'null_ls'),
}

View file

@ -1,10 +1,10 @@
local cmp = require('cmp')
local u = require('cosmic.utils')
local user_config = require('cosmic.core.user')
local icons = require('cosmic.utils.icons')
local u = require('utils')
local config = require('config')
local icons = require('utils.icons')
local cmp_autopairs = require('nvim-autopairs.completion.cmp')
local user_has_luasnip = not vim.tbl_contains(user_config.disable_builtin_plugins, 'luasnip')
local user_has_luasnip = not vim.tbl_contains(config.disable_builtin_plugins, 'luasnip')
local _, luasnip = pcall(require, 'luasnip')
local has_words_before = function()
@ -75,11 +75,11 @@ local default_cmp_opts = {
}),
window = {
completion = {
border = user_config.border,
border = config.border,
winhighlight = 'FloatBorder:FloatBorder,Normal:Normal',
},
documentation = {
border = user_config.border,
border = config.border,
winhighlight = 'FloatBorder:FloatBorder,Normal:Normal',
},
},
@ -111,7 +111,7 @@ local default_cmp_opts = {
-- 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 {}))
cmp.setup(u.merge(default_cmp_opts, config.plugins.nvim_cmp or {}))
-- Set configuration for specific filetype.
cmp.setup.filetype('gitcommit', {

View file

@ -1,16 +1,16 @@
local user_config = require('cosmic.core.user')
local u = require('cosmic.utils')
local config = require('config')
local u = require('utils')
return {
'hrsh7th/nvim-cmp',
config = function()
require('cosmic.plugins.nvim-cmp.config')
require('plugins.nvim-cmp.config')
end,
dependencies = {
'hrsh7th/cmp-nvim-lsp',
{
'saadparwaiz1/cmp_luasnip',
enabled = not vim.tbl_contains(user_config.disable_builtin_plugins, 'luasnip'),
enabled = not vim.tbl_contains(config.disable_builtin_plugins, 'luasnip'),
},
'hrsh7th/cmp-buffer',
'hrsh7th/cmp-cmdline',
@ -24,7 +24,7 @@ return {
-- Update more often, :h events for more info.
updateevents = 'TextChanged,TextChangedI',
enable_autosnippets = true,
}, user_config.plugins.luasnip or {}))
}, config.plugins.luasnip or {}))
-- extend html snippets to react files
require('luasnip').filetype_extend('javascriptreact', { 'html' })
@ -36,9 +36,9 @@ return {
dependencies = {
'rafamadriz/friendly-snippets',
},
enabled = not vim.tbl_contains(user_config.disable_builtin_plugins, 'luasnip'),
enabled = not vim.tbl_contains(config.disable_builtin_plugins, 'luasnip'),
},
},
event = 'InsertEnter',
enabled = not vim.tbl_contains(user_config.disable_builtin_plugins, 'nvim-cmp'),
enabled = not vim.tbl_contains(config.disable_builtin_plugins, 'nvim-cmp'),
}

View file

@ -0,0 +1,26 @@
local config = require('config')
return {
'neovim/nvim-lspconfig',
config = function()
local u = require('utils')
local default_config = require('lsp.servers.defaults')
local lspconfig = require('lspconfig')
local start_server = function(server)
local server_config = default_config
local ok, cosmic_server_config = pcall(require, 'lsp.servers.' .. server)
if ok then
server_config = u.merge(server_config, cosmic_server_config)
end
lspconfig[server].setup(server_config)
end
for _, server in pairs(require('lsp.servers')) do
start_server(server)
end
end,
lazy = false,
}

View file

@ -1,7 +1,7 @@
local actions = require('telescope.actions')
local user_config = require('cosmic.core.user')
local icons = require('cosmic.utils.icons')
local u = require('cosmic.utils')
local config = require('config')
local icons = require('utils.icons')
local u = require('utils')
local default_mappings = {
n = {
@ -49,7 +49,6 @@ local opts_flex = {
require('telescope').setup(u.merge({
defaults = {
prompt_prefix = '🔍 ',
selection_caret = icons.folder.arrow_closed,
file_ignore_patterns = {
'.git/',
@ -70,16 +69,16 @@ require('telescope').setup(u.merge({
},
extensions = {
fzf = {
fuzzy = true, -- false will only do exact matching
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"
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',
prompt_title = 'Search Buffers',
mappings = u.merge({
n = {
['d'] = actions.delete_buffer,
@ -111,7 +110,7 @@ require('telescope').setup(u.merge({
mappings = default_mappings,
}),
find_files = u.merge(opts_flex, {
prompt_title = 'Search Project',
prompt_title = 'Search Project',
mappings = default_mappings,
hidden = true,
}),
@ -119,19 +118,19 @@ require('telescope').setup(u.merge({
mappings = default_mappings,
}),
git_files = u.merge(opts_flex, {
prompt_title = 'Search Git Project',
prompt_title = 'Search Git Project',
mappings = default_mappings,
hidden = true,
}),
live_grep = u.merge(opts_flex, {
prompt_title = 'Live Grep',
prompt_title = 'Live Grep',
mappings = default_mappings,
}),
grep_string = u.merge(opts_vertical, {
prompt_title = 'Grep String',
prompt_title = 'Grep String',
mappings = default_mappings,
}),
},
}, user_config.plugins.telescope or {}))
}, config.plugins.telescope or {}))
require('telescope').load_extension('fzf')

View file

@ -1,4 +1,4 @@
local user_config = require('cosmic.core.user')
local config = require('config')
return {
'nvim-telescope/telescope.nvim',
dependencies = {
@ -10,18 +10,14 @@ return {
},
},
config = function()
require('cosmic.plugins.telescope.config')
require('plugins.telescope.config')
end,
init = function()
-- normal mappings
local u = require('cosmic.utils')
local u = require('utils')
local map = u.set_keymap
map('n', '<leader>ff', '', {
callback = require('cosmic.plugins.telescope.utils').project_files,
desc = 'Find file',
})
map('n', '<leader>fp', ':Telescope find_files<cr>', { desc = 'Find project file' })
map('n', '<leader>ff', ':Telescope find_files<cr>', { desc = 'Find project file' })
map('n', '<leader>fk', ':Telescope buffers<cr>', { desc = 'Find buffer' })
map('n', '<leader>fs', ':Telescope live_grep<cr>', { desc = 'Grep string' })
map('n', '<leader>fw', ':Telescope grep_string<cr>', { desc = 'Grep current word' })
@ -30,7 +26,7 @@ return {
map('n', '<leader>vc', ':Telescope git_commits<cr>', { desc = 'Git commits' })
map('n', '<leader>vg', ':Telescope git_status<cr>', { desc = 'Git status' })
user_config.lsp.add_on_attach_mapping(function(client, bufnr)
config.lsp.add_on_attach_mapping(function(_, bufnr)
local buf_map = u.create_buf_map(bufnr)
buf_map('n', 'gd', '<cmd>Telescope lsp_definitions<cr>', { desc = 'Go to definition' })
@ -43,12 +39,4 @@ return {
end)
end,
cmd = { 'Telescope' },
keys = {
{
'<leader>ff',
'<cmd>lua require("cosmic.plugins.telescope.utils").project_files()<cr>',
desc = 'Find project file',
},
},
enabled = not vim.tbl_contains(user_config.disable_builtin_plugins, 'telescope'),
}

View file

@ -1,6 +1,6 @@
local user_config = require('cosmic.core.user')
local icons = require('cosmic.utils.icons')
local u = require('cosmic.utils')
local config = require('config')
local icons = require('utils.icons')
local u = require('utils')
return {
'folke/todo-comments.nvim',
@ -27,8 +27,8 @@ return {
hint = { 'DiagnosticHint', '#10B981' },
default = { 'Identifier', '#7C3AED' },
},
}, user_config.plugins.todo_comments or {}))
}, config.plugins.todo_comments or {}))
end,
event = 'VeryLazy',
enabled = not vim.tbl_contains(user_config.disable_builtin_plugins, 'todo-comments'),
enabled = not vim.tbl_contains(config.disable_builtin_plugins, 'todo-comments'),
}

View file

@ -0,0 +1,35 @@
local config = require('config')
local map = require('utils').set_keymap
return {
'akinsho/toggleterm.nvim',
config = function()
require('toggleterm').setup({
direction = 'float',
float_opts = {
border = config.border,
},
highlights = {
FloatBorder = {
link = 'FloatBorder',
},
},
})
local terminal_utils = require('plugins.toggleterm.utils')
-- toggle terminals
map('n', '<leader>xx', ':ToggleTerm<CR>', { desc = 'Toggle Terminal' })
-- new terminal
map('n', '<leader>xn', terminal_utils.new_terminal, { desc = 'New terminal' })
-- select terminal to open
map('n', '<leader>fx', ':TermSelect<CR>', { desc = 'Find open terminal' })
-- rename terminal
map('n', '<leader>xr', ':ToggleTermSetName<CR>', { desc = 'Rename terminal', buffer = 0 })
-- terminal only mappings
vim.cmd("autocmd! TermOpen term://* lua require('plugins.toggleterm.utils').set_terminal_keymaps()")
end,
lazy = false,
}

View file

@ -0,0 +1,18 @@
local M = {}
local map = require('utils').set_keymap
local Terminal = require('toggleterm.terminal').Terminal
function M.new_terminal()
local terminal = Terminal:new()
terminal:toggle()
end
function M.set_terminal_keymaps()
map('t', '<C-n>', [[<C-\><C-n>]], { desc = 'Visual mode' })
-- map('t', '<leader>xx', [[<C-\><C-n>]] .. ':ToggleTerm<CR>', { desc = 'Toggle Terminal' })
-- map('t', '<leader>xn', M.new_terminal, { desc = 'New terminal' })
-- map('t', '<leader>fx', [[<C-\><C-n>]] .. ':TermSelect<CR>', { desc = 'Find open terminal' })
-- map('t', '<leader>xr', [[<C-\><C-n>]] .. ':ToggleTermSetName<CR>', { desc = 'Rename terminal', buffer = 0 })
end
return M

View file

@ -1,5 +1,5 @@
local user_config = require('cosmic.core.user')
local u = require('cosmic.utils')
local config = require('config')
local u = require('utils')
local config = u.merge({
@ -7,6 +7,6 @@ local config = u.merge({
style = 'night',
light_style = 'moon',
sidebars = { 'qf', 'packer', 'help' },
}, user_config.plugins.tokyonight or {})
}, config.plugins.tokyonight or {})
return config

View file

@ -0,0 +1,13 @@
local config = require('config')
return {
{ -- color scheme
'folke/tokyonight.nvim',
lazy = false,
config = function()
local config = require('plugins.tokyonight.config')
require('tokyonight').setup(config)
vim.cmd('color tokyonight')
end,
enabled = not vim.tbl_contains(config.disable_builtin_plugins, 'tokyonight'),
},
}

View file

@ -1,5 +1,5 @@
local user_config = require('cosmic.core.user')
local u = require('cosmic.utils')
local config = require('config')
local u = require('utils')
local defaults = {
ensure_installed = {
@ -52,7 +52,7 @@ return {
event = 'BufEnter',
build = ':TSUpdate',
config = function()
require('nvim-treesitter.configs').setup(u.merge(defaults, user_config.plugins.treesitter or {}))
require('nvim-treesitter.configs').setup(u.merge(defaults, config.plugins.treesitter or {}))
end,
enabled = not vim.tbl_contains(user_config.disable_builtin_plugins, 'treesitter'),
enabled = not vim.tbl_contains(config.disable_builtin_plugins, 'treesitter'),
}

44
lua/plugins/which-key.lua Normal file
View file

@ -0,0 +1,44 @@
local config = require('config')
return {
'folke/which-key.nvim',
config = function()
local wk = require('which-key')
wk.setup({
win = {
border = config.border,
--[[ position = 'bottom', ]]
--[[ margin = { 1, 0, 1, 0 }, ]]
padding = { 3, 2, 3, 2 },
--[[ winblend = 20, ]]
},
layout = {
height = { min = 10, max = 25 },
width = { min = 20, max = 50 },
spacing = 8,
align = 'center',
},
})
wk.add({
{ '<leader>c', group = 'quickfix' },
{ '<leader>f', group = 'find' },
{ '<leader>g', group = 'goto' },
{ '<leader>h', group = 'gitsigns' },
{ '<leader>ht', group = 'toggle' },
{ '<leader>k', group = 'buffer' },
{ '<leader>l', group = 'lsp' },
{ '<leader>ld', group = 'diagnostics' },
{ '<leader>lt', group = 'toggle' },
{ '<leader>lw', group = 'workspace' },
{ '<leader>n', group = 'tree' },
{ '<leader>p', group = 'lazy (plugins)' },
{ '<leader>s', group = 'session' },
{ '<leader>t', group = 'tab' },
{ '<leader>v', group = 'git (vsc)' },
{ '<leader>vt', group = 'toggle' },
{ '<leader>x', group = 'terminal' },
})
end,
event = 'VeryLazy',
enabled = not vim.tbl_contains(config.disable_builtin_plugins, 'which-key'),
}

View file

@ -1,11 +1,10 @@
local u = require('cosmic.utils.cosmic')
local user_config = require('cosmic.core.user')
local config = require('config')
require('lazy').setup('cosmic.plugins', {
lockfile = u.get_install_dir() .. '/lazy-lock.json',
require('lazy').setup('plugins', {
lockfile = vim.fn.stdpath('config') .. '/lazy-lock.json',
defaults = { lazy = true },
ui = {
border = user_config.border,
border = config.border,
size = { width = 0.7, height = 0.7 },
},
performance = {

81
lua/utils/icons.lua Normal file
View file

@ -0,0 +1,81 @@
local icons = {
rounded_left_filled = "",
rounded_right_filled = "",
arrow_left_filled = "", -- e0b2
arrow_right_filled = "", -- e0b0
arrow_left = "", -- e0b3
arrow_right = "", -- e0b1
ghost = "",
rocket = "🚀",
warn = "",
info = "",
error = "",
hint = "󰌵",
perf = "󰄭",
note = "󰎚",
branch = "",
file = "",
dotdotdot = "",
information = "",
symlink = "",
line_number = "",
debug = "",
flame = "",
check = "",
trace = "",
file1 = "",
file2 = "",
clock = "",
word = "",
diff_add = "",
diff_modified = "",
diff_remove = "",
git = {
unstaged = "",
staged = "",
unmerged = "",
renamed = "",
untracked = "",
deleted = "",
ignored = "",
},
folder = {
arrow_open = "",
arrow_closed = "",
default = "",
open = "",
empty = "",
empty_open = "",
symlink = "",
symlink_open = "",
},
kind_icons = {
Text = "",
Method = "m",
Function = "󰊕",
Constructor = "",
Field = "",
Variable = "",
Class = "",
Interface = "",
Module = "",
Property = "",
Unit = "",
Value = "󱨉",
Enum = "",
Keyword = "",
Snippet = "",
Color = "",
File = "",
Reference = "",
Folder = "",
EnumMember = "",
Constant = "",
Struct = "",
Event = "",
Operator = "",
TypeParameter = "󰫧",
},
}
return icons

View file

@ -1,28 +1,8 @@
local user_config = require('cosmic.core.user')
local config = require('config')
local M = {}
M.format_on_save_enabled = true
function M.can_client_format_on_save(client)
local user_server_config = user_config.lsp.servers[client.name]
-- formatting enabled by default if server=true
if user_server_config == true then
return true
end
-- check config server settings
if user_server_config then
-- default to true if no format flag on server settings is set
if user_server_config.format_on_save == nil then
return true
end
-- check format flag on server settings
return user_server_config.format_on_save == true
end
return true
end
function M.toggle_format_on_save()
M.format_on_save_enabled = not M.format_on_save_enabled
vim.notify(string.format('Format on save: %s', M.format_on_save_enabled))
@ -30,7 +10,7 @@ end
function M.buf_format(bufnr, timeout)
if timeout == '' or timeout == nil then
timeout = user_config.lsp.format_timeout
timeout = config.lsp.format_timeout
else
timeout = timeout * 1000
end
@ -71,7 +51,7 @@ function M.buf_get_active_clients_str()
end
function M.toggle_inlay_hints()
local enabled = user_config.lsp.inlay_hint
local enabled = config.lsp.inlay_hint
return function()
enabled = not enabled
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled({