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.
37 lines
1.3 KiB
Lua
37 lines
1.3 KiB
Lua
-- 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,
|
|
})
|