Skip to content

Commit

Permalink
refactor: extract related configs into coding
Browse files Browse the repository at this point in the history
  • Loading branch information
BBboy01 committed Dec 1, 2023
1 parent 38bc5a6 commit 860ff6d
Show file tree
Hide file tree
Showing 8 changed files with 198 additions and 184 deletions.
18 changes: 9 additions & 9 deletions lazy-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,30 +13,30 @@
"gitsigns.nvim": { "branch": "main", "commit": "6ef8c54fb526bf3a0bc4efb0b2fe8e6d9a7daed2" },
"indentmini.nvim": { "branch": "main", "commit": "a58129ae424fd6d8e0e2e7f6ce06c0443101e370" },
"lazy.nvim": { "branch": "main", "commit": "96584866b9c5e998cbae300594d0ccfd0c464627" },
"lspsaga.nvim": { "branch": "main", "commit": "d3dfaea0125315110ea720c337ab88aa451d75e7" },
"lspsaga.nvim": { "branch": "main", "commit": "e9f08958e5f8410cadaa6388844788aedec5f78a" },
"lualine.nvim": { "branch": "master", "commit": "2248ef254d0a1488a72041cfb45ca9caada6d994" },
"mini.ai": { "branch": "main", "commit": "4a2e387b121352dfb478f440c9a5313a9d97006c" },
"mini.comment": { "branch": "main", "commit": "3d9c8009615857e982f09bc5357fc95f2a2175f3" },
"mini.pairs": { "branch": "main", "commit": "71f117fd57f930da6ef4126b24f594dd398bac26" },
"mini.surround": { "branch": "main", "commit": "af8129efcabe95fc08a233e9f91569829bed031f" },
"neodev.nvim": { "branch": "main", "commit": "eab4a55c43e0dec631acec992e52490b3f1b5a17" },
"neodev.nvim": { "branch": "main", "commit": "1676d2c24186fc30005317e0306d20c639b2351b" },
"neogen": { "branch": "main", "commit": "70127baaff25611deaf1a29d801fc054ad9d2dc1" },
"noice.nvim": { "branch": "main", "commit": "92433164e2f7118d4122c7674c3834d9511722ba" },
"none-ls.nvim": { "branch": "main", "commit": "3a4826687da4310af379515086d71faca4d21288" },
"none-ls.nvim": { "branch": "main", "commit": "de6865527bdd66f78738737e574796ccf138d19b" },
"nui.nvim": { "branch": "main", "commit": "257dccc43b4badc735978f0791d216f7d665b75a" },
"nvim-cmp": { "branch": "main", "commit": "0b751f6beef40fd47375eaf53d3057e0bfa317e4" },
"nvim-lspconfig": { "branch": "master", "commit": "39546f730bdff8eccf7cec344cfce694f19ac908" },
"nvim-lspconfig": { "branch": "master", "commit": "694aaec65733e2d54d393abf80e526f86726c988" },
"nvim-tree.lua": { "branch": "master", "commit": "086bf310bd19a7103ee7d761eb59f89f3dd23e21" },
"nvim-treesitter": { "branch": "master", "commit": "e9acd01a4a1f6e584f76e736987f4c31401aa4b1" },
"nvim-treesitter-textobjects": { "branch": "master", "commit": "c71406807b545f4a2c17310197a8c88b976f338d" },
"nvim-treesitter": { "branch": "master", "commit": "b41bbcbb9a2c5543d3bfa4cf7e2b0948a5f61ce6" },
"nvim-treesitter-textobjects": { "branch": "master", "commit": "aa7935c60aff501580b7f4872a7082e615ea5be3" },
"nvim-ts-autotag": { "branch": "main", "commit": "6be1192965df35f94b8ea6d323354f7dc7a557e4" },
"nvim-ts-context-commentstring": { "branch": "main", "commit": "b8ff464f2afc2000f6c72fa331a8fc090cb46b39" },
"nvim-ts-context-commentstring": { "branch": "main", "commit": "1277b4a1f451b0f18c0790e1a7f12e1e5fdebfee" },
"nvim-ts-rainbow": { "branch": "master", "commit": "ef95c15a935f97c65a80e48e12fe72d49aacf9b9" },
"nvim-web-devicons": { "branch": "master", "commit": "5efb8bd06841f91f97c90e16de85e96d57e9c862" },
"persistence.nvim": { "branch": "main", "commit": "ad538bfd5336f1335cdb6fd4e0b0eebfa6e12f32" },
"playground": { "branch": "master", "commit": "ba48c6a62a280eefb7c85725b0915e021a1a0749" },
"plenary.nvim": { "branch": "master", "commit": "366b0837486f60ae0e7550c15de8ff66d057c4cd" },
"schemastore.nvim": { "branch": "main", "commit": "54a4ea14b70cd3fc9db8217bb4ac9e1f78bfa390" },
"plenary.nvim": { "branch": "master", "commit": "55d9fe89e33efd26f532ef20223e5f9430c8b0c0" },
"schemastore.nvim": { "branch": "main", "commit": "5bfeb36550018438c2c7ef58f91174f79d99a28a" },
"solarized-osaka.nvim": { "branch": "main", "commit": "a823d09b062852194ae15365392bc16274e38fc8" },
"telescope-file-browser.nvim": { "branch": "master", "commit": "d7c453396a043c265bef1227920628e7b811ff30" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "6c921ca12321edaa773e324ef64ea301a1d0da62" },
Expand Down
19 changes: 0 additions & 19 deletions lua/plugins/ai.lua

This file was deleted.

5 changes: 0 additions & 5 deletions lua/plugins/autopairs.lua

This file was deleted.

78 changes: 0 additions & 78 deletions lua/plugins/cmp.lua

