new structure

This commit is contained in:
00xJ4CK committed 2024-12-31 02:19:32 +05:45
1 parent d3f06cbee8
commit 2a0e6f86c6
72 files changed
+2659 -2947

No files matched your search

+35
View File
@@ -0,0 +1,35 @@
local ai = require('mini.ai')
ai.setup({
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>', '^<.->().*()</[^/]->$' },
},
mappings = {
-- Main textobject prefixes
around = 'a',
inside = 'i',
-- Next/last variants
around_next = 'an',
inside_next = 'in',
around_last = 'al',
inside_last = 'il',
-- Move cursor to corresponding edge of `a` textobject
goto_left = 'g[',
goto_right = 'g]',
},
-- How to search for object
-- 'cover', 'cover_or_next', 'cover_or_prev','cover_or_nearest', 'next', 'previous', 'nearest'.
search_method = 'cover_or_next',
n_lines = 500,
silent = false,
})
+22
View File
@@ -0,0 +1,22 @@
local npairs = require('nvim-autopairs')
npairs.setup({
check_ts = true,
ts_config = {
lua = { 'string', 'source' },
javascript = { 'string', 'template_string' },
java = false,
},
disable_filetype = { 'TelescopePrompt', 'spectre_panel' },
fast_wrap = {
map = '<M-s>',
chars = { '{', '[', '(', '"', "'" },
pattern = string.gsub([[ [%'%"%)%>%]%)%}%,] ]], '%s+', ''),
offset = 0,
end_key = '$',
keys = 'qwertyuiopzxcvbnmasdfghjkl',
check_comma = true,
highlight = 'PmenuSel',
highlight_grey = 'LineNr',
},
})
+51
View File
@@ -0,0 +1,51 @@
local blink = require('blink.cmp')
local icons = require('lib.icons')
blink.setup({
-- 'default', 'super-tab', 'enter'
keymap = {
preset = 'enter',
['<Tab>'] = { 'select_next', 'snippet_forward', 'fallback' },
['<S-Tab>'] = { 'select_prev', 'snippet_backward', 'fallback' },
},
-- 'preselect', 'manual', 'auto_insert'
completion = {
list = { selection = 'auto_insert' },
menu = { border = 'rounded' },
documentation = { window = { border = 'rounded' } },
},
signature = { window = { border = 'rounded' } },
appearance = {
-- Sets the fallback highlight groups to nvim-cmp's highlight groups
use_nvim_cmp_as_default = true,
-- Set to 'mono' for 'Nerd Font Mono' or 'normal' for 'Nerd Font'
nerd_font_variant = 'normal',
kind_icons = icons.kind,
},
sources = {
default = { 'lazydev', 'lsp', 'path', 'snippets', 'buffer', 'copilot' },
providers = {
copilot = {
name = 'copilot',
module = 'blink-cmp-copilot',
score_offset = 90,
async = true,
transform_items = function(_, items)
local CompletionItemKind = require('blink.cmp.types').CompletionItemKind
local kind_idx = #CompletionItemKind + 1
CompletionItemKind[kind_idx] = 'Copilot'
for _, item in ipairs(items) do
item.kind = kind_idx
end
return items
end,
},
lazydev = {
name = 'LazyDev',
module = 'lazydev.integrations.blink',
-- make lazydev completions top priority (see `:h blink.cmp`)
score_offset = 100,
},
},
},
})
+92
View File
@@ -0,0 +1,92 @@
local chat = require('CopilotChat')
local icons = require('lib.icons')
chat.setup({
debug = false, -- Enable debug logging
proxy = nil, -- [protocol://]host[:port] Use this proxy
allow_insecure = false, -- Allow insecure server connections
model = 'gpt-4o', -- model to use, :CopilotChatModels for available models
agent = 'copilot', -- Default agent to use, see ':CopilotChatAgents' for available agents (can be specified manually in prompt via @).
context = 'buffers', -- Default context to use, 'buffers', 'buffer' or none (can be specified manually in prompt via @).
temperature = 0.1, -- temperature
question_header = '# ' .. icons.ui.User .. 'User', -- Header to use for user questions
answer_header = '# ' .. icons.ui.Copilot .. 'Copilot', -- Header to use for AI answers
error_header = '## ' .. icons.ui.CopilotError .. 'Error', -- Header to use for errors
separator = ' ', -- Separator to use in chat
show_folds = true, -- Shows folds for sections in chat
show_help = true, -- Shows help message as virtual lines when waiting for user input
auto_follow_cursor = false, -- Auto-follow cursor in chat
auto_insert_mode = false, -- Automatically enter insert mode when opening window and if auto follow cursor is enabled on new prompt
clear_chat_on_new_prompt = false, -- Clears chat on every new prompt
highlight_selection = true, -- Highlight selection in the source buffer when in the chat window
chat_autocomplete = true, -- Enable chat autocompletion (when disabled, requires manual `mappings.complete` trigger)
history_path = vim.fn.stdpath('data') .. '/copilot_chat_history', -- Default path to stored history
callback = nil, -- Callback to use when ask response is received
-- default window options
window = {
layout = 'vertical', -- 'vertical', 'horizontal', 'float', 'replace'
width = 0.45, -- fractional width of parent, or absolute width in columns when > 1
height = 0.4, -- fractional height of parent, or absolute height in rows when > 1
-- Options below only apply to floating windows
relative = 'editor', -- 'editor', 'win', 'cursor', 'mouse'
border = 'rounded', -- 'none', single', 'double', 'rounded', 'solid', 'shadow'
row = nil, -- row position of the window, default is centered
col = nil, -- column position of the window, default is centered
title = icons.ui.Copilot .. ' Copilot Chat', -- title of chat window
footer = nil, -- footer of chat window
zindex = 1, -- determines if window is on top or below other floating windows
},
-- default mappings
mappings = {
complete = {
insert = '<Tab>',
},
close = {
normal = 'q',
insert = '<C-c>',
},
reset = {
normal = '<C-r>',
insert = '<C-r>',
},
submit_prompt = {
normal = '<CR>',
insert = '<C-s>',
},
toggle_sticky = {
detail = 'Makes line under cursor sticky or deletes sticky line.',
normal = 'gr',
},
accept_diff = {
normal = '<C-y>',
insert = '<C-y>',
},
jump_to_diff = {
normal = 'gj',
},
quickfix_diffs = {
normal = 'gq',
},
yank_diff = {
normal = 'gy',
register = '"',
},
show_diff = {
normal = 'gd',
},
show_info = {
normal = 'gi',
},
show_context = {
normal = 'gc',
},
show_help = {
normal = 'gh',
},
},
})
+45
View File
@@ -0,0 +1,45 @@
local copilot = require('copilot')
copilot.setup({
panel = {
enabled = true,
auto_refresh = false,
keymap = {
jump_prev = '[[',
jump_next = ']]',
accept = '<CR>',
refresh = 'gr',
open = '<M-CR>',
},
layout = {
position = 'bottom',
ratio = 0.4,
},
},
suggestion = {
enabled = true,
auto_trigger = false,
debounce = 75,
keymap = {
accept = '<M-l>',
accept_word = false,
accept_line = false,
next = '<M-]>',
prev = '<M-[>',
dismiss = '<C-]>',
},
},
filetypes = {
yaml = true,
markdown = true,
help = true,
gitcommit = true,
gitrebase = true,
hgcommit = true,
svn = true,
cvs = true,
['.'] = true,
},
copilot_node_command = 'node', -- Node.js version must be > 16.x
server_opts_overrides = {},
})
+107
View File
@@ -0,0 +1,107 @@
local dap = require('dap')
local dapui = require('dapui')
local icons = require('lib.icons')
dapui.setup({
icons = { expanded = icons.ui.ArrowClosed, collapsed = icons.ui.ArrowOpen },
mappings = {
expand = { '<CR>', '<2-LeftMouse>' },
open = 'o',
remove = 'd',
edit = 'e',
repl = 'r',
toggle = 't',
},
expand_lines = vim.fn.has('nvim-0.7'),
layouts = {
{
elements = {
{ id = 'scopes', size = 0.25 },
'breakpoints',
'stacks',
'watches',
},
size = 40,
position = 'right',
},
{
elements = {
'repl',
'console',
},
size = 0.25,
position = 'bottom',
},
},
floating = {
max_height = nil,
max_width = nil,
border = 'rounded',
mappings = {
close = { 'q', '<Esc>' },
},
},
windows = { indent = 1 },
render = {
max_type_length = nil,
},
})
vim.fn.sign_define('DapBreakpoint', { text = icons.ui.Bug, texthl = 'DiagnosticSignError', linehl = '', numhl = '' })
dap.listeners.after.event_initialized['dapui_config'] = function()
dapui.open()
end
dap.listeners.before.event_terminated['dapui_config'] = function()
dapui.close()
end
dap.listeners.before.event_exited['dapui_config'] = function()
dapui.close()
end
dap.adapters.python = {
type = 'executable',
command = '/usr/bin/python',
args = { '-m', 'debugpy.adapter' },
}
dap.configurations.python = {
{
type = 'python',
request = 'launch',
name = 'Launch file',
program = '${file}',
pythonPath = function()
local cwd = vim.fn.getcwd()
if vim.fn.executable(cwd .. '/venv/bin/python') == 1 then
return cwd .. '/venv/bin/python'
elseif vim.fn.executable(cwd .. '/.venv/bin/python') == 1 then
return cwd .. '/.venv/bin/python'
else
return '/usr/bin/python'
end
end,
},
}
dap.adapters.ruby = {
type = 'executable',
command = 'bundle',
args = { 'exec', 'readapt', 'stdio' },
}
dap.configurations.ruby = {
{
type = 'ruby',
request = 'launch',
name = 'Rails',
program = 'bundle',
programArgs = { 'exec', 'rails', 's' },
useBundler = true,
},
}
vim.api.nvim_create_user_command('DapUIToggle', function()
require('dapui').toggle()
end, {})
+48
View File
@@ -0,0 +1,48 @@
local lspconfig = require('lspconfig')
local icons = require('lib.icons').diagnostics
local auto_install = require('lib.util').get_user_config('auto_install', true)
local installed_servers = {}
if auto_install then
installed_servers = require('plugins.list').lsp_servers
end
local default_setup = function(server)
lspconfig[server].setup({
capabilities =
require('blink.cmp').get_lsp_capabilities()
})
end
local signs = { Error = icons.Error, Warn = icons.Warning, Hint = icons.Hint, Info = icons.Information }
for type, icon in pairs(signs) do
local hl = 'DiagnosticSign' .. type
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = '' })
end
require('mason-lspconfig').setup({
ensure_installed = installed_servers,
handlers = {
default_setup,
lua_ls = function()
lspconfig.lua_ls.setup({
capabilities = lsp_capabilities,
settings = {
Lua = {
runtime = { version = 'LuaJIT' },
diagnostics = { globals = { 'vim' } },
workspace = { library = { vim.env.VIMRUNTIME } },
format = {
enable = true,
defaultConfig = {
align_continuous_assign_statement = false,
align_continuous_rect_table_field = false,
align_array_table = false,
},
},
},
},
})
end,
},
})
+21
View File
@@ -0,0 +1,21 @@
local lspsaga = require('lspsaga')
local icons = require('lib.icons')
lspsaga.setup({
ui = {
theme = 'round',
border = 'rounded',
devicon = true,
title = true,
winblend = 1,
expand = icons.ui.ArrowOpen,
collapse = icons.ui.ArrowClosed,
preview = icons.ui.List,
code_action = icons.diagnostics.Hint,
diagnostic = icons.ui.Bug,
incoming = icons.ui.Incoming,
outgoing = icons.ui.Outgoing,
hover = icons.ui.Comment,
},
})
+35
View File
@@ -0,0 +1,35 @@
local mason = require('mason')
local icons = require('lib.icons')
mason.setup({
-- - "prepend": Use mason binary, "append": Use system binary
PATH = 'append',
log_level = vim.log.levels.INFO,
max_concurrent_installers = 8,
ui = {
check_outdated_packages_on_open = true,
border = 'rounded',
width = 0.8,
height = 0.8,
icons = {
package_installed = icons.ui.Gear,
package_pending = icons.ui.Download,
package_uninstalled = icons.ui.Plus,
},
keymaps = {
toggle_package_expand = '<CR>',
install_package = 'i',
update_package = 'u',
check_package_version = 'c',
update_all_packages = 'U',
check_outdated_packages = 'C',
uninstall_package = 'x',
cancel_installation = '<C-c>',
apply_language_filter = '<C-f>',
},
},
})
+20
View File
@@ -0,0 +1,20 @@
local neotest = require('neotest')
neotest.setup({
adapters = {
require('neotest-rspec')({
rspec_cmd = function()
return vim.tbl_flatten({
'bundle',
'exec',
'rspec',
})
end,
}),
require('neotest-jest')({
jestCommand = 'npx jest --',
jestConfigFile = 'jest.config.js',
}),
require('neotest-python'),
},
})
+51
View File
@@ -0,0 +1,51 @@
local null_ls = require('null-ls')
local action = null_ls.builtins.code_actions
local comp = null_ls.builtins.completion
local diag = null_ls.builtins.diagnostics
local format = null_ls.builtins.formatting
local hover = null_ls.builtins.hover
-- Buily in sources: https://github.com/nvimtools/none-ls.nvim/blob/main/doc/BUILTINS.md
null_ls.setup({
debug = false,
border = 'rounded',
log_level = 'info',
diagnostics_format = '#{c} #{m} (#{s})',
sources = {
action.proselint, -- markdown actions
action.refactoring,
-- action.ts_node_action, -- treesitter node actions, buggy, causes repeated notifications
comp.spell, -- spell completion
comp.tags, -- tags completion
diag.actionlint, -- github action lint
diag.credo, -- elixir diagnostics
diag.golangci_lint,
diag.hadolint, -- docker lint
diag.proselint, -- markdown lint
diag.reek, -- ruby code smell
-- diag.rubocop, -- ruby diagnostics
-- diag.todo_comments, -- causes highlighter errors on J
diag.trail_space, -- trailing space check
diag.vint, -- vim lint
diag.write_good, -- english writing style
format.mix, -- elixir formatter
format.prettier, -- js, md, css, etc formatter
-- format.rubocop, -- ruby formatter
format.shfmt, -- shell formatter
format.stylua, -- lua formatter
hover.dictionary, -- show word dictionary on hover
hover.printenv, -- show env on hover
},
})
local auto_install = require('lib.util').get_user_config('auto_install', true)
local installed_sources = {}
if auto_install then
installed_sources = require('plugins.list').null_ls_sources
end
require('mason-null-ls').setup({
ensure_installed = installed_sources,
automatic_installation = auto_install,
})
+25
View File
@@ -0,0 +1,25 @@
local refactoring = require('refactoring')
refactoring.setup({
prompt_func_return_type = {
go = false,
java = false,
cpp = false,
c = false,
h = false,
hpp = false,
cxx = false,
},
prompt_func_param_type = {
go = false,
java = false,
cpp = false,
c = false,
h = false,
hpp = false,
cxx = false,
},
printf_statements = {},
print_var_statements = {},
})
+20
View File
@@ -0,0 +1,20 @@
local ror = require('ror')
local icons = require('lib.icons')
ror.setup({
test = {
message = {
file = 'Running test file...',
line = 'Running single test...',
},
coverage = {
up = 'DiffAdd',
down = 'DiffDelete',
},
notification = {
timeout = false,
},
pass_icon = icons.ui.Check,
fail_icon = icons.ui.Close,
},
})
+27
View File
@@ -0,0 +1,27 @@
local sniprun = require('sniprun')
local sniprun_api = require('sniprun.api')
sniprun.setup({
display = { 'Api' },
show_no_output = { 'Classic', 'TempFloatingWindow' },
display_options = {
terminal_width = 45,
notification_timeout = 5,
},
inline_messages = 0,
borders = 'single',
})
local api_listener = function(d)
if d.status == 'ok' then
vim.notify('Output: \n' .. d.message, vim.log.levels.INFO)
elseif d.status == 'error' then
vim.notify('Error: \n' .. d.message, vim.log.levels.ERROR)
else
vim.notify('Sniprun: ' .. d.message, vim.log.levels.INFO)
end
end
sniprun_api.register_listener(api_listener)
+25
View File
@@ -0,0 +1,25 @@
local surround = require('mini.surround')
surround.setup({
custom_surroundings = nil,
mappings = {
add = 'gsa',
delete = 'gsd',
find = 'gsf',
find_left = 'gsF',
highlight = 'gsh',
replace = 'gsr',
update_n_lines = 'gsn',
suffix_last = 'l', -- Suffix to search with "prev" method
suffix_next = 'n', -- Suffix to search with "next" method
},
-- How to search for surrounding
-- 'cover', 'cover_or_next', 'cover_or_prev','cover_or_nearest', 'next', 'previous', 'nearest'.
search_method = 'cover_or_nearest',
highlight_duration = 500,
n_lines = 20,
respect_selection_type = false,
silent = false,
})
+116
View File
@@ -0,0 +1,116 @@
local textobjects = {
select = {
enable = true,
lookahead = true,
keymaps = {
['a='] = { query = '@assignment.outer', desc = 'Select outer part of an assignment' },
['i='] = { query = '@assignment.inner', desc = 'Select inner part of an assignment' },
['al='] = { query = '@assignment.lhs', desc = 'Select left hand side of an assignment' },
['ar='] = {
query = '@assignment.rhs',
desc = 'Select right hand side of an assignment',
},
['a:'] = { query = '@property.outer', desc = 'Select outer part of an object property' },
['i:'] = { query = '@property.inner', desc = 'Select inner part of an object property' },
['l:'] = { query = '@property.lhs', desc = 'Select left part of an object property' },
['r:'] = { query = '@property.rhs', desc = 'Select right part of an object property' },
['aa'] = {
query = '@parameter.outer',
desc = 'Select outer part of a parameter/argument',
},
['ia'] = {
query = '@parameter.inner',
desc = 'Select inner part of a parameter/argument',
},
['ai'] = { query = '@conditional.outer', desc = 'Select outer part of a conditional' },
['ii'] = { query = '@conditional.inner', desc = 'Select inner part of a conditional' },
['al'] = { query = '@loop.outer', desc = 'Select outer part of a loop' },
['il'] = { query = '@loop.inner', desc = 'Select inner part of a loop' },
['af'] = { query = '@call.outer', desc = 'Select outer part of a function call' },
['if'] = { query = '@call.inner', desc = 'Select inner part of a function call' },
['am'] = {
query = '@function.outer',
desc = 'Select outer part of a method/function definition',
},
['im'] = {
query = '@function.inner',
desc = 'Select inner part of a method/function definition',
},
['ac'] = { query = '@class.outer', desc = 'Select outer part of a class' },
['ic'] = { query = '@class.inner', desc = 'Select inner part of a class' },
},
},
swap = {
enable = true,
swap_next = {
['<leader>rna'] = '@parameter.inner', -- swap object property with next
['<leader>rn:'] = '@property.outer', -- swap parameters/argument with next
['<leader>rnm'] = '@function.outer', -- swap function with next
},
swap_previous = {
['<leader>rpa'] = '@parameter.inner', -- swap parameters/argument with prev
['<leader>rp:'] = '@property.outer', -- swap object property with prev
['<leader>rpm'] = '@function.outer', -- swap function with previous
},
},
move = {
enable = true,
set_jumps = true, -- whether to set jumps in the jumplist
goto_next_start = {
[']c'] = { query = '@class.outer', desc = 'Next class start' },
[']f'] = { query = '@call.outer', desc = 'Next function call start' },
[']i'] = { query = '@conditional.outer', desc = 'Next conditional start' },
[']l'] = { query = '@loop.outer', desc = 'Next loop start' },
[']m'] = { query = '@function.outer', desc = 'Next method/function def start' },
[']z'] = { query = '@fold', query_group = 'folds', desc = 'Next fold' },
-- You can pass a query group to use query from `queries/<lang>/<query_group>.scm file in your runtime path.
-- Above example nvim-treesitter's folds.scm`. They also provide locals.scm, highlights.scm and indent.scm.
},
goto_next_end = {
[']C'] = { query = '@class.outer', desc = 'Next class end' },
[']F'] = { query = '@call.outer', desc = 'Next function call end' },
[']I'] = { query = '@conditional.outer', desc = 'Next conditional end' },
[']L'] = { query = '@loop.outer', desc = 'Next loop end' },
[']M'] = { query = '@function.outer', desc = 'Next method/function def end' },
[']Z'] = { query = '@fold', query_group = 'folds', desc = 'Next fold end' },
},
goto_previous_start = {
['[c'] = { query = '@class.outer', desc = 'Prev class start' },
['[f'] = { query = '@call.outer', desc = 'Prev function call start' },
['[i'] = { query = '@conditional.outer', desc = 'Prev conditional start' },
['[l'] = { query = '@loop.outer', desc = 'Prev loop start' },
['[m'] = { query = '@function.outer', desc = 'Prev method/function def start' },
['[z'] = { query = '@fold', query_group = 'folds', desc = 'Prev fold' },
},
goto_previous_end = {
['[C'] = { query = '@class.outer', desc = 'Prev class end' },
['[F'] = { query = '@call.outer', desc = 'Prev function call end' },
['[I'] = { query = '@conditional.outer', desc = 'Prev conditional end' },
['[L'] = { query = '@loop.outer', desc = 'Prev loop end' },
['[M'] = { query = '@function.outer', desc = 'Prev method/function def end' },
['[Z'] = { query = '@fold', query_group = 'folds', desc = 'Prev fold end' },
},
},
}
local ts_repeat_move = require('nvim-treesitter.textobjects.repeatable_move')
-- vim way: ; goes to the direction you were moving.
vim.keymap.set({ 'n', 'x', 'o' }, ';', ts_repeat_move.repeat_last_move)
vim.keymap.set({ 'n', 'x', 'o' }, ',', ts_repeat_move.repeat_last_move_opposite)
-- Optionally, make builtin f, F, t, T also repeatable with ; and ,
vim.keymap.set({ 'n', 'x', 'o' }, 'f', ts_repeat_move.builtin_f)
vim.keymap.set({ 'n', 'x', 'o' }, 'F', ts_repeat_move.builtin_F)
vim.keymap.set({ 'n', 'x', 'o' }, 't', ts_repeat_move.builtin_t)
vim.keymap.set({ 'n', 'x', 'o' }, 'T', ts_repeat_move.builtin_T)
return textobjects
+84
View File
@@ -0,0 +1,84 @@
local treesitter = require('nvim-treesitter.configs')
local textobjects = require('plugins.lang.textobjects')
local auto_install = require('lib.util').get_user_config('auto_install', true)
local installed_parsers = {}
if auto_install then
installed_parsers = require('plugins.list').ts_parsers
end
treesitter.setup({
ensure_installed = installed_parsers,
sync_install = false,
ignore_install = {},
auto_install = true,
textobjects = textobjects,
autopairs = { enable = true },
endwise = { enable = true },
autotag = { enable = true },
matchup = { enable = true },
indent = { enable = true },
highlight = {
enable = true,
disable = function(lang, buf)
local max_filesize = 100 * 1024 -- 100 KB
local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
if ok and stats and stats.size > max_filesize then
return true
end
end,
additional_vim_regex_highlighting = false,
},
incremental_selection = {
enable = true,
keymaps = {
init_selection = '<c-space>',
node_incremental = '<c-space>',
scope_incremental = false,
node_decremental = '<bs>',
},
},
textsubjects = {
enable = true,
prev_selection = ',',
keymaps = {
['.'] = { 'textsubjects-smart', desc = 'Select the current text subject' },
['a;'] = {
'textsubjects-container-outer',
desc = 'Select outer container (class, function, etc.)',
},
['i;'] = {
'textsubjects-container-inner',
desc = 'Select inside containers (classes, functions, etc.)',
},
},
},
refactor = {
highlight_definitions = {
enable = true,
clear_on_cursor_move = true,
},
highlight_current_scope = { enable = true },
smart_rename = {
enable = true,
keymaps = {
smart_rename = '<leader>rr',
},
},
navigation = {
enable = true,
keymaps = {
goto_definition = '<leader>rd',
list_definitions = '<leader>rl',
list_definitions_toc = '<leader>rh',
goto_next_usage = '<leader>rj',
goto_previous_usage = '<leader>rk',
},
},
},
})