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.
This commit is contained in:
@@ -30,7 +30,6 @@ frontend/package.json.md5
|
|||||||
# Root-level lockfile only: the frontend lockfile IS tracked so CI installs
|
# Root-level lockfile only: the frontend lockfile IS tracked so CI installs
|
||||||
# are reproducible and setup-node's npm cache has something to hash.
|
# are reproducible and setup-node's npm cache has something to hash.
|
||||||
/package-lock.json
|
/package-lock.json
|
||||||
.idea
|
|
||||||
.env
|
.env
|
||||||
environment.go
|
environment.go
|
||||||
# Updater signing private key. The public half (updater.pub) is committed and
|
# Updater signing private key. The public half (updater.pub) is committed and
|
||||||
|
|||||||
@@ -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,
|
||||||
|
})
|
||||||
@@ -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"))
|
||||||
Reference in New Issue
Block a user