mirror of
https://github.com/darwincereska/nvim-config.git
synced 2026-02-12 03:04:43 -05:00
working condition
This commit is contained in:
@@ -1,80 +1,79 @@
|
||||
return {
|
||||
'windwp/nvim-autopairs',
|
||||
event = "InsertEnter",
|
||||
dependencies = { 'nvim-treesitter/nvim-treesitter' },
|
||||
config = function()
|
||||
local npairs = require('nvim-autopairs')
|
||||
local Rule = require('nvim-autopairs.rule')
|
||||
local cond = require('nvim-autopairs.conds')
|
||||
|
||||
npairs.setup({
|
||||
check_ts = true, -- Enable treesitter integration
|
||||
ts_config = {
|
||||
lua = {'string', 'source'},
|
||||
kotlin = {'string', 'comment'},
|
||||
java = {'string', 'comment'},
|
||||
},
|
||||
disable_filetype = { "TelescopePrompt", "spectre_panel" },
|
||||
disable_in_macro = false,
|
||||
disable_in_visualblock = false,
|
||||
disable_in_replace_mode = true,
|
||||
ignored_next_char = [=[[%w%%%'%[%"%.%`%$]]=],
|
||||
enable_moveright = true,
|
||||
enable_afterquote = true,
|
||||
enable_check_bracket_line = false,
|
||||
enable_bracket_in_quote = true,
|
||||
enable_abbr = false,
|
||||
break_undo = true,
|
||||
map_cr = true,
|
||||
map_bs = true,
|
||||
map_c_h = false,
|
||||
map_c_w = false,
|
||||
|
||||
-- Fast wrap feature - press Alt+e to wrap selection
|
||||
fast_wrap = {
|
||||
map = '<M-e>',
|
||||
chars = { '{', '[', '(', '"', "'" },
|
||||
pattern = [=[[%'%"%>%]%)%}%,]]=],
|
||||
offset = 0,
|
||||
end_key = '$',
|
||||
keys = 'qwertyuiopzxcvbnmasdfghjkl',
|
||||
check_comma = true,
|
||||
highlight = 'PmenuSel',
|
||||
highlight_grey = 'LineNr'
|
||||
},
|
||||
})
|
||||
'windwp/nvim-autopairs',
|
||||
event = "InsertEnter",
|
||||
dependencies = { 'nvim-treesitter/nvim-treesitter' },
|
||||
config = function()
|
||||
local npairs = require('nvim-autopairs')
|
||||
local Rule = require('nvim-autopairs.rule')
|
||||
local cond = require('nvim-autopairs.conds')
|
||||
|
||||
-- Custom rules for better Kotlin support
|
||||
npairs.add_rules({
|
||||
-- Add spaces inside brackets for function calls
|
||||
Rule(' ', ' ')
|
||||
:with_pair(function(opts)
|
||||
local pair = opts.line:sub(opts.col - 1, opts.col)
|
||||
return vim.tbl_contains({ '()', '[]', '{}' }, pair)
|
||||
end),
|
||||
|
||||
-- Don't pair quotes after backslash
|
||||
Rule('"', '"', 'kotlin')
|
||||
:with_pair(cond.not_before_regex('\\', 1)),
|
||||
|
||||
-- Smart pairing for lambda expressions
|
||||
Rule('{', '}', 'kotlin')
|
||||
:with_pair(function(opts)
|
||||
-- Don't autopair if we're after forEach, let, etc.
|
||||
local line = opts.line:sub(1, opts.col - 1)
|
||||
if line:match('forEach%s*$') or line:match('let%s*$') or line:match('run%s*$') then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end),
|
||||
})
|
||||
npairs.setup({
|
||||
check_ts = true, -- Enable treesitter integration
|
||||
ts_config = {
|
||||
lua = {'string', 'source'},
|
||||
kotlin = {'string', 'comment'},
|
||||
java = {'string', 'comment'},
|
||||
},
|
||||
disable_filetype = { "TelescopePrompt", "spectre_panel" },
|
||||
disable_in_macro = false,
|
||||
disable_in_visualblock = false,
|
||||
disable_in_replace_mode = true,
|
||||
ignored_next_char = [=[[%w%%%'%[%"%.%`%$]]=],
|
||||
enable_moveright = true,
|
||||
enable_afterquote = true,
|
||||
enable_check_bracket_line = false,
|
||||
enable_bracket_in_quote = true,
|
||||
enable_abbr = false,
|
||||
break_undo = true,
|
||||
map_cr = true,
|
||||
map_bs = true,
|
||||
map_c_h = false,
|
||||
map_c_w = false,
|
||||
|
||||
-- Integration with nvim-cmp if you have it
|
||||
local cmp_status_ok, cmp = pcall(require, "cmp")
|
||||
if cmp_status_ok then
|
||||
local cmp_autopairs = require('nvim-autopairs.completion.cmp')
|
||||
cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done())
|
||||
-- Fast wrap feature - press Alt+e to wrap selection
|
||||
fast_wrap = {
|
||||
map = '<M-e>', -- or whatever key you prefer
|
||||
chars = { '{', '[', '(', '"', "'", '*' }, -- Added * here
|
||||
pattern = [=[[%'%"%)%>%]%)%}%,]]=],
|
||||
end_key = '$',
|
||||
keys = 'qwertyuiopzxcvbnmasdfghjkl',
|
||||
check_comma = true,
|
||||
highlight = 'Search',
|
||||
highlight_grey = 'Comment'
|
||||
},
|
||||
})
|
||||
|
||||
-- Custom rules for better Kotlin support
|
||||
npairs.add_rules({
|
||||
-- Add spaces inside brackets for function calls
|
||||
Rule(' ', ' ')
|
||||
:with_pair(function(opts)
|
||||
local pair = opts.line:sub(opts.col - 1, opts.col)
|
||||
return vim.tbl_contains({ '()', '[]', '{}' }, pair)
|
||||
end),
|
||||
|
||||
-- Don't pair quotes after backslash
|
||||
Rule('"', '"', 'kotlin')
|
||||
:with_pair(cond.not_before_regex('\\', 1)),
|
||||
|
||||
-- Smart pairing for lambda expressions
|
||||
Rule('{', '}', 'kotlin')
|
||||
:with_pair(function(opts)
|
||||
-- Don't autopair if we're after forEach, let, etc.
|
||||
local line = opts.line:sub(1, opts.col - 1)
|
||||
if line:match('forEach%s*$') or line:match('let%s*$') or line:match('run%s*$') then
|
||||
return false
|
||||
end
|
||||
return true
|
||||
end),
|
||||
})
|
||||
|
||||
-- Integration with nvim-cmp if you have it
|
||||
local cmp_status_ok, cmp = pcall(require, "cmp")
|
||||
if cmp_status_ok then
|
||||
local cmp_autopairs = require('nvim-autopairs.completion.cmp')
|
||||
cmp.event:on('confirm_done', cmp_autopairs.on_confirm_done())
|
||||
end
|
||||
end
|
||||
end
|
||||
}
|
||||
|
||||
|
||||
@@ -16,16 +16,30 @@ return {
|
||||
local cmp = require("cmp")
|
||||
local luasnip = require("luasnip")
|
||||
|
||||
-- Load VSCode-style snippets
|
||||
require("luasnip.loaders.from_vscode").lazy_load()
|
||||
|
||||
-- Highlighting for completion windows
|
||||
vim.api.nvim_set_hl(0, "CmpBorder", { link = "FloatBorder" })
|
||||
vim.api.nvim_set_hl(0, "CmpDocBorder", { link = "FloatBorder" })
|
||||
vim.api.nvim_set_hl(0, "CmpDocNormal", { link = "NormalFloat" })
|
||||
|
||||
local snippets_enabled = true
|
||||
|
||||
-- Toggle function for snippets
|
||||
function toggle_snippets()
|
||||
snippets_enabled = not snippets_enabled
|
||||
end
|
||||
|
||||
-- Key mapping to toggle snippets
|
||||
vim.api.nvim_set_keymap('n', '<Leader>ts', ':lua toggle_snippets()<CR>', { noremap = true, silent = true })
|
||||
|
||||
cmp.setup({
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
luasnip.lsp_expand(args.body)
|
||||
if snippets_enabled then
|
||||
luasnip.lsp_expand(args.body)
|
||||
end
|
||||
end,
|
||||
},
|
||||
|
||||
@@ -39,7 +53,7 @@ return {
|
||||
["<Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif luasnip.expand_or_jumpable() then
|
||||
elseif snippets_enabled and luasnip.expand_or_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
else
|
||||
fallback()
|
||||
@@ -49,7 +63,7 @@ return {
|
||||
["<S-Tab>"] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip.jumpable(-1) then
|
||||
elseif snippets_enabled and luasnip.jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
@@ -60,7 +74,7 @@ return {
|
||||
sources = cmp.config.sources({
|
||||
{ name = "nvim_lsp" },
|
||||
{ name = "luasnip" },
|
||||
{ name = "buffer" },
|
||||
{ name = "buffer", keyword_length = 3 },
|
||||
{ name = "path" },
|
||||
{ name = "spell" },
|
||||
}),
|
||||
@@ -113,3 +127,4 @@ return {
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
16
lua/plugins/surround.lua
Normal file
16
lua/plugins/surround.lua
Normal file
@@ -0,0 +1,16 @@
|
||||
return {
|
||||
"kylechui/nvim-surround",
|
||||
version = "*",
|
||||
event = "VeryLazy",
|
||||
config = function()
|
||||
require("nvim-surround").setup({
|
||||
surrounds = {
|
||||
["*"] = { -- 'b' for bold
|
||||
add = { "**", "**" },
|
||||
find = "%*%*.-%*%*",
|
||||
delete = "^(%*%*)().-(%*%*)()$",
|
||||
},
|
||||
}
|
||||
})
|
||||
end
|
||||
}
|
||||
Reference in New Issue
Block a user