refactor: Complete modular migration from kickstart.nvim
Major architectural overhaul to transform the flat kickstart.nvim structure
into a maintainable, modular configuration while preserving upstream sync capability.
## Structure Changes
- Migrated from flat `lua/custom/` to organized `lua/core/` and `lua/plugins/`
- Separated plugin specs from configs: `lua/plugins/spec/` and `lua/plugins/config/`
- Complex configs (LSP, Debug) now use directory structure with sub-modules:
- `lsp/init.lua`, `lsp/servers.lua`, `lsp/keymaps.lua`
- `debug/init.lua`, `debug/adapters.lua`, `debug/keymaps.lua`
## Core Improvements
- Created dedicated core modules: options, keymaps, autocmds, bootstrap, health
- Added comprehensive health check (`lua/core/health.lua`) for diagnostics
- Simplified init.lua to just orchestrate module loading
- Better separation of concerns throughout
## Plugin Updates
- Fixed Blink.cmp configuration (removed invalid fuzzy options)
- Integrated Copilot with Blink.cmp for unified completion experience
- Added autopairs and indent-line from kickstart examples
- Optimized for Nix development environments (removed venv assumptions)
## Documentation
- Updated README with modular structure and kickstart sync instructions
- Created comprehensive KEYBIND_ANALYSIS.md with all mappings
- Added modular.txt help documentation
- Created TODO_TEST.md checklist for testing
## Benefits
- Easier to maintain and extend
- Clean separation allows upstream kickstart merges without conflicts
- Scalable architecture for adding new languages/tools
- Better code organization and discoverability
All kickstart functionality preserved while gaining modularity and maintainability.
This commit is contained in:
parent
277be1e79b
commit
f81cab2da3
55 changed files with 2039 additions and 2299 deletions
126
lua/plugins/config/blink.lua
Normal file
126
lua/plugins/config/blink.lua
Normal file
|
|
@ -0,0 +1,126 @@
|
|||
-- Blink.cmp Configuration
|
||||
local M = {}
|
||||
|
||||
function M.setup()
|
||||
require('blink.cmp').setup({
|
||||
-- Keymap configuration
|
||||
keymap = {
|
||||
preset = 'default',
|
||||
['<C-space>'] = { 'show', 'show_documentation', 'hide_documentation' },
|
||||
['<C-e>'] = { 'hide' },
|
||||
['<C-y>'] = { 'select_and_accept' },
|
||||
|
||||
['<C-p>'] = { 'select_prev', 'fallback' },
|
||||
['<C-n>'] = { 'select_next', 'fallback' },
|
||||
|
||||
['<C-b>'] = { 'scroll_documentation_up', 'fallback' },
|
||||
['<C-f>'] = { 'scroll_documentation_down', 'fallback' },
|
||||
|
||||
['<Tab>'] = { 'snippet_forward', 'fallback' },
|
||||
['<S-Tab>'] = { 'snippet_backward', 'fallback' },
|
||||
},
|
||||
|
||||
-- Appearance configuration
|
||||
appearance = {
|
||||
use_nvim_cmp_as_default = true,
|
||||
nerd_font_variant = 'mono',
|
||||
},
|
||||
|
||||
-- Sources configuration with Copilot integration
|
||||
sources = {
|
||||
default = { 'lsp', 'path', 'snippets', 'buffer', 'copilot' },
|
||||
providers = {
|
||||
copilot = {
|
||||
name = 'copilot',
|
||||
module = 'blink-cmp-copilot',
|
||||
score_offset = 100,
|
||||
async = true,
|
||||
transform_items = function(_, items)
|
||||
-- Add copilot icon to copilot suggestions
|
||||
for _, item in ipairs(items) do
|
||||
item.kind = 'Copilot'
|
||||
end
|
||||
return items
|
||||
end,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- Command line configuration (new API)
|
||||
cmdline = {
|
||||
enabled = false, -- Disable cmdline completion for now
|
||||
},
|
||||
|
||||
-- Signature help configuration
|
||||
signature = {
|
||||
enabled = true,
|
||||
window = {
|
||||
border = 'rounded',
|
||||
},
|
||||
},
|
||||
|
||||
-- Completion configuration
|
||||
completion = {
|
||||
accept = {
|
||||
-- Auto-insert brackets for functions
|
||||
auto_brackets = {
|
||||
enabled = true,
|
||||
},
|
||||
},
|
||||
menu = {
|
||||
draw = {
|
||||
columns = {
|
||||
{ 'label', 'label_description', gap = 1 },
|
||||
{ 'kind_icon', 'kind' }
|
||||
},
|
||||
},
|
||||
border = 'rounded',
|
||||
winblend = 0,
|
||||
},
|
||||
documentation = {
|
||||
auto_show = true,
|
||||
auto_show_delay_ms = 200,
|
||||
window = {
|
||||
border = 'rounded',
|
||||
},
|
||||
},
|
||||
ghost_text = {
|
||||
enabled = true,
|
||||
},
|
||||
},
|
||||
|
||||
-- Fuzzy matching configuration
|
||||
fuzzy = {
|
||||
-- Use Rust implementation for better performance
|
||||
implementation = 'prefer_rust_with_warning',
|
||||
-- Allow typos based on keyword length
|
||||
max_typos = function(keyword)
|
||||
return math.floor(#keyword / 4)
|
||||
end,
|
||||
-- Track frequently/recently used items
|
||||
use_frecency = true,
|
||||
-- Boost items matching nearby words
|
||||
use_proximity = true,
|
||||
-- Prebuilt binaries configuration
|
||||
prebuilt_binaries = {
|
||||
download = true,
|
||||
},
|
||||
},
|
||||
|
||||
-- Snippet configuration
|
||||
snippets = {
|
||||
expand = function(snippet)
|
||||
-- Use native snippet expansion if available
|
||||
if vim.snippet then
|
||||
vim.snippet.expand(snippet)
|
||||
else
|
||||
-- Fallback to basic expansion
|
||||
local insert = string.gsub(snippet, '%$%d+', '')
|
||||
vim.api.nvim_put({ insert }, 'c', true, true)
|
||||
end
|
||||
end,
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
return M
|
||||
158
lua/plugins/config/debug/adapters.lua
Normal file
158
lua/plugins/config/debug/adapters.lua
Normal file
|
|
@ -0,0 +1,158 @@
|
|||
-- Debug Adapters Configuration
|
||||
local M = {}
|
||||
|
||||
-- Helper function to find Python executable
|
||||
-- In Nix environments, use whatever Python is in PATH
|
||||
local function get_python_path()
|
||||
-- Use the Python from current environment (Nix or system)
|
||||
if vim.fn.executable('python3') == 1 then
|
||||
return vim.fn.exepath('python3')
|
||||
elseif vim.fn.executable('python') == 1 then
|
||||
return vim.fn.exepath('python')
|
||||
else
|
||||
-- Fallback to system Python
|
||||
return '/usr/bin/python3'
|
||||
end
|
||||
end
|
||||
|
||||
function M.setup()
|
||||
local dap = require('dap')
|
||||
|
||||
-- Setup all language-specific adapters
|
||||
M.setup_python(dap)
|
||||
M.setup_cpp(dap)
|
||||
|
||||
-- Add more adapters as needed
|
||||
-- M.setup_rust(dap)
|
||||
-- M.setup_go(dap)
|
||||
-- M.setup_javascript(dap)
|
||||
end
|
||||
|
||||
-- Python debugger configuration
|
||||
function M.setup_python(dap)
|
||||
dap.adapters.python = {
|
||||
type = 'executable',
|
||||
command = vim.fn.exepath('python3') ~= '' and vim.fn.exepath('python3') or 'python',
|
||||
args = { '-m', 'debugpy.adapter' },
|
||||
}
|
||||
|
||||
dap.configurations.python = {
|
||||
{
|
||||
type = 'python',
|
||||
request = 'launch',
|
||||
name = 'Launch file',
|
||||
program = '${file}',
|
||||
pythonPath = get_python_path,
|
||||
},
|
||||
{
|
||||
type = 'python',
|
||||
request = 'launch',
|
||||
name = 'Launch file with arguments',
|
||||
program = '${file}',
|
||||
args = function()
|
||||
local args_string = vim.fn.input('Arguments: ')
|
||||
return vim.split(args_string, ' ')
|
||||
end,
|
||||
pythonPath = get_python_path,
|
||||
},
|
||||
{
|
||||
type = 'python',
|
||||
request = 'attach',
|
||||
name = 'Attach to running process',
|
||||
processId = require('dap.utils').pick_process,
|
||||
pythonPath = get_python_path,
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
-- C/C++/Rust debugger configuration (using codelldb)
|
||||
function M.setup_cpp(dap)
|
||||
-- CodeLLDB adapter
|
||||
dap.adapters.codelldb = {
|
||||
type = 'server',
|
||||
port = '${port}',
|
||||
executable = {
|
||||
command = 'codelldb',
|
||||
args = { '--port', '${port}' },
|
||||
},
|
||||
}
|
||||
|
||||
-- Alternative: Use lldb-vscode if codelldb is not available
|
||||
dap.adapters.lldb = {
|
||||
type = 'executable',
|
||||
command = '/usr/bin/lldb-vscode', -- Adjust path as needed
|
||||
name = 'lldb',
|
||||
}
|
||||
|
||||
-- C++ configuration
|
||||
dap.configurations.cpp = {
|
||||
{
|
||||
name = 'Launch',
|
||||
type = 'codelldb',
|
||||
request = 'launch',
|
||||
program = function()
|
||||
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
|
||||
end,
|
||||
cwd = '${workspaceFolder}',
|
||||
stopOnEntry = false,
|
||||
args = {},
|
||||
runInTerminal = false,
|
||||
},
|
||||
{
|
||||
name = 'Launch with arguments',
|
||||
type = 'codelldb',
|
||||
request = 'launch',
|
||||
program = function()
|
||||
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/', 'file')
|
||||
end,
|
||||
cwd = '${workspaceFolder}',
|
||||
stopOnEntry = false,
|
||||
args = function()
|
||||
local args_string = vim.fn.input('Arguments: ')
|
||||
return vim.split(args_string, ' ')
|
||||
end,
|
||||
runInTerminal = false,
|
||||
},
|
||||
{
|
||||
name = 'Attach to process',
|
||||
type = 'codelldb',
|
||||
request = 'attach',
|
||||
pid = require('dap.utils').pick_process,
|
||||
args = {},
|
||||
},
|
||||
}
|
||||
|
||||
-- Share C++ configuration with C and Rust
|
||||
dap.configurations.c = dap.configurations.cpp
|
||||
dap.configurations.rust = dap.configurations.cpp
|
||||
end
|
||||
|
||||
-- Example: Go debugger configuration (commented out)
|
||||
-- function M.setup_go(dap)
|
||||
-- dap.adapters.delve = {
|
||||
-- type = 'server',
|
||||
-- port = '${port}',
|
||||
-- executable = {
|
||||
-- command = 'dlv',
|
||||
-- args = { 'dap', '-l', '127.0.0.1:${port}' },
|
||||
-- },
|
||||
-- }
|
||||
--
|
||||
-- dap.configurations.go = {
|
||||
-- {
|
||||
-- type = 'delve',
|
||||
-- name = 'Debug',
|
||||
-- request = 'launch',
|
||||
-- program = '${file}',
|
||||
-- },
|
||||
-- {
|
||||
-- type = 'delve',
|
||||
-- name = 'Debug test',
|
||||
-- request = 'launch',
|
||||
-- mode = 'test',
|
||||
-- program = '${file}',
|
||||
-- },
|
||||
-- }
|
||||
-- end
|
||||
|
||||
return M
|
||||
38
lua/plugins/config/debug/init.lua
Normal file
38
lua/plugins/config/debug/init.lua
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
-- Debug Configuration (DAP)
|
||||
local M = {}
|
||||
|
||||
function M.setup()
|
||||
local dap = require('dap')
|
||||
local dapui = require('dapui')
|
||||
|
||||
-- Setup DAP UI with icons and controls
|
||||
dapui.setup({
|
||||
icons = { expanded = '▾', collapsed = '▸', current_frame = '*' },
|
||||
controls = {
|
||||
icons = {
|
||||
pause = '⏸',
|
||||
play = '▶',
|
||||
step_into = '⏎',
|
||||
step_over = '⏭',
|
||||
step_out = '⏮',
|
||||
step_back = 'b',
|
||||
run_last = '▶▶',
|
||||
terminate = '⏹',
|
||||
disconnect = '⏏',
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
-- Automatically open/close DAP UI on debug events
|
||||
dap.listeners.after.event_initialized['dapui_config'] = dapui.open
|
||||
dap.listeners.before.event_terminated['dapui_config'] = dapui.close
|
||||
dap.listeners.before.event_exited['dapui_config'] = dapui.close
|
||||
|
||||
-- Configure debug adapters for different languages
|
||||
require('plugins.config.debug.adapters').setup()
|
||||
|
||||
-- Setup debug keymaps
|
||||
require('plugins.config.debug.keymaps').setup()
|
||||
end
|
||||
|
||||
return M
|
||||
59
lua/plugins/config/debug/keymaps.lua
Normal file
59
lua/plugins/config/debug/keymaps.lua
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
-- Debug Keymaps Configuration
|
||||
local M = {}
|
||||
|
||||
function M.setup()
|
||||
local dap = require('dap')
|
||||
local dapui = require('dapui')
|
||||
|
||||
-- Function key mappings for common debug operations
|
||||
vim.keymap.set('n', '<F5>', dap.continue, { desc = 'Debug: Start/Continue' })
|
||||
vim.keymap.set('n', '<F10>', dap.step_over, { desc = 'Debug: Step Over' })
|
||||
vim.keymap.set('n', '<F11>', dap.step_into, { desc = 'Debug: Step Into' })
|
||||
vim.keymap.set('n', '<F12>', dap.step_out, { desc = 'Debug: Step Out' })
|
||||
|
||||
-- Breakpoint management
|
||||
vim.keymap.set('n', '<leader>db', dap.toggle_breakpoint, { desc = 'Debug: Toggle Breakpoint' })
|
||||
vim.keymap.set('n', '<leader>dB', function()
|
||||
dap.set_breakpoint(vim.fn.input 'Breakpoint condition: ')
|
||||
end, { desc = 'Debug: Set Conditional Breakpoint' })
|
||||
vim.keymap.set('n', '<leader>lp', function()
|
||||
dap.set_breakpoint(nil, nil, vim.fn.input('Log point message: '))
|
||||
end, { desc = 'Debug: Set Log Point' })
|
||||
|
||||
-- DAP UI controls
|
||||
vim.keymap.set('n', '<F7>', dapui.toggle, { desc = 'Debug: Toggle UI' })
|
||||
vim.keymap.set('n', '<leader>de', dapui.eval, { desc = 'Debug: Eval under cursor' })
|
||||
vim.keymap.set('v', '<leader>de', dapui.eval, { desc = 'Debug: Eval selection' })
|
||||
|
||||
-- REPL and additional features
|
||||
vim.keymap.set('n', '<leader>dr', dap.repl.open, { desc = 'Debug: Open REPL' })
|
||||
vim.keymap.set('n', '<leader>dl', dap.run_last, { desc = 'Debug: Run Last' })
|
||||
|
||||
-- Widget-based inspections
|
||||
vim.keymap.set('n', '<leader>dh', function()
|
||||
require('dap.ui.widgets').hover()
|
||||
end, { desc = 'Debug: Hover Variables' })
|
||||
|
||||
vim.keymap.set('n', '<leader>ds', function()
|
||||
local widgets = require('dap.ui.widgets')
|
||||
widgets.centered_float(widgets.scopes)
|
||||
end, { desc = 'Debug: View Scopes' })
|
||||
|
||||
vim.keymap.set('n', '<leader>df', function()
|
||||
local widgets = require('dap.ui.widgets')
|
||||
widgets.centered_float(widgets.frames)
|
||||
end, { desc = 'Debug: View Frames' })
|
||||
|
||||
-- Session management
|
||||
vim.keymap.set('n', '<leader>dt', dap.terminate, { desc = 'Debug: Terminate Session' })
|
||||
vim.keymap.set('n', '<leader>dc', dap.run_to_cursor, { desc = 'Debug: Continue to Cursor' })
|
||||
|
||||
-- Create visual indicators for breakpoints
|
||||
vim.fn.sign_define('DapBreakpoint', { text = '🔴', texthl = 'DapBreakpoint', linehl = '', numhl = '' })
|
||||
vim.fn.sign_define('DapBreakpointCondition', { text = '🟡', texthl = 'DapBreakpoint', linehl = '', numhl = '' })
|
||||
vim.fn.sign_define('DapBreakpointRejected', { text = '⭕', texthl = 'DapBreakpoint', linehl = '', numhl = '' })
|
||||
vim.fn.sign_define('DapLogPoint', { text = '📝', texthl = 'DapLogPoint', linehl = '', numhl = '' })
|
||||
vim.fn.sign_define('DapStopped', { text = '▶️', texthl = 'DapStopped', linehl = 'DapStopped', numhl = 'DapStopped' })
|
||||
end
|
||||
|
||||
return M
|
||||
59
lua/plugins/config/editor.lua
Normal file
59
lua/plugins/config/editor.lua
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
-- Editor Enhancement Configuration
|
||||
local M = {}
|
||||
|
||||
function M.setup_mini()
|
||||
-- Better Around/Inside textobjects
|
||||
require('mini.ai').setup { n_lines = 500 }
|
||||
|
||||
-- Add/delete/replace surroundings (brackets, quotes, etc.)
|
||||
require('mini.surround').setup()
|
||||
|
||||
-- Simple and easy statusline
|
||||
local statusline = require 'mini.statusline'
|
||||
statusline.setup { use_icons = vim.g.have_nerd_font }
|
||||
|
||||
-- Custom statusline location section
|
||||
---@diagnostic disable-next-line: duplicate-set-field
|
||||
statusline.section_location = function()
|
||||
return '%2l:%-2v'
|
||||
end
|
||||
end
|
||||
|
||||
function M.setup_illuminate()
|
||||
require('illuminate').configure({
|
||||
delay = 200,
|
||||
large_file_cutoff = 2000,
|
||||
large_file_overrides = {
|
||||
providers = { 'lsp' },
|
||||
},
|
||||
providers = {
|
||||
'lsp',
|
||||
'treesitter',
|
||||
'regex',
|
||||
},
|
||||
filetypes_denylist = {
|
||||
'dirbuf',
|
||||
'dirvish',
|
||||
'fugitive',
|
||||
'alpha',
|
||||
'NvimTree',
|
||||
'lazy',
|
||||
'neogitstatus',
|
||||
'Trouble',
|
||||
'lir',
|
||||
'Outline',
|
||||
'spectre_panel',
|
||||
'toggleterm',
|
||||
'DressingSelect',
|
||||
'TelescopePrompt',
|
||||
},
|
||||
under_cursor = true,
|
||||
})
|
||||
end
|
||||
|
||||
function M.setup()
|
||||
M.setup_mini()
|
||||
M.setup_illuminate()
|
||||
end
|
||||
|
||||
return M
|
||||
69
lua/plugins/config/git.lua
Normal file
69
lua/plugins/config/git.lua
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
-- Git Configuration
|
||||
local M = {}
|
||||
|
||||
function M.setup_gitsigns()
|
||||
require('gitsigns').setup({
|
||||
signs = {
|
||||
add = { text = '+' },
|
||||
change = { text = '~' },
|
||||
delete = { text = '_' },
|
||||
topdelete = { text = '‾' },
|
||||
changedelete = { text = '~' },
|
||||
},
|
||||
on_attach = function(bufnr)
|
||||
local gitsigns = require('gitsigns')
|
||||
|
||||
local function map(mode, l, r, opts)
|
||||
opts = opts or {}
|
||||
opts.buffer = bufnr
|
||||
vim.keymap.set(mode, l, r, opts)
|
||||
end
|
||||
|
||||
-- Navigation
|
||||
map('n', ']c', function()
|
||||
if vim.wo.diff then
|
||||
vim.cmd.normal({']c', bang = true})
|
||||
else
|
||||
gitsigns.nav_hunk('next')
|
||||
end
|
||||
end, { desc = 'Jump to next git [c]hange' })
|
||||
|
||||
map('n', '[c', function()
|
||||
if vim.wo.diff then
|
||||
vim.cmd.normal({'[c', bang = true})
|
||||
else
|
||||
gitsigns.nav_hunk('prev')
|
||||
end
|
||||
end, { desc = 'Jump to previous git [c]hange' })
|
||||
|
||||
-- Actions
|
||||
map('n', '<leader>hs', gitsigns.stage_hunk, { desc = 'Git [s]tage hunk' })
|
||||
map('n', '<leader>hr', gitsigns.reset_hunk, { desc = 'Git [r]eset hunk' })
|
||||
map('v', '<leader>hs', function()
|
||||
gitsigns.stage_hunk({vim.fn.line('.'), vim.fn.line('v')})
|
||||
end, { desc = 'Git [s]tage hunk' })
|
||||
map('v', '<leader>hr', function()
|
||||
gitsigns.reset_hunk({vim.fn.line('.'), vim.fn.line('v')})
|
||||
end, { desc = 'Git [r]eset hunk' })
|
||||
|
||||
map('n', '<leader>hS', gitsigns.stage_buffer, { desc = 'Git [S]tage buffer' })
|
||||
map('n', '<leader>hu', gitsigns.undo_stage_hunk, { desc = 'Git [u]ndo stage hunk' })
|
||||
map('n', '<leader>hR', gitsigns.reset_buffer, { desc = 'Git [R]eset buffer' })
|
||||
map('n', '<leader>hp', gitsigns.preview_hunk, { desc = 'Git [p]review hunk' })
|
||||
map('n', '<leader>hb', gitsigns.blame_line, { desc = 'Git [b]lame line' })
|
||||
map('n', '<leader>hd', gitsigns.diffthis, { desc = 'Git [d]iff against index' })
|
||||
map('n', '<leader>hD', function()
|
||||
gitsigns.diffthis('@')
|
||||
end, { desc = 'Git [D]iff against last commit' })
|
||||
|
||||
-- Toggles
|
||||
map('n', '<leader>tb', gitsigns.toggle_current_line_blame, { desc = '[T]oggle git show [b]lame line' })
|
||||
map('n', '<leader>tD', gitsigns.toggle_deleted, { desc = '[T]oggle git show [D]eleted' })
|
||||
|
||||
-- Text object
|
||||
map({'o', 'x'}, 'ih', ':<C-U>Gitsigns select_hunk<CR>', { desc = 'Select git hunk' })
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
return M
|
||||
26
lua/plugins/config/lsp/init.lua
Normal file
26
lua/plugins/config/lsp/init.lua
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
-- LSP Configuration Module
|
||||
local M = {}
|
||||
|
||||
function M.setup()
|
||||
local lspconfig = require 'lspconfig'
|
||||
|
||||
-- Get capabilities from blink.cmp if available
|
||||
local capabilities = {}
|
||||
pcall(function()
|
||||
capabilities = require('blink.cmp').get_lsp_capabilities()
|
||||
end)
|
||||
|
||||
-- Load server configurations
|
||||
local servers = require('plugins.config.lsp.servers').get_servers()
|
||||
|
||||
-- Setup each server with capabilities
|
||||
for name, config in pairs(servers) do
|
||||
config.capabilities = vim.tbl_deep_extend('force', {}, capabilities, config.capabilities or {})
|
||||
lspconfig[name].setup(config)
|
||||
end
|
||||
|
||||
-- Setup LSP keymaps
|
||||
require('plugins.config.lsp.keymaps').setup()
|
||||
end
|
||||
|
||||
return M
|
||||
57
lua/plugins/config/lsp/keymaps.lua
Normal file
57
lua/plugins/config/lsp/keymaps.lua
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
-- LSP Keymaps Configuration
|
||||
local M = {}
|
||||
|
||||
function M.setup()
|
||||
-- Setup keymaps when LSP attaches to a buffer
|
||||
vim.api.nvim_create_autocmd('LspAttach', {
|
||||
group = vim.api.nvim_create_augroup('lsp-attach-keymaps', { clear = true }),
|
||||
callback = function(event)
|
||||
-- Helper function to define keymaps
|
||||
local map = function(keys, func, desc, mode)
|
||||
mode = mode or 'n'
|
||||
vim.keymap.set(mode, keys, func, { buffer = event.buf, desc = 'LSP: ' .. desc })
|
||||
end
|
||||
|
||||
-- Navigation keymaps (using kickstart.nvim patterns)
|
||||
map('gd', require('telescope.builtin').lsp_definitions, '[G]oto [D]efinition')
|
||||
map('grr', require('telescope.builtin').lsp_references, '[G]oto [R]eferences')
|
||||
map('gri', require('telescope.builtin').lsp_implementations, '[G]oto [I]mplementation')
|
||||
map('grt', require('telescope.builtin').lsp_type_definitions, '[G]oto [T]ype definition')
|
||||
map('grD', vim.lsp.buf.declaration, '[G]oto [D]eclaration')
|
||||
|
||||
-- Symbol operations
|
||||
map('grn', vim.lsp.buf.rename, '[G]oto [R]e[n]ame')
|
||||
map('gra', vim.lsp.buf.code_action, '[G]oto code [A]ction', { 'n', 'x' })
|
||||
map('gO', require('telescope.builtin').lsp_document_symbols, '[G]oto [O]pen document symbols')
|
||||
map('gW', require('telescope.builtin').lsp_dynamic_workspace_symbols, '[G]oto [W]orkspace symbols')
|
||||
|
||||
-- Documentation
|
||||
map('K', vim.lsp.buf.hover, 'Hover Documentation')
|
||||
|
||||
-- Formatting
|
||||
map('<leader>f', function()
|
||||
vim.lsp.buf.format { async = true }
|
||||
end, '[F]ormat buffer')
|
||||
|
||||
-- The following keymaps are available but not mapped by default:
|
||||
-- vim.lsp.buf.signature_help - Show function signature help
|
||||
-- vim.lsp.buf.add_workspace_folder - Add workspace folder
|
||||
-- vim.lsp.buf.remove_workspace_folder - Remove workspace folder
|
||||
-- vim.lsp.buf.list_workspace_folders - List workspace folders
|
||||
|
||||
-- Optional: Add a message when LSP attaches
|
||||
local client = vim.lsp.get_client_by_id(event.data.client_id)
|
||||
if client then
|
||||
vim.notify('LSP attached: ' .. client.name, vim.log.levels.INFO)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
-- Diagnostic keymaps (available globally, not just when LSP attaches)
|
||||
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous [D]iagnostic message' })
|
||||
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next [D]iagnostic message' })
|
||||
vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { desc = 'Show diagnostic [E]rror messages' })
|
||||
vim.keymap.set('n', '<leader>q', vim.diagnostic.setloclist, { desc = 'Open diagnostic [Q]uickfix list' })
|
||||
end
|
||||
|
||||
return M
|
||||
88
lua/plugins/config/lsp/servers.lua
Normal file
88
lua/plugins/config/lsp/servers.lua
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
-- LSP Server Configurations
|
||||
local M = {}
|
||||
|
||||
local util = require 'lspconfig.util'
|
||||
|
||||
-- Query driver for clangd to find compilers in various locations
|
||||
local function get_clangd_query_driver()
|
||||
return table.concat({
|
||||
'/nix/store/*/bin/clang*',
|
||||
'/opt/homebrew/opt/llvm/bin/clang*',
|
||||
'/usr/bin/clang*',
|
||||
}, ';')
|
||||
end
|
||||
|
||||
-- Get clang resource directory
|
||||
local function get_clang_resource_dir()
|
||||
local ok, result = pcall(vim.fn.systemlist, { 'clang++', '--print-resource-dir' })
|
||||
if ok and result and result[1] then
|
||||
return result[1]
|
||||
else
|
||||
return '/usr/lib/clang/19/include' -- fallback
|
||||
end
|
||||
end
|
||||
|
||||
function M.get_servers()
|
||||
return {
|
||||
-- C/C++ Language Server
|
||||
clangd = {
|
||||
cmd = {
|
||||
'clangd',
|
||||
'--background-index',
|
||||
'--clang-tidy',
|
||||
'--header-insertion=never',
|
||||
'--query-driver=' .. get_clangd_query_driver(),
|
||||
'--compile-commands-dir=build',
|
||||
'--resource-dir=' .. get_clang_resource_dir(),
|
||||
},
|
||||
filetypes = { 'c', 'cpp', 'objc', 'objcpp', 'cuda' },
|
||||
root_dir = util.root_pattern('CMakeLists.txt', '.git'),
|
||||
single_file_support = true,
|
||||
},
|
||||
|
||||
-- Python Language Server
|
||||
pyright = {
|
||||
settings = {
|
||||
python = {
|
||||
analysis = {
|
||||
autoSearchPaths = true,
|
||||
diagnosticMode = 'openFilesOnly',
|
||||
useLibraryCodeForTypes = true,
|
||||
typeCheckingMode = 'basic',
|
||||
},
|
||||
},
|
||||
},
|
||||
positionEncoding = 'utf-8',
|
||||
},
|
||||
|
||||
-- Python Linter/Formatter
|
||||
ruff = {},
|
||||
|
||||
-- Nix Language Server
|
||||
nixd = {},
|
||||
|
||||
-- LaTeX Language Server
|
||||
texlab = {},
|
||||
|
||||
-- CMake Language Server
|
||||
cmake = {
|
||||
cmd = { 'cmake-language-server' },
|
||||
filetypes = { 'cmake' },
|
||||
root_dir = util.root_pattern('CMakeLists.txt', '.git'),
|
||||
},
|
||||
|
||||
-- Add more servers here as needed
|
||||
-- Example:
|
||||
-- rust_analyzer = {
|
||||
-- settings = {
|
||||
-- ['rust-analyzer'] = {
|
||||
-- checkOnSave = {
|
||||
-- command = 'clippy',
|
||||
-- },
|
||||
-- },
|
||||
-- },
|
||||
-- },
|
||||
}
|
||||
end
|
||||
|
||||
return M
|
||||
84
lua/plugins/config/telescope.lua
Normal file
84
lua/plugins/config/telescope.lua
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
-- Telescope Configuration
|
||||
local M = {}
|
||||
|
||||
function M.setup()
|
||||
local telescope = require('telescope')
|
||||
local builtin = require('telescope.builtin')
|
||||
|
||||
telescope.setup({
|
||||
defaults = {
|
||||
prompt_prefix = '> ',
|
||||
selection_caret = '> ',
|
||||
path_display = { 'truncate' },
|
||||
sorting_strategy = 'ascending',
|
||||
layout_config = {
|
||||
horizontal = {
|
||||
prompt_position = 'top',
|
||||
preview_width = 0.55,
|
||||
},
|
||||
vertical = {
|
||||
mirror = false,
|
||||
},
|
||||
width = 0.87,
|
||||
height = 0.80,
|
||||
preview_cutoff = 120,
|
||||
},
|
||||
},
|
||||
pickers = {
|
||||
find_files = {
|
||||
-- Use rg for finding files (ensure rg is installed via Nix/Home Manager)
|
||||
find_command = { 'rg', '--files', '--hidden', '-g', '!.git' },
|
||||
},
|
||||
},
|
||||
extensions = {
|
||||
['ui-select'] = {
|
||||
require('telescope.themes').get_dropdown(),
|
||||
},
|
||||
fzf = {
|
||||
fuzzy = true,
|
||||
override_generic_sorter = true,
|
||||
override_file_sorter = true,
|
||||
case_mode = 'smart_case',
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
-- Load extensions
|
||||
pcall(telescope.load_extension, 'fzf')
|
||||
pcall(telescope.load_extension, 'ui-select')
|
||||
|
||||
-- Setup keymaps
|
||||
vim.keymap.set('n', '<leader>sf', builtin.find_files, { desc = '[S]earch [F]iles' })
|
||||
vim.keymap.set('n', '<leader>sg', builtin.live_grep, { desc = '[S]earch by [G]rep' })
|
||||
vim.keymap.set('n', '<leader>sh', builtin.help_tags, { desc = '[S]earch [H]elp' })
|
||||
vim.keymap.set('n', '<leader>sk', builtin.keymaps, { desc = '[S]earch [K]eymaps' })
|
||||
vim.keymap.set('n', '<leader>ss', builtin.builtin, { desc = '[S]earch [S]elect Telescope' })
|
||||
vim.keymap.set('n', '<leader>sw', builtin.grep_string, { desc = '[S]earch current [W]ord' })
|
||||
vim.keymap.set('n', '<leader>sd', builtin.diagnostics, { desc = '[S]earch [D]iagnostics' })
|
||||
vim.keymap.set('n', '<leader>sr', builtin.resume, { desc = '[S]earch [R]esume' })
|
||||
vim.keymap.set('n', '<leader>s.', builtin.oldfiles, { desc = '[S]earch Recent Files ("." for repeat)' })
|
||||
vim.keymap.set('n', '<leader><leader>', builtin.buffers, { desc = '[ ] Find existing buffers' })
|
||||
|
||||
-- Fuzzy search in current buffer
|
||||
vim.keymap.set('n', '<leader>/', function()
|
||||
builtin.current_buffer_fuzzy_find(require('telescope.themes').get_dropdown {
|
||||
winblend = 10,
|
||||
previewer = false,
|
||||
})
|
||||
end, { desc = '[/] Fuzzily search in current buffer' })
|
||||
|
||||
-- Search in open files
|
||||
vim.keymap.set('n', '<leader>s/', function()
|
||||
builtin.live_grep {
|
||||
grep_open_files = true,
|
||||
prompt_title = 'Live Grep in Open Files',
|
||||
}
|
||||
end, { desc = '[S]earch [/] in Open Files' })
|
||||
|
||||
-- Search in neovim config
|
||||
vim.keymap.set('n', '<leader>sn', function()
|
||||
builtin.find_files { cwd = vim.fn.stdpath 'config' }
|
||||
end, { desc = '[S]earch [N]eovim files' })
|
||||
end
|
||||
|
||||
return M
|
||||
57
lua/plugins/config/ui.lua
Normal file
57
lua/plugins/config/ui.lua
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
-- UI Configuration
|
||||
local M = {}
|
||||
|
||||
function M.setup_which_key()
|
||||
local wk = require 'which-key'
|
||||
|
||||
wk.setup({
|
||||
delay = 0,
|
||||
icons = {
|
||||
mappings = vim.g.have_nerd_font,
|
||||
keys = vim.g.have_nerd_font and {} or {
|
||||
Up = '<Up> ',
|
||||
Down = '<Down> ',
|
||||
Left = '<Left> ',
|
||||
Right = '<Right> ',
|
||||
C = '<C-…> ',
|
||||
M = '<M-…> ',
|
||||
D = '<D-…> ',
|
||||
S = '<S-…> ',
|
||||
CR = '<CR> ',
|
||||
Esc = '<Esc> ',
|
||||
ScrollWheelDown = '<ScrollWheelDown> ',
|
||||
ScrollWheelUp = '<ScrollWheelUp> ',
|
||||
NL = '<NL> ',
|
||||
BS = '<BS> ',
|
||||
Space = '<Space> ',
|
||||
Tab = '<Tab> ',
|
||||
F1 = '<F1>',
|
||||
F2 = '<F2>',
|
||||
F3 = '<F3>',
|
||||
F4 = '<F4>',
|
||||
F5 = '<F5>',
|
||||
F6 = '<F6>',
|
||||
F7 = '<F7>',
|
||||
F8 = '<F8>',
|
||||
F9 = '<F9>',
|
||||
F10 = '<F10>',
|
||||
F11 = '<F11>',
|
||||
F12 = '<F12>',
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
-- Document existing key chains
|
||||
wk.add {
|
||||
{ '<leader>c', group = '[C]ode' },
|
||||
{ '<leader>d', group = '[D]ocument/[D]ebug' },
|
||||
{ '<leader>r', group = '[R]ename' },
|
||||
{ '<leader>s', group = '[S]earch' },
|
||||
{ '<leader>w', group = '[W]orkspace' },
|
||||
{ '<leader>t', group = '[T]oggle' },
|
||||
{ '<leader>g', group = '[G]it' },
|
||||
{ '<leader>h', group = 'Git [H]unk', mode = { 'n', 'v' } },
|
||||
}
|
||||
end
|
||||
|
||||
return M
|
||||
Loading…
Add table
Add a link
Reference in a new issue