refactor(editor): modularize neovim config, add dap support, and unify tmux setup

- Neovim: Modularize configuration into `init.lua`, `lsp.lua`, and `dap.lua`.
- Neovim: Introduce DAP (Debug Adapter Protocol) setup with `nvim-dap` and `nvim-dap-ui` for Python, Rust, and JS/TS.
- Neovim: Add seamless Neovim/Tmux pane navigation (`Ctrl-h/j/k/l`) and window split helpers (`|`, `-`).
- Tmux: Migrate settings to a declarative `tmux.conf` file with `Ctrl+Space` prefix, vi copy mode, and OSC 52 clipboard support.
- Graphical: Expand tree-sitter parsers and declaratively mount Neovim config modules.
This commit is contained in:
kiskaadee committed 2026-08-21 08:18:10 -05:00
1 parent 687bb8fd71
commit 437773fe0f
6 files changed
+311 -33

No files matched your search

+100
View File
@@ -0,0 +1,100 @@
-- Debug Adapter Protocol (DAP) Setup for Neovim
local ok, dap = pcall(require, 'dap')
if not ok then
return
end
-- 1. Standard Debug Keybindings
vim.keymap.set('n', '<F5>', function() dap.continue() end, { desc = 'Debug: Start/Continue' })
vim.keymap.set('n', '<F9>', function() dap.toggle_breakpoint() end, { desc = 'Debug: Toggle Breakpoint' })
vim.keymap.set('n', '<F10>', function() dap.step_over() end, { desc = 'Debug: Step Over' })
vim.keymap.set('n', '<F11>', function() dap.step_into() end, { desc = 'Debug: Step Into' })
vim.keymap.set('n', '<F12>', function() dap.step_out() end, { desc = 'Debug: Step Out' })
vim.keymap.set('n', '<leader>b', function() dap.toggle_breakpoint() end, { desc = 'Debug: Toggle Breakpoint' })
vim.keymap.set('n', '<leader>B', function()
vim.ui.input({ prompt = 'Breakpoint Condition: ' }, function(input)
if input then dap.set_breakpoint(input) end
end)
end, { desc = 'Debug: Conditional Breakpoint' })
vim.keymap.set('n', '<leader>dr', function() dap.repl.open() end, { desc = 'Debug: Open REPL' })
vim.keymap.set('n', '<leader>dl', function() dap.run_last() end, { desc = 'Debug: Run Last' })
-- 2. Debug UI Integration (if nvim-dap-ui is installed)
local ui_ok, dapui = pcall(require, 'dapui')
if ui_ok then
dapui.setup()
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
vim.keymap.set('n', '<leader>du', function() dapui.toggle() end, { desc = 'Debug: Toggle UI' })
end
-- 3. Language Debug Adapters
-- Python Debugging (via debugpy)
dap.adapters.python = {
type = 'executable',
command = 'python',
args = { '-m', 'debugpy.adapter' },
}
dap.configurations.python = {
{
type = 'python',
request = 'launch',
name = 'Launch File',
program = '${file}',
pythonPath = function()
local venv = vim.fn.getenv('VIRTUAL_ENV')
if venv ~= vim.NIL and venv ~= '' then
return venv .. '/bin/python'
end
return '/usr/bin/python'
end,
},
}
-- Rust / C / C++ Debugging (via codelldb / gdb)
dap.adapters.codelldb = {
type = 'server',
port = '${port}',
executable = {
command = 'codelldb',
args = { '--port', '${port}' },
},
}
dap.configurations.rust = {
{
name = 'Launch Rust Binary',
type = 'codelldb',
request = 'launch',
program = function()
return vim.fn.input('Path to executable: ', vim.fn.getcwd() .. '/target/debug/', 'file')
end,
cwd = '${workspaceFolder}',
stopOnEntry = false,
},
}
-- JavaScript / TypeScript Debugging (via node / pwa-node)
dap.adapters.node2 = {
type = 'executable',
command = 'node',
args = { vim.fn.stdpath('data') .. '/mason/packages/node-debug2-adapter/out/src/nodeDebug.js' },
}
dap.configurations.javascript = {
{
name = 'Launch Node File',
type = 'node2',
request = 'launch',
program = '${file}',
cwd = '${workspaceFolder}',
},
}
dap.configurations.typescript = dap.configurations.javascript
+72
View File
@@ -1,3 +1,7 @@
-- =============================================================================
-- Editor Configuration
-- =============================================================================
vim.opt.number = true -- Show line numbers
vim.opt.relativenumber = true -- Relative line numbers for easier navigation jumps
vim.opt.shiftwidth = 2 -- 2-space indents
@@ -8,6 +12,13 @@ vim.opt.wrap = false -- Disable automatic line wrapping
vim.opt.termguicolors = true -- Enable 24-bit RGB terminal colors
vim.opt.completeopt = { "menu", "menuone", "noinsert" } -- Smooth auto-completion behavior
-- Enable autoread so external file changes are recognized
vim.opt.autoread = true
-- =============================================================================
-- Completion
-- =============================================================================
-- Accept completion with Tab when the completion menu is visible
vim.keymap.set('i', '<Tab>', function()
if vim.fn.pumvisible() == 1 then
@@ -17,3 +28,64 @@ vim.keymap.set('i', '<Tab>', function()
end
end, { expr = true, silent = true })
-- =============================================================================
-- Window / Tmux Seamless Navigation (Ctrl-h/j/k/l)
-- =============================================================================
local function navigate(direction, tmux_direction)
local current = vim.api.nvim_get_current_win()
-- Attempt to move within Neovim splits
vim.cmd('wincmd ' .. direction)
-- If Neovim moved to another split, we are done
if vim.api.nvim_get_current_win() ~= current then
return
end
-- If at the boundary and running under tmux, cross into the adjacent tmux pane
if vim.env.TMUX then
vim.fn.system({ 'tmux', 'select-pane', tmux_direction })
end
end
vim.keymap.set('n', '<C-h>', function() navigate('h', '-L') end, { desc = 'Navigate left (Nvim / Tmux)' })
vim.keymap.set('n', '<C-j>', function() navigate('j', '-D') end, { desc = 'Navigate down (Nvim / Tmux)' })
vim.keymap.set('n', '<C-k>', function() navigate('k', '-U') end, { desc = 'Navigate up (Nvim / Tmux)' })
vim.keymap.set('n', '<C-l>', function() navigate('l', '-R') end, { desc = 'Navigate right (Nvim / Tmux)' })
-- =============================================================================
-- Split Creation (Vocabulary matching Tmux: | vertical, - horizontal)
-- =============================================================================
vim.keymap.set('n', '<leader>|', '<cmd>vsplit<CR>', { desc = 'Split vertically' })
vim.keymap.set('n', '<leader>-', '<cmd>split<CR>', { desc = 'Split horizontally' })
vim.keymap.set('n', '<leader>=', '<C-w>=', { desc = 'Equalize split sizes' })
-- =============================================================================
-- External File Changes Synchronization (Focus / BufEnter)
-- =============================================================================
vim.api.nvim_create_autocmd({ 'FocusGained', 'BufEnter', 'CursorHold' }, {
group = vim.api.nvim_create_augroup('CheckExternalChanges', { clear = true }),
callback = function()
if vim.fn.getcmdwintype() == '' then
vim.cmd('checktime')
end
end,
})
-- =============================================================================
-- Load LSP & DAP Modules
-- =============================================================================
local lsp_config_path = vim.fn.stdpath('config') .. '/lsp.lua'
if vim.fn.filereadable(lsp_config_path) == 1 then
dofile(lsp_config_path)
end
local dap_config_path = vim.fn.stdpath('config') .. '/dap.lua'
if vim.fn.filereadable(dap_config_path) == 1 then
dofile(dap_config_path)
end
+15 -15
View File
@@ -1,11 +1,13 @@
-- Minimal Native Neovim LSP Setup (Neovim 0.11+)
-- Python LSP: Pyright (Type checking and navigation)
if vim.lsp.config then
vim.lsp.config('pyright', {})
vim.lsp.enable('pyright')
-- Python LSP: Ruff (Ultra-fast Linting and Auto-formatting)
vim.lsp.config('ruff', {
on_attach = function(client, bufnr)
-- Disable hover provider in Ruff so it doesn't conflict with Pyright
on_attach = function(client)
client.server_capabilities.hoverProvider = false
end,
})
@@ -15,14 +17,6 @@ vim.lsp.enable('ruff')
vim.lsp.config('rust_analyzer', {})
vim.lsp.enable('rust_analyzer')
-- Nix LSP: nixd (Nix Language Server)
vim.lsp.config('nixd', {})
vim.lsp.enable('nixd')
-- Java LSP: Eclipse jdtls
vim.lsp.config('jdtls', {})
vim.lsp.enable('jdtls')
-- TypeScript LSP: ts_ls
vim.lsp.config('ts_ls', {})
vim.lsp.enable('ts_ls')
@@ -31,6 +25,10 @@ vim.lsp.enable('ts_ls')
vim.lsp.config('lua_ls', {})
vim.lsp.enable('lua_ls')
-- Java LSP: Eclipse jdtls
vim.lsp.config('jdtls', {})
vim.lsp.enable('jdtls')
-- TOML LSP: taplo
vim.lsp.config('taplo', {})
vim.lsp.enable('taplo')
@@ -39,14 +37,15 @@ vim.lsp.enable('taplo')
vim.lsp.config('marksman', {})
vim.lsp.enable('marksman')
-- KDL LSP: kdl-lsp (KDL Language Server)
-- Note: Install the server using: cargo install kdl-lsp
-- KDL LSP: kdl-lsp (KDL Language Server for Niri configs)
vim.lsp.config('kdl_lsp', {
cmd = { 'kdl-lsp' },
filetypes = { 'kdl' },
root_markers = { '.git' },
})
vim.lsp.enable('kdl_lsp')
end
-- Configure LSP Keybindings and features on attach
vim.api.nvim_create_autocmd('LspAttach', {
@@ -62,12 +61,13 @@ vim.api.nvim_create_autocmd('LspAttach', {
vim.keymap.set('n', '<leader>ca', vim.lsp.buf.code_action, opts)
vim.keymap.set('n', 'gr', vim.lsp.buf.references, opts)
-- Enable built-in LSP completion (Neovim 0.11+)
if client and client:supports_method('textDocument/completion') then
-- Enable built-in LSP completion
if client and client.supports_method and client:supports_method('textDocument/completion') then
vim.lsp.completion.enable(true, client.id, ev.buf, { autotrigger = true })
end
-- Auto-format on save using Ruff / LSP
-- Auto-format on save using LSP
vim.api.nvim_create_autocmd('BufWritePre', {
buffer = ev.buf,
callback = function()
+108 -5
View File
@@ -1,11 +1,114 @@
# Enable True Color (24-bit RGB) support inside Tmux for editor colorschemes
set -ag terminal-overrides ",xterm-256color:RGB"
# ==============================================================================
# Tmux Configuration
# Neovim / Wayland / Alacritty integration
# ==============================================================================
# Vim-style bindings for switching between active Tmux panes
# ------------------------------------------------------------------------------
# Terminal & Colors
# ------------------------------------------------------------------------------
set -g default-terminal "tmux-256color"
# Advertise true color / RGB support to terminal applications (Neovim, etc.)
set -as terminal-features ',*:RGB'
# 1-based indexing for windows and panes (matches keyboard row 1..9)
set -g base-index 1
setw -g pane-base-index 1
set -g renumber-windows on
# ------------------------------------------------------------------------------
# General Behavior & Flow Control
# ------------------------------------------------------------------------------
set -g mouse on
set -g focus-events on
set -g history-limit 10000
# Zero delay for escape key responsiveness in Vim/Neovim
set -s escape-time 0
# Keep panes at their current size when the window is resized
setw -g aggressive-resize off
# Vim-style status and copy mode navigation
set -g status-keys vi
set -g mode-keys vi
# ------------------------------------------------------------------------------
# Prefix Key (Ctrl-Space)
# ------------------------------------------------------------------------------
unbind C-b
unbind C-s
set -g prefix C-Space
bind C-Space send-prefix
# ------------------------------------------------------------------------------
# Pane Creation (Shared Mental Model: | for vertical, - for horizontal)
# ------------------------------------------------------------------------------
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
unbind '"'
unbind %
# ------------------------------------------------------------------------------
# Seamless Neovim <-> tmux Navigation (Ctrl-h/j/k/l)
# ------------------------------------------------------------------------------
# Smart pane switching with awareness of Vim/Neovim splits.
# When in Neovim, pass Ctrl-h/j/k/l through to Neovim.
# When in shell or at the edge of Neovim, tmux handles pane switching.
is_vim="ps -o state= -o comm= -t '#{pane_tty}' \
| grep -iqE '^[^TXZ ]+ +(\\S+\\/)?g?(view|l?n?vim?x?|fzf)(diff)?$'"
bind-key -n 'C-h' if-shell "$is_vim" 'send-keys C-h' 'select-pane -L'
bind-key -n 'C-j' if-shell "$is_vim" 'send-keys C-j' 'select-pane -D'
bind-key -n 'C-k' if-shell "$is_vim" 'send-keys C-k' 'select-pane -U'
bind-key -n 'C-l' if-shell "$is_vim" 'send-keys C-l' 'select-pane -R'
# Fallback explicit tmux-only navigation via prefix + h/j/k/l
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# Place status bar at the top of the terminal screen rather than the bottom
set-option -g status-position top
# ------------------------------------------------------------------------------
# Pane Resizing (prefix + H/J/K/L)
# ------------------------------------------------------------------------------
bind -r H resize-pane -L 5
bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r L resize-pane -R 5
# ------------------------------------------------------------------------------
# Copy Mode & Clipboard (Vi-Style + OSC 52 Terminal Clipboard)
# ------------------------------------------------------------------------------
bind Escape copy-mode
bind-key -T copy-mode-vi v send-keys -X begin-selection
bind-key -T copy-mode-vi C-v send-keys -X rectangle-toggle
# Copy selection to tmux buffer and system clipboard through OSC 52
bind-key -T copy-mode-vi y send-keys -X copy-selection-and-cancel
# Allow tmux to set the system clipboard via terminal OSC 52 sequences (works locally & over SSH)
set -s set-clipboard on
# ------------------------------------------------------------------------------
# Configuration Reload
# ------------------------------------------------------------------------------
bind r source-file ~/.config/tmux/tmux.conf \; display-message "Tmux config reloaded"
# ------------------------------------------------------------------------------
# UI Adjustments
# ------------------------------------------------------------------------------
set -g status-position top
set -g clock-mode-style 12
+16 -2
View File
@@ -67,19 +67,33 @@
lua
java
javascript
typescript
markdown
kdl
toml
bash
]))
# LSP Configuration & Python Language Servers
# LSP Configuration & Language Servers
{
plugin = nvim-lspconfig;
type = "lua";
config = builtins.readFile ./config/nvim/lsp.lua;
}
# DAP (Debug Adapter Protocol)
{
plugin = nvim-dap;
}
{
plugin = nvim-dap-ui;
}
];
};
# Declarative configuration files for Neovim (lsp.lua & dap.lua loaded dynamically via init.lua)
home.file.".config/nvim/lsp.lua".source = ./config/nvim/lsp.lua;
home.file.".config/nvim/dap.lua".source = ./config/nvim/dap.lua;
# Declarative configuration files for Zed editor
home.file.".config/zed/settings.json".source = ./config/zed/settings.json;
home.file.".config/zed/themes".source = ./config/zed/themes;
-11
View File
@@ -68,17 +68,6 @@
# Allows maintaining persistent shell sessions, window splitting, and tabs.
programs.tmux = {
enable = true;
baseIndex = 1; # Number windows starting at 1
escapeTime = 0; # Remove the default escape delay
mouse = true; # Enables scrollback navigation and pane resizing using the mouse pointer
terminal = "tmux-256color";
plugins = with pkgs.tmuxPlugins; [
catppuccin # Visual styling matching system theme
vim-tmux-navigator # Seamless navigation switching between Vim panes and Tmux splits (Ctrl+h/j/k/l)
];
extraConfig = builtins.readFile ./config/tmux.conf;
};