refactor(plugins): improve plugin configurations and add C/C++ formatting
This commit is contained in:
6 files changed
+50
-147
No files matched your search
+13
-8
@@ -2,18 +2,23 @@ return {
|
||||
-- auto pairs
|
||||
{
|
||||
'windwp/nvim-autopairs',
|
||||
enabled = false,
|
||||
event = 'InsertEnter',
|
||||
config = function()
|
||||
local npairs = require('nvim-autopairs')
|
||||
local Rule = require('nvim-autopairs.rule')
|
||||
local conds = require('nvim-autopairs.conds')
|
||||
|
||||
npairs.setup({
|
||||
check_ts = true,
|
||||
enable_check_bracket_line = true,
|
||||
fast_wrap = {},
|
||||
map_cr = true,
|
||||
map_bs = true,
|
||||
})
|
||||
npairs.setup()
|
||||
|
||||
-- Autoclosing angle-brackets.
|
||||
npairs.add_rule(Rule('<', '>', {
|
||||
-- Avoid conflicts with nvim-ts-autotag.
|
||||
'-html',
|
||||
'-javascriptreact',
|
||||
'-typescriptreact',
|
||||
}):with_pair(conds.before_regex('%a+:?:?$', 3)):with_move(function(opts)
|
||||
return opts.char == '>'
|
||||
end))
|
||||
end,
|
||||
},
|
||||
|
||||
|
||||
+7
-38
@@ -27,7 +27,6 @@ return {
|
||||
-- comment
|
||||
{
|
||||
'numToStr/Comment.nvim',
|
||||
version = false,
|
||||
dependencies = {
|
||||
'JoosepAlviste/nvim-ts-context-commentstring',
|
||||
},
|
||||
@@ -41,44 +40,14 @@ return {
|
||||
})
|
||||
end,
|
||||
keys = {
|
||||
{
|
||||
'gcc',
|
||||
mode = 'n',
|
||||
desc = 'Toggle comment line',
|
||||
},
|
||||
{
|
||||
'gc',
|
||||
mode = { 'n', 'o' },
|
||||
desc = 'Toggle comment linewise',
|
||||
},
|
||||
{
|
||||
'gc',
|
||||
mode = 'x',
|
||||
desc = 'Toggle comment linewise (visual)',
|
||||
},
|
||||
{
|
||||
'gbc',
|
||||
mode = 'n',
|
||||
desc = 'Toggle comment block',
|
||||
},
|
||||
{
|
||||
'gb',
|
||||
mode = { 'n', 'o' },
|
||||
desc = 'Toggle comment blockwise',
|
||||
},
|
||||
{
|
||||
'gb',
|
||||
mode = 'x',
|
||||
desc = 'Toggle comment blockwise (visual)',
|
||||
},
|
||||
{ '<leader>/', "<cmd>lua require('Comment.api').toggle.linewise.current()<cr>", desc = 'Toggle comment' },
|
||||
{
|
||||
'<leader>/',
|
||||
"<esc><cmd>lua require('Comment.api').toggle.linewise(vim.fn.visualmode())<cr>",
|
||||
desc = 'Toggle comment',
|
||||
mode = 'v',
|
||||
},
|
||||
{ 'gcc', mode = 'n', desc = 'Toggle comment line' },
|
||||
{ 'gc', mode = { 'n', 'o' }, desc = 'Toggle comment linewise' },
|
||||
{ 'gc', mode = 'x', desc = 'Toggle comment linewise (visual)' },
|
||||
{ 'gbc', mode = 'n', desc = 'Toggle comment block' },
|
||||
{ 'gb', mode = { 'n', 'o' }, desc = 'Toggle comment blockwise' },
|
||||
{ 'gb', mode = 'x', desc = 'Toggle comment blockwise (visual)' },
|
||||
},
|
||||
|
||||
opts = {},
|
||||
},
|
||||
|
||||
|
||||
@@ -27,6 +27,9 @@ return {
|
||||
},
|
||||
formatters_by_ft = {
|
||||
['lua'] = { 'stylua' },
|
||||
['c'] = { 'clang_format' },
|
||||
['cpp'] = { 'clang_format' },
|
||||
['h'] = { 'clang_format' },
|
||||
['python'] = { 'ruff_fix', 'ruff_format', 'ruff_organize_imports' },
|
||||
['javascript'] = { 'biome' },
|
||||
['typescript'] = { 'biome' },
|
||||
@@ -52,9 +55,10 @@ return {
|
||||
vim.b.conform_disable = not vim.b.conform_disable
|
||||
local status = vim.b.conform_disable and 'disabled' or 'enabled'
|
||||
vim.notify('Autoformat ' .. status, vim.log.levels.INFO)
|
||||
end)
|
||||
end, { desc = 'Toggle autoformat' })
|
||||
require('mason-conform').setup({
|
||||
ensure_installed = {
|
||||
'clang_format',
|
||||
'ruff',
|
||||
'stylua',
|
||||
'prettier',
|
||||
|
||||
+9
-10
@@ -19,18 +19,17 @@ return {
|
||||
|
||||
-- surround action
|
||||
require('mini.surround').setup({
|
||||
n_lines = 25,
|
||||
mappings = {
|
||||
add = 'ys', -- Add surrounding in Normal and Visual modes
|
||||
delete = 'ds', -- Delete surrounding
|
||||
find = '', -- Find surrounding (to the right)
|
||||
find_left = '', -- Find surrounding (to the left)
|
||||
highlight = '', -- Highlight surrounding
|
||||
replace = 'cs', -- Replace surrounding
|
||||
update_n_lines = '', -- Update `n_lines`
|
||||
add = 'msa',
|
||||
delete = 'msd',
|
||||
find = 'msf',
|
||||
find_left = 'msF',
|
||||
highlight = 'msh',
|
||||
replace = 'msr',
|
||||
update_n_lines = 'msn',
|
||||
|
||||
suffix_last = 'l', -- Suffix to search with "prev" method
|
||||
suffix_next = 'n', -- Suffix to search with "next" method
|
||||
suffix_last = 'l',
|
||||
suffix_next = 'n',
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
+6
-80
@@ -31,86 +31,12 @@ return {
|
||||
'kevinhwang91/nvim-ufo',
|
||||
event = { 'BufReadPost', 'BufNewFile' },
|
||||
dependencies = { 'kevinhwang91/promise-async', event = 'BufReadPost' },
|
||||
opts = {
|
||||
provider_selector = function()
|
||||
return { 'lsp', 'indent' }
|
||||
end,
|
||||
fold_virt_text_handler = function(virtText, lnum, endLnum, width, truncate)
|
||||
local newVirtText = {}
|
||||
local suffix = (' … %d '):format(endLnum - lnum)
|
||||
local sufWidth = vim.fn.strdisplaywidth(suffix)
|
||||
local targetWidth = width - sufWidth
|
||||
local curWidth = 0
|
||||
for _, chunk in ipairs(virtText) do
|
||||
local chunkText = chunk[1]
|
||||
local chunkWidth = vim.fn.strdisplaywidth(chunkText)
|
||||
if targetWidth > curWidth + chunkWidth then
|
||||
table.insert(newVirtText, chunk)
|
||||
else
|
||||
chunkText = truncate(chunkText, targetWidth - curWidth)
|
||||
local hlGroup = chunk[2]
|
||||
table.insert(newVirtText, { chunkText, hlGroup })
|
||||
chunkWidth = vim.fn.strdisplaywidth(chunkText)
|
||||
-- str width returned from truncate() may less than 2nd argument, need padding
|
||||
if curWidth + chunkWidth < targetWidth then
|
||||
suffix = suffix .. (' '):rep(targetWidth - curWidth - chunkWidth)
|
||||
end
|
||||
break
|
||||
end
|
||||
curWidth = curWidth + chunkWidth
|
||||
end
|
||||
table.insert(newVirtText, { suffix, 'MoreMsg' })
|
||||
return newVirtText
|
||||
end,
|
||||
open_fold_hl_timeout = 0,
|
||||
},
|
||||
keys = {
|
||||
{ 'fd', 'zd', desc = 'Delete fold under cursor' },
|
||||
{ 'fo', 'zo', desc = 'Open fold under cursor' },
|
||||
{ 'fO', 'zO', desc = 'Open all folds under cursor' },
|
||||
{ 'fc', 'zC', desc = 'Close all folds under cursor' },
|
||||
{ 'fa', 'za', desc = 'Toggle fold under cursor' },
|
||||
{ 'fA', 'zA', desc = 'Toggle all folds under cursor' },
|
||||
{ 'fv', 'zv', desc = 'Show cursor line' },
|
||||
{
|
||||
'fM',
|
||||
function()
|
||||
require('ufo').closeAllFolds()
|
||||
config = function()
|
||||
require('ufo').setup({
|
||||
provider_selector = function(bufnr, filetype, buftype)
|
||||
return { 'treesitter', 'indent' }
|
||||
end,
|
||||
desc = 'Close all folds',
|
||||
},
|
||||
{
|
||||
'fR',
|
||||
function()
|
||||
require('ufo').openAllFolds()
|
||||
end,
|
||||
desc = 'Open all folds',
|
||||
},
|
||||
{
|
||||
'fm',
|
||||
function()
|
||||
require('ufo').closeFoldsWith()
|
||||
end,
|
||||
desc = 'Fold more',
|
||||
},
|
||||
{
|
||||
'fr',
|
||||
function()
|
||||
require('ufo').openFoldsExceptKinds()
|
||||
end,
|
||||
desc = 'Fold less',
|
||||
},
|
||||
{ 'fx', 'zx', desc = 'Update folds' },
|
||||
{ 'fz', 'zz', desc = 'Center this line' },
|
||||
{ 'ft', 'zt', desc = 'Top this line' },
|
||||
{ 'fb', 'zb', desc = 'Bottom this line' },
|
||||
{ 'fg', 'zg', desc = 'Add word to spell list' },
|
||||
{ 'fw', 'zw', desc = 'Mark word as bad/misspelling' },
|
||||
{ 'fe', 'ze', desc = 'Right this line' },
|
||||
{ 'fE', 'zE', desc = 'Delete all folds in current buffer' },
|
||||
{ 'fs', 'zs', desc = 'Left this line' },
|
||||
{ 'fH', 'zH', desc = 'Half screen to the left' },
|
||||
{ 'fL', 'zL', desc = 'Half screen to the right' },
|
||||
},
|
||||
})
|
||||
end,
|
||||
},
|
||||
}
|
||||
+10
-10
@@ -83,7 +83,7 @@ return {
|
||||
shell = vim.o.shell,
|
||||
float_opts = {
|
||||
border = 'curved', -- 'single', 'double', 'shadow', etc.
|
||||
winblend = 0, -- Set to 0 for full transparency
|
||||
winblend = 0, -- Set to 0 for full transparency
|
||||
highlights = {
|
||||
border = 'Normal',
|
||||
background = 'Normal',
|
||||
@@ -114,16 +114,16 @@ return {
|
||||
picker_integration = true,
|
||||
keymaps = {
|
||||
prefix = '<leader>u', -- Main prefix for uv commands
|
||||
commands = true, -- Show uv commands menu (<leader>x)
|
||||
run_file = true, -- Run current file (<leader>xr)
|
||||
commands = true, -- Show uv commands menu (<leader>x)
|
||||
run_file = true, -- Run current file (<leader>xr)
|
||||
run_selection = true, -- Run selected code (<leader>xs)
|
||||
run_function = true, -- Run function (<leader>xf)
|
||||
venv = true, -- Environment management (<leader>xe)
|
||||
init = true, -- Initialize uv project (<leader>xi)
|
||||
add = true, -- Add a package (<leader>xa)
|
||||
remove = true, -- Remove a package (<leader>xd)
|
||||
sync = true, -- Sync packages (<leader>xc)
|
||||
sync_all = true, -- Sync all packages, extras and groups (<leader>xC)
|
||||
run_function = true, -- Run function (<leader>xf)
|
||||
venv = true, -- Environment management (<leader>xe)
|
||||
init = true, -- Initialize uv project (<leader>xi)
|
||||
add = true, -- Add a package (<leader>xa)
|
||||
remove = true, -- Remove a package (<leader>xd)
|
||||
sync = true, -- Sync packages (<leader>xc)
|
||||
sync_all = true, -- Sync all packages, extras and groups (<leader>xC)
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user