This file was deleted.

189 changes: 189 additions & 0 deletions lua/plugins/coding.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
return {
{
'L3MON4D3/LuaSnip',
build = (not jit.os:find('Windows'))
and "echo 'NOTE: jsregexp is optional, so not a big deal if it fails to build'; make install_jsregexp"
or nil,
dependencies = {
'rafamadriz/friendly-snippets',
config = function()
require('luasnip.loaders.from_vscode').lazy_load()
end,
},
opts = {
history = true,
delete_check_events = 'TextChanged',
},
-- stylua: ignore
-- keys = {
-- {
-- "<tab>",
-- function()
-- return require("luasnip").jumpable(1) and "<Plug>luasnip-jump-next" or "<tab>"
-- end,
-- expr = true,
-- silent = true,
-- mode = "i",
-- },
-- { "<tab>", function() require("luasnip").jump(1) end, mode = "s" },
-- { "<s-tab>", function() require("luasnip").jump(-1) end, mode = { "i", "s" } },
-- },
},

-- auto pairs
{
'echasnovski/mini.pairs',
event = 'VeryLazy',
opts = {},
},

-- Fast and feature-rich surround actions. For text that includes
-- surrounding characters like brackets or quotes, this allows you
-- to select the text inside, change or modify the surrounding characters,
-- and more.
{
'echasnovski/mini.surround',
keys = function(_, keys)
-- Populate the keys based on the user's options
local plugin = require('lazy.core.config').spec.plugins['mini.surround']
local opts = require('lazy.core.plugin').values(plugin, 'opts', false)
local mappings = {
{ opts.mappings.add, desc = 'Add surrounding', mode = { 'n', 'v' } },
{ opts.mappings.delete, desc = 'Delete surrounding' },
{ opts.mappings.find, desc = 'Find right surrounding' },
{ opts.mappings.find_left, desc = 'Find left surrounding' },
{ opts.mappings.highlight, desc = 'Highlight surrounding' },
{ opts.mappings.replace, desc = 'Replace surrounding' },
{ opts.mappings.update_n_lines, desc = 'Update `MiniSurround.config.n_lines`' },
}
mappings = vim.tbl_filter(function(m)
return m[1] and #m[1] > 0
end, mappings)
return vim.list_extend(mappings, keys)
end,
opts = {
mappings = {
add = 'gsa', -- Add surrounding in Normal and Visual modes
delete = 'gsd', -- Delete surrounding
find = 'gsf', -- Find surrounding (to the right)
find_left = 'gsF', -- Find surrounding (to the left)
highlight = 'gsh', -- Highlight surrounding
replace = 'gsr', -- Replace surrounding
update_n_lines = 'gsn', -- Update `n_lines`
},
},
},

-- comments
{
'echasnovski/mini.comment',
event = 'VeryLazy',
opts = {
options = {
custom_commentstring = function()
return require('ts_context_commentstring.internal').calculate_commentstring() or vim.bo.commentstring
end,
},
},
},

-- ai
{
'echasnovski/mini.ai',
event = 'VeryLazy',
opts = function()
local ai = require('mini.ai')
return {
n_lines = 500,
custom_textobjects = {
o = ai.gen_spec.treesitter({
a = { '@block.outer', '@conditional.outer', '@loop.outer' },
i = { '@block.inner', '@conditional.inner', '@loop.inner' },
}, {}),
f = ai.gen_spec.treesitter({ a = '@function.outer', i = '@function.inner' }, {}),
c = ai.gen_spec.treesitter({ a = '@class.outer', i = '@class.inner' }, {}),
t = { '<([%p%w]-)%f[^<%w][^<>]->.-</%1>', '^<.->().*()</[^/]->$' },
},
}
end,
},

{
'hrsh7th/nvim-cmp',
version = false,
event = 'InsertEnter',
dependencies = {
'hrsh7th/cmp-cmdline',
'hrsh7th/cmp-nvim-lsp',
'hrsh7th/cmp-path',
'hrsh7th/cmp-buffer',
'saadparwaiz1/cmp_luasnip',
},
opts = function()
vim.api.nvim_set_hl(0, 'CmpGhostText', { link = 'Comment', default = true })
local cmp = require('cmp')
local defaults = require('cmp.config.default')()
return {
completion = {
completeopt = 'menu,menuone,noinsert',
},
snippet = {
expand = function(args)
require('luasnip').lsp_expand(args.body)
end,
},
window = {
completion = cmp.config.window.bordered(),
documentation = cmp.config.window.bordered(),
},
mapping = cmp.mapping.preset.insert({
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-q>'] = cmp.mapping.close(),
['<Tab>'] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Insert,
select = true,
}),
}),
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'luasnip' },
{ name = 'path' },
}, {
{ name = 'buffer', keyword_length = 3 },
}),
formatting = {
format = function(_, item)
local icons = require('config').icons.kinds
if icons[item.kind] then
item.kind = icons[item.kind] .. item.kind
end
return item
end,
},
experimental = {
ghost_text = {
hl_group = 'CmpGhostText',
},
},
sorting = defaults.sorting,
}
end,
---@param opts cmp.ConfigSchema
config = function(_, opts)
local cmp = require('cmp')
for _, source in ipairs(opts.sources) do
source.group_index = source.group_index or 1
end
cmp.setup(opts)
cmp.setup.cmdline(':', {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{ name = 'path' },
}, {
{ name = 'cmdline' },
}),
})
end,
},
}
11 changes: 0 additions & 11 deletions lua/plugins/comment.lua

This file was deleted.

30 changes: 0 additions & 30 deletions lua/plugins/luasnip.lua

This file was deleted.

Loading

0 comments on commit 860ff6d

Please sign in to comment.