From c0885a4bd59d86790de709f7726c962b9ae6d6ef Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Thu, 24 Sep 2026 13:50:24 -0400 Subject: [PATCH] chore(nvim): track project-local Neovim config, drop .idea from ignore Add .nvim.lua, an opt-in project-local Neovim configuration for LazyVim users. It extends the runtime path with .nvim/ so the treesitter injections ship with the repo, and wires conform to format embedded GraphQL regions (via prettier's injected formatter) alongside goimports/gofumpt on Go buffers. Add .nvim/queries/go/injections.scm, which marks Go raw string literals starting with query/mutation/subscription/fragment as GraphQL injections, so treesitter highlighting and formatting apply to the embedded AniList queries. Remove .idea from .gitignore: the ignore list now deliberately tracks project-local editor configs (.nvim.lua) instead of editor-specific junk. --- .gitignore | 1 - .nvim.lua | 36 +++++++++++++++++++++++++++++++++ .nvim/queries/go/injections.scm | 21 +++++++++++++++++++ 3 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 .nvim.lua create mode 100644 .nvim/queries/go/injections.scm diff --git a/.gitignore b/.gitignore index 3561cef..6cc858d 100644 --- a/.gitignore +++ b/.gitignore @@ -30,7 +30,6 @@ frontend/package.json.md5 # Root-level lockfile only: the frontend lockfile IS tracked so CI installs # are reproducible and setup-node's npm cache has something to hash. /package-lock.json -.idea .env environment.go # Updater signing private key. The public half (updater.pub) is committed and diff --git a/.nvim.lua b/.nvim.lua new file mode 100644 index 0000000..510b0b8 --- /dev/null +++ b/.nvim.lua @@ -0,0 +1,36 @@ +-- AniTrack project-local Neovim config (for LazyVim users) +-- Requires: vim.o.exrc = true in your Neovim config; approve the :trust prompt. +local here = vim.fs.dirname(debug.getinfo(1, "S").source:sub(2)) + +-- project-local treesitter queries (graphql injections for Go raw strings) +vim.opt.rtp:append(here .. "/.nvim") + +vim.api.nvim_create_autocmd("FileType", { + pattern = "go", + once = true, + callback = function() + -- ensure the graphql treesitter parser exists (no-op when already installed) + pcall(function() + local LazyVim = require("lazyvim.util") + if not LazyVim.treesitter.have("graphql") then + require("nvim-treesitter").install({ "graphql" }) + end + end) + -- conform: format embedded graphql regions via prettier (injected formatter) + require("conform").setup({ + formatters_by_ft = { + go = { "goimports", "gofumpt", "injected" }, + graphql = { "prettier" }, + }, + formatters = { + prettier = { + -- conform's injected formatter resolves formatters against the host + -- (go) buffer, so LazyVim's filetype-gated prettier condition would + -- filter it out; safe to relax since prettier is only registered + -- for filetypes it supports. + condition = function() return true end, + }, + }, + }) + end, +}) diff --git a/.nvim/queries/go/injections.scm b/.nvim/queries/go/injections.scm new file mode 100644 index 0000000..155e89e --- /dev/null +++ b/.nvim/queries/go/injections.scm @@ -0,0 +1,21 @@ +; extends + +((raw_string_literal + (raw_string_literal_content) @injection.content) + (#lua-match? @injection.content "^%s*query%f[^%w]") + (#set! injection.language "graphql")) + +((raw_string_literal + (raw_string_literal_content) @injection.content) + (#lua-match? @injection.content "^%s*mutation%f[^%w]") + (#set! injection.language "graphql")) + +((raw_string_literal + (raw_string_literal_content) @injection.content) + (#lua-match? @injection.content "^%s*subscription%f[^%w]") + (#set! injection.language "graphql")) + +((raw_string_literal + (raw_string_literal_content) @injection.content) + (#lua-match? @injection.content "^%s*fragment%f[^%w]") + (#set! injection.language "graphql"))