diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 00000000..221e4241 --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,80 @@ +# CLAUDE.md + +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. + +## Overview + +Kickstart-based Neovim config using lazy.nvim as the plugin manager. Single `init.lua` + modular custom plugins under `lua/custom/plugins/`. + +## Plugin Manager + +lazy.nvim — plugins defined as lazy specs (`return { "owner/repo", ... }`). + +Update plugins: `:Lazy update` +Check status: `:Lazy` +Install/manage LSP tools: `:Mason` + +## Structure + +``` +init.lua — Sections 1–9: foundation → plugins +lua/custom/plugins/init.lua — Auto-loads all *.lua files in same dir +lua/custom/plugins/*.lua — User-added plugins (no merge conflicts from upstream) +lua/kickstart/plugins/*.lua — Optional kickstart examples (indent_line, lint, gitsigns) +lazy-lock.json — Lockfile (commit this) +``` + +`init.lua` is organized into `do...end` blocks by section: +1. Foundation (options, keymaps, autocmds) +2. lazy.nvim bootstrap + setup +3. UI/UX (gitsigns, which-key, mini.nvim, todo-comments) +4. Search/Navigation (Telescope) +5. LSP (mason, nvim-lspconfig, fidget) +6. Formatting (conform.nvim) +7. Autocomplete & Snippets (blink.cmp + LuaSnip) +8. Treesitter +9. Optional examples + +## Custom Plugins + +| File | Purpose | +|------|---------| +| `claude.lua` | claudecode.nvim — `a*` keymaps; depends on snacks.nvim | +| `lsp.lua` | dbt language server config for SQL/YAML files | +| `markdown.lua` | live-preview.nvim | +| `notebook.lua` | molten-nvim (Jupyter), image.nvim (magick_cli), wezterm.nvim | +| `oil.lua` | oil.nvim file manager via mini.icons | +| `themes.lua` | gruvbox-medium (active), tokyonight (installed) | +| `toggle-term.lua` | toggleterm.nvim terminal toggle | + +## LSP + +Servers are configured in `init.lua:670` via `vim.lsp.config(name, server)` + `vim.lsp.enable(name)`. +Custom dbt server lives in `lua/custom/plugins/lsp.lua` — requires `dbt-language-server` in `$PATH`. +Lua formatting disabled in `lua_ls`; formatting delegated to `stylua` via conform.nvim. + +## Key Bindings (leader = ``) + +- `s*` — Telescope search +- `f` — format buffer (conform) +- `a*` — Claude Code integration +- `h*` — gitsigns hunk operations +- `t*` — toggles (inlay hints, blame, word diff) +- `gr*` — LSP actions (rename, code action, references, definitions) + +## Adding Plugins + +Drop a `.lua` file in `lua/custom/plugins/` — auto-required on next start. Use the lazy spec pattern: + +```lua +return { + "owner/repo", + opts = {}, +} +``` + +## Formatting & Linting + +- **Formatter**: conform.nvim — `f` to format; auto-format on save disabled by default (opt-in per filetype in `init.lua:760`) +- **Linter**: nvim-lint — runs on `BufEnter`/`BufWritePost`/`InsertLeave`; markdownlint for markdown +- **Treesitter**: auto-installs parsers on `FileType` event diff --git a/init.lua b/init.lua index 62496363..47a95bff 100644 --- a/init.lua +++ b/init.lua @@ -506,27 +506,39 @@ require('lazy').setup({ { 'stevearc/conform.nvim', config = function() + local prettier_ft = { + 'javascript', + 'javascriptreact', + 'typescript', + 'typescriptreact', + 'vue', + 'css', + 'scss', + 'less', + 'html', + 'json', + 'jsonc', + 'yaml', + 'markdown', + 'graphql', + } + local formatters_by_ft = {} + for _, ft in ipairs(prettier_ft) do + formatters_by_ft[ft] = { 'prettierd', 'prettier', stop_after_first = true } + end + require('conform').setup { notify_on_error = false, format_on_save = function(bufnr) - local enabled_filetypes = { - -- lua = true, - -- python = true, - } - if enabled_filetypes[vim.bo[bufnr].filetype] then - return { timeout_ms = 500 } - else - return nil + if formatters_by_ft[vim.bo[bufnr].filetype] then + return { timeout_ms = 500, lsp_format = 'fallback' } end + return nil end, default_format_opts = { lsp_format = 'fallback', }, - formatters_by_ft = { - -- rust = { 'rustfmt' }, - -- python = { "isort", "black" }, - -- javascript = { "prettierd", "prettier", stop_after_first = true }, - }, + formatters_by_ft = formatters_by_ft, } vim.keymap.set({ 'n', 'v' }, 'f', function() require('conform').format { async = true } end, { desc = '[F]ormat buffer' }) end, diff --git a/lazy-lock.json b/lazy-lock.json index 2c6cad0d..c6d163a9 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -12,6 +12,7 @@ "indent-blankline.nvim": { "branch": "master", "commit": "d28a3f70721c79e3c5f6693057ae929f3d9c0a03" }, "lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" }, "live-preview.nvim": { "branch": "main", "commit": "c1fcf75c5f9c9c01dd392852de44204b60f1b5b1" }, + "lsp_lines.nvim": { "branch": "main", "commit": "3b57922d2d79762e6baedaf9d66d8ba71f822816" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "7b01e2974a47d489bb92f47a41e4c0088ea8f86e" }, "mason-tool-installer.nvim": { "branch": "main", "commit": "443f1ef8b5e6bf47045cb2217b6f748a223cf7dc" }, "mason.nvim": { "branch": "main", "commit": "bb639d4bf385a4d89f478b83af4d770be05ab7eb" }, diff --git a/lua/custom/plugins/lsp_lines.lua b/lua/custom/plugins/lsp_lines.lua new file mode 100644 index 00000000..1bf0d29f --- /dev/null +++ b/lua/custom/plugins/lsp_lines.lua @@ -0,0 +1,21 @@ +return { + "ErichDonGubler/lsp_lines.nvim", + config = function() + require("lsp_lines").setup() + + -- Disable default virtual text to prevent overlapping/duplicate diagnostic lines + vim.diagnostic.config({ + virtual_text = false, + }) + end, + -- Keymap to toggle lsp_lines + keys = { + { + "ll", + function() + require("lsp_lines").toggle() + end, + desc = "Toggle lsp_lines", + }, + }, +}