From 8802b654c9ddfa8ad84217663c8e3c158b0600ed Mon Sep 17 00:00:00 2001 From: dlond Date: Tue, 2 Sep 2025 19:24:05 +1200 Subject: [PATCH] fix: clangd config --- KEYBIND_ANALYSIS.md | 227 ----------------------------- lua/custom/plugins/blink.lua | 0 lua/custom/plugins/copilot.lua | 0 lua/plugins/config/lsp/servers.lua | 49 ++++--- 4 files changed, 27 insertions(+), 249 deletions(-) delete mode 100644 KEYBIND_ANALYSIS.md delete mode 100644 lua/custom/plugins/blink.lua delete mode 100644 lua/custom/plugins/copilot.lua diff --git a/KEYBIND_ANALYSIS.md b/KEYBIND_ANALYSIS.md deleted file mode 100644 index baebc632..00000000 --- a/KEYBIND_ANALYSIS.md +++ /dev/null @@ -1,227 +0,0 @@ -# Neovim Keybind Analysis - -## Current Active Keybindings (Modular Config) - -### Leader Key -- **Leader**: `` (Fixed: was missing from config!) - -### Core Navigation & Editing -- `` - Clear search highlights (in normal mode) -- `q` - Open diagnostic quickfix list -- `` - Exit terminal mode (in terminal) - -### Window/Tmux Navigation -- `` - Navigate to left window/tmux pane -- `` - Navigate to down window/tmux pane -- `` - Navigate to up window/tmux pane -- `` - Navigate to right window/tmux pane -- `` - Navigate to previous tmux pane - -### Search & Files (`s*`) -- `sf` - **[S]earch [F]iles** - Find files in project -- `sg` - **[S]earch by [G]rep** - Live grep search -- `sh` - **[S]earch [H]elp** - Search help documentation -- `sk` - **[S]earch [K]eymaps** - Browse all keymaps -- `ss` - **[S]earch [S]elect Telescope** - Telescope picker -- `sw` - **[S]earch current [W]ord** - Search word under cursor -- `sd` - **[S]earch [D]iagnostics** - Browse diagnostics -- `sr` - **[S]earch [R]esume** - Resume last search -- `s.` - **[S]earch Recent Files** - Recently opened files -- `s/` - **[S]earch in Open Files** - Grep in open buffers -- `sn` - **[S]earch [N]eovim files** - Browse config files -- `/` - **Fuzzy search in current buffer** -- `` - **Find existing buffers** - -### LSP Operations -- `gd` - **[G]oto [D]efinition** -- `grr` - **[G]oto [R]eferences** -- `gri` - **[G]oto [I]mplementation** -- `grD` - **[G]oto [D]eclaration** -- `grt` - **[G]oto [T]ype definition** -- `grn` - **[G]oto [R]e[n]ame** - Rename symbol -- `gra` - **[G]oto code [A]ction** (also works in visual mode) -- `gO` - **[G]oto [O]pen document symbols** -- `gW` - **[G]oto [W]orkspace symbols** -- `K` - **Hover Documentation** -- `f` - **[F]ormat buffer** -- `lr` - **[L]SP [R]eload** all servers - -### Diagnostics -- `[d` - Previous diagnostic message -- `]d` - Next diagnostic message -- `e` - Show diagnostic error messages (float) -- `q` - Open diagnostic quickfix list - -### Git Operations (`g*`) -#### Fugitive Commands -- `gs` - **[G]it [S]tatus** - Open Git status -- `gd` - **[G]it [D]iff** - Show diff -- `gc` - **[G]it [C]ommit** - Create commit -- `gb` - **[G]it [B]lame** - Show blame -- `gl` - **[G]it [L]og** - View log -- `gp` - **[G]it [P]ush** - Push changes -- `gf` - **[G]it [F]etch** - Fetch from remote - -#### Gitsigns Hunks (`h*`) -- `]c` - Jump to next git change -- `[c` - Jump to previous git change -- `hs` - **[H]unk [S]tage** - Stage current hunk -- `hr` - **[H]unk [R]eset** - Reset current hunk -- `hS` - **[H]unk [S]tage buffer** - Stage entire buffer -- `hu` - **[H]unk [U]ndo stage** - Undo stage hunk -- `hR` - **[H]unk [R]eset buffer** - Reset entire buffer -- `hp` - **[H]unk [P]review** - Preview hunk changes -- `hb` - **[H]unk [B]lame line** - Show blame for line -- `hd` - **[H]unk [D]iff** - Diff against index -- `hD` - **[H]unk [D]iff** - Diff against last commit -- `tb` - **[T]oggle [B]lame line** - Toggle inline blame -- `tD` - **[T]oggle [D]eleted** - Toggle deleted lines - -### Debug Operations (DAP) -- `` - **Start/Continue** debugging -- `` - **Step Over** -- `` - **Step Into** -- `` - **Step Out** -- `` - **Toggle Debug UI** -- `db` - **[D]ebug [B]reakpoint** - Toggle breakpoint -- `dB` - **[D]ebug [B]reakpoint** - Set conditional -- `lp` - **[L]og [P]oint** - Set log point message -- `de` - **[D]ebug [E]val** - Evaluate expression -- `dr` - **[D]ebug [R]EPL** - Open REPL -- `dl` - **[D]ebug [L]ast** - Run last debug session -- `dh` - **[D]ebug [H]over** - Hover variables -- `ds` - **[D]ebug [S]copes** - View scopes -- `df` - **[D]ebug [F]rames** - View call frames -- `dt` - **[D]ebug [T]erminate** - Terminate session -- `dc` - **[D]ebug [C]ontinue** - Continue to cursor - -### Completion (Blink.cmp) -- `` - Trigger/Show completion -- `` - Accept completion -- `` - Cancel/Hide completion -- `` - Select next item -- `` - Select previous item -- `` - Scroll documentation up -- `` - Scroll documentation down -- `` - Next snippet placeholder -- `` - Previous snippet placeholder - -### GitHub Copilot -**Integration**: Copilot is installed (`zbirenbaum/copilot.lua`) and integrated with Blink.cmp. -- Copilot suggestions appear automatically in the completion menu -- Inline ghost text is disabled (handled by Blink.cmp instead) -- Use standard Blink.cmp keybindings to accept Copilot suggestions - -Copilot commands: -- `:Copilot auth` - Authenticate with GitHub -- `:Copilot status` - Check Copilot status -- `:Copilot disable` - Disable Copilot -- `:Copilot enable` - Enable Copilot - -### Text Objects (Mini.ai) -Enhanced text objects for better selection: -- `a` - Around (e.g., `daw` = delete around word) -- `i` - Inside (e.g., `ci"` = change inside quotes) -Common targets: -- `w` - Word -- `W` - WORD (includes punctuation) -- `p` - Paragraph -- `s` - Sentence -- `(`, `)`, `[`, `]`, `{`, `}` - Brackets -- `'`, `"`, `` ` `` - Quotes -- `<`, `>` - Angle brackets -- `t` - Tag (HTML/XML) - -### Surround Operations (Mini.surround) -Default mappings: -- `sa` - Add surrounding (e.g., `saiw"` = surround word with quotes) -- `sd` - Delete surrounding (e.g., `sd"` = delete surrounding quotes) -- `sr` - Replace surrounding (e.g., `sr"'` = replace " with ') -- `sf` - Find surrounding -- `sF` - Find surrounding (left) -- `sh` - Highlight surrounding -- `sn` - Update MiniSurround.config.n_lines - -### Comments (Comment.nvim) -- `gcc` - Toggle comment on current line -- `gc` - Toggle comment (motion/visual mode) -- `gbc` - Toggle block comment on current line -- `gb` - Toggle block comment (motion/visual mode) -Examples: -- `gcap` - Comment a paragraph -- `gc3j` - Comment current line and 3 lines below -- Visual mode: Select lines then `gc` to toggle - -### Autopairs (nvim-autopairs) -Automatic bracket/quote pairing: -- When typing `(`, `[`, `{`, `'`, `"`, or `` ` ``, the closing pair is automatically inserted -- Pressing `` between pairs expands them properly -- Backspace removes both opening and closing pairs - -### Indent Line (indent-blankline.nvim) -Visual indent guides are automatically shown - no keybindings needed - -### Vim Sleuth -Automatically detects and sets indentation settings - no keybindings needed - -### Illuminate (vim-illuminate) -Automatically highlights other occurrences of word under cursor - no keybindings needed -Navigation between occurrences: -- `` or `]]` - Next occurrence (if configured) -- `` or `[[` - Previous occurrence (if configured) - -### Visual Feedback -- **Yank Highlighting** - Text flashes when yanked/copied (automatic) -- **Cursor Line** - Current line is highlighted -- **Search Highlighting** - Search results are highlighted (clear with ``) - -### System Integration -- **Clipboard** - System clipboard integration enabled (yank/paste works with OS) -- **Mouse** - Full mouse support in all modes -- **Undo** - Persistent undo history across sessions - -### Which-Key Groups -Groups that organize keybindings: -- `c` - **[C]ode** operations -- `d` - **[D]ocument/[D]ebug** operations -- `g` - **[G]it** operations -- `h` - **Git [H]unk** operations -- `r` - **[R]ename** operations -- `s` - **[S]earch** operations -- `t` - **[T]oggle** operations -- `w` - **[W]orkspace** operations - -## Keybinding Architecture - -### Organization Pattern -1. **Leader-based commands** - Most actions use `` (Space) -2. **Mnemonic prefixes** - First letter usually matches action (s=search, g=git, d=debug) -3. **LSP shortcuts** - Use `g` prefix for goto operations -4. **Function keys** - Reserved for debugging (F5, F7, F10-F12) -5. **Control combos** - Navigation and completion - -### Configuration Locations -- **Core keymaps**: `lua/core/keymaps.lua` (custom LSP reload) -- **Kickstart defaults**: Built into respective plugin configurations -- **LSP keymaps**: `lua/plugins/config/lsp/keymaps.lua` -- **Telescope keymaps**: `lua/plugins/config/telescope.lua` -- **Git keymaps**: `lua/plugins/config/git.lua` -- **Debug keymaps**: `lua/plugins/config/debug/keymaps.lua` -- **Tmux navigation**: `lua/plugins/spec/nvim-tmux-navigator.lua` -- **Blink.cmp keymaps**: `lua/plugins/config/blink.lua` -- **Editor enhancements**: `lua/plugins/config/editor.lua` (Mini.nvim modules) -- **Which-key groups**: `lua/plugins/config/ui.lua` - -## Tips for Learning Keybindings - -1. **Use Which-key**: Press `` and wait to see available options -2. **Search keymaps**: Use `sk` to search all keybindings -3. **Mnemonic patterns**: Most bindings follow logical patterns (s=search, g=git, etc.) -4. **Check `:checkhealth core`**: Verify all features are working - -## Customization Guide - -To add new keybindings: -1. For general keymaps: Edit `lua/core/keymaps.lua` -2. For plugin-specific: Add to the relevant config file in `lua/plugins/config/` -3. Update Which-key groups in `lua/plugins/config/ui.lua` if adding new categories \ No newline at end of file diff --git a/lua/custom/plugins/blink.lua b/lua/custom/plugins/blink.lua deleted file mode 100644 index e69de29b..00000000 diff --git a/lua/custom/plugins/copilot.lua b/lua/custom/plugins/copilot.lua deleted file mode 100644 index e69de29b..00000000 diff --git a/lua/plugins/config/lsp/servers.lua b/lua/plugins/config/lsp/servers.lua index 28d717d3..3f761eb5 100644 --- a/lua/plugins/config/lsp/servers.lua +++ b/lua/plugins/config/lsp/servers.lua @@ -28,27 +28,31 @@ function M.get_servers() clangd = { cmd = { 'clangd', + '--query-driver=' .. get_clangd_query_driver(), '--background-index', '--clang-tidy', - '--header-insertion=never', - '--query-driver=' .. get_clangd_query_driver(), - -- Remove hardcoded build dir - clangd will search for compile_commands.json - -- in the current directory and all parent directories by default - '--resource-dir=' .. get_clang_resource_dir(), - -- Help clangd find system headers + '--enable-config', '--fallback-style=llvm', + '--function-arg-placeholders', + '--header-insertion-decorators', + '--header-insertion=iwyu', }, filetypes = { 'c', 'cpp', 'objc', 'objcpp', 'cuda' }, - -- First check for compile_commands.json in build/, then at root, then other markers - root_dir = function(fname) - -- Look for compile_commands.json in build/ first - local build_dir = util.root_pattern('build/compile_commands.json')(fname) - if build_dir then - return build_dir - end - -- Then look for it at project root or other markers - return util.root_pattern('compile_commands.json', 'compile_flags.txt', '.clangd', 'CMakeLists.txt', '.git')(fname) - end, + -- Look for project markers - clangd will find compile_commands.json itself + root_dir = util.root_pattern( + -- First check for any compile_commands.json anywhere + 'compile_commands.json', + -- Then check common build directories + 'build/compile_commands.json', + 'Debug/compile_commands.json', + 'Release/compile_commands.json', + -- Project markers + '.clangd', + 'compile_flags.txt', + 'CMakeLists.txt', + 'Makefile', + '.git' + ), single_file_support = true, }, @@ -66,23 +70,23 @@ function M.get_servers() }, 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 = { @@ -97,4 +101,5 @@ function M.get_servers() } end -return M \ No newline at end of file +return M +