CLAUDE.md (3500B)
1 # CLAUDE.md 2 3 This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. 4 5 ## What this repo is 6 7 Neovim configuration for daily use with Python, Bash/Shell, Ansible, OpenTofu, and YAML. 8 This directory is symlinked to `~/.config/nvim/`. 9 10 ## Install prerequisites 11 12 ```bash 13 # Core 14 sudo pacman -S neovim nodejs npm 15 16 # System linters and formatters (not managed by Mason) 17 sudo pacman -S shellcheck shfmt python-lsp-server python-ruff ansible-lint yamllint 18 19 # tree-sitter CLI (required by nvim-treesitter to compile yaml/toml/json/hcl parsers) 20 # Neovim 0.12 bundles parsers for bash, lua, python, markdown, vim, vimdoc — no CLI needed for those 21 sudo pacman -S tree-sitter-cli 22 23 # Optional: stylua (Lua formatter for this config) 24 sudo pacman -S stylua 25 ``` 26 27 ## First launch 28 29 Open `nvim` — lazy.nvim bootstraps itself, installs all plugins, then Mason installs LSP servers. 30 Run `:MasonInstall prettier` manually if YAML formatting is needed. 31 32 ## Structure 33 34 ``` 35 init.lua -- entry point: loads core modules, bootstraps lazy.nvim 36 lua/core/ 37 options.lua -- vim options (tabs, search, clipboard, etc.) 38 keymaps.lua -- all non-plugin keymaps 39 autocmds.lua -- filetype detection (yaml.ansible), yank highlight, trim whitespace 40 lua/plugins/ 41 treesitter.lua -- syntax highlighting (python, bash, yaml, hcl, etc.) 42 lsp.lua -- mason + mason-lspconfig + nvim-lspconfig (all servers) 43 completion.lua -- nvim-cmp + LuaSnip + friendly-snippets 44 autopairs.lua -- nvim-autopairs (auto-close brackets/quotes) 45 lint.lua -- nvim-lint (linting) + conform.nvim (formatting) 46 ui.lua -- catppuccin, lualine, nvim-tree, telescope, gitsigns, which-key 47 ``` 48 49 ## LSP servers (auto-installed by Mason) 50 51 | Language | Server | Notes | 52 |---|---|---| 53 | Python | `pylsp` | Uses ruff plugin for linting | 54 | Bash/Shell | `bashls` | Requires Node | 55 | YAML | `yamlls` | Schema store enabled | 56 | Ansible | `ansiblels` | Activates on `yaml.ansible` filetype | 57 | OpenTofu/Terraform | `terraformls` | Works with both | 58 | Lua | `lua_ls` | Configured for Neovim globals | 59 60 ## Ansible file detection 61 62 Files matching `*/tasks/**/*.yml`, `*/handlers/**/*.yml`, `*/roles/**/*.yml`, `*/playbooks/**/*.yml`, 63 `*/group_vars/**`, `*/host_vars/**`, `site.yml`, `playbook.yml` are automatically set to the 64 `yaml.ansible` filetype, which activates `ansiblels` instead of `yamlls`. 65 66 For project-level detection, create a `.ansible-lint` file at the project root. 67 68 ## Key mappings (leader = Space) 69 70 | Key | Action | 71 |---|---| 72 | `<leader>ff` | Find files (Telescope) | 73 | `<leader>fg` | Live grep | 74 | `<leader>fb` | Open buffers | 75 | `<leader>e` | Toggle file explorer | 76 | `<leader>w` | Save | 77 | `<leader>q` | Quit | 78 | `<leader>cf` | Format file | 79 | `<leader>rn` | Rename symbol (LSP) | 80 | `<leader>ca` | Code action (LSP) | 81 | `<leader>d` | Show diagnostic float | 82 | `[d` / `]d` | Prev/next diagnostic | 83 | `gd` | Go to definition | 84 | `K` | Hover documentation | 85 | `<Tab>` | Next completion / jump snippet | 86 87 ## Adding new language support 88 89 1. Add the LSP server name to `ensure_installed` in `lua/plugins/lsp.lua` 90 2. Add a `lspconfig.<server>.setup()` call in the same file 91 3. Add linter entries to `lint.linters_by_ft` in `lua/plugins/lint.lua` 92 4. Add formatter entries to `formatters_by_ft` in `lua/plugins/lint.lua` 93 5. Add the treesitter grammar to `ensure_installed` in `lua/plugins/treesitter.lua`