-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: extract related configs into coding
- Loading branch information
Showing
8 changed files
with
198 additions
and
184 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}, | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.