diff --git a/docs/manual.nix b/docs/manual.nix index 60550b14..10f586c2 100644 --- a/docs/manual.nix +++ b/docs/manual.nix @@ -4,6 +4,7 @@ stdenvNoCC, optionsJSON, jaq, + gnused, } @ args: let manual-release = args.release or "unstable"; in @@ -18,6 +19,7 @@ in doCheck = false; }) jaq + gnused ]; patchPhase = '' @@ -37,6 +39,23 @@ in ''; buildPhase = '' + mkdir -p queries/nix + + # apply nix injections + sed -n -f /dev/stdin ${../modules/plugins/languages/nix.nix} <<'EOF' > ./queries/nix/injections.scm + /type = "injections"/,/^[[:space:]]*};/ { + /query = '''/,/^[[:space:]]*''';/ { + /query = '''/d + /^[[:space:]]*''';/d + p + } + } + EOF + + # Syntactica doesnt support `query` so we patch it with the closest it does, + # which is `haskell` :bwaa: + sed -i 's|#set! injection\.language "query"|#set! injection.language "haskell"|' ./queries/nix/injections.scm + # Generate the final manual from a set of parameters. This uses # feel-co/ndg to render the web manual. ndg --config-file ${./ndg.toml} html \ diff --git a/docs/manual/configuring/autocmds.md b/docs/manual/configuring/autocmds.md index e547ace2..2f6cf315 100644 --- a/docs/manual/configuring/autocmds.md +++ b/docs/manual/configuring/autocmds.md @@ -60,8 +60,9 @@ Vimscript) for the same autocommand. Choose one. **Examples:** ```nix -{ lib, ... }: -{ +{ lib, ... }: let + inherit (lib.generators) mkLuaInline; +in { vim.augroups = [ { name = "UserSetup"; } ]; vim.autocmds = [ @@ -71,7 +72,7 @@ Vimscript) for the same autocommand. Choose one. pattern = [ "*.lua" ]; group = "UserSetup"; desc = "Notify after saving Lua file"; - callback = lib.generators.mkLuaInline '' + callback = mkLuaInline '' function() vim.notify("Lua file saved!", vim.log.levels.INFO) end @@ -101,7 +102,7 @@ Vimscript) for the same autocommand. Choose one. event = [ "BufWinEnter" ]; pattern = [ "*" ]; desc = "Simple greeting on entering a buffer window"; - callback = lib.generators.mkLuaInline '' + callback = mkLuaInline '' function(args) print("Entered buffer: " .. args.buf) end diff --git a/docs/manual/configuring/custom-plugins/legacy-method.md b/docs/manual/configuring/custom-plugins/legacy-method.md index f4976e5f..41dc504f 100644 --- a/docs/manual/configuring/custom-plugins/legacy-method.md +++ b/docs/manual/configuring/custom-plugins/legacy-method.md @@ -36,7 +36,7 @@ order to configure the added plugin, in { # luaConfigRC takes Lua configuration verbatim and inserts it at an arbitrary # position by default or if 'entryAnywhere' is used. - vim.luaConfigRC.aerial-nvim= entryAnywhere '' + vim.luaConfigRC.aerial-nvim = entryAnywhere '' require('aerial').setup { -- your configuration here } diff --git a/docs/manual/configuring/queries.md b/docs/manual/configuring/queries.md index 866fbd8e..5359475c 100644 --- a/docs/manual/configuring/queries.md +++ b/docs/manual/configuring/queries.md @@ -10,11 +10,15 @@ In the following example, we are creating a custom injection, to highlight the Lua string after `mkLuaInline`. ```nix -foo = mkLuaInline '' - function bar() - return 'foobar' - end -''; +let + inherit (lib.generators) mkLuaInline; +in { + foo = mkLuaInline '' + function bar() + return 'foobar' + end + ''; +} ``` ```nix diff --git a/docs/manual/hacking.md b/docs/manual/hacking.md index 72ad528f..191a6dfe 100644 --- a/docs/manual/hacking.md +++ b/docs/manual/hacking.md @@ -650,9 +650,11 @@ As you've seen above, `toLuaObject` is used to convert our nix attrSet that return specific values as expected by the plugins. ```nix - { + let + inherit (lib.generators) mkLuaInline; + in { vim.your-plugin.setupOpts = { - on_init = lib.generators.mkLuaInline '' + on_init = mkLuaInline '' function() print('we can write lua!') end diff --git a/docs/manual/release-notes/rl-0.9.md b/docs/manual/release-notes/rl-0.9.md index ce0e34a4..134a15d2 100644 --- a/docs/manual/release-notes/rl-0.9.md +++ b/docs/manual/release-notes/rl-0.9.md @@ -323,6 +323,8 @@ [Snoweuph](https://github.com/snoweuph) +- Use nvf nix Tree-sitter injections in the docs. + - Allow the usage of `pks.tree-sitter-grammars` in {option}`vim.treesitter.grammars` and language module tree-sitter package options created via `mkGrammarOption`. diff --git a/docs/ndg.toml b/docs/ndg.toml index 7105c709..10e65fb2 100644 --- a/docs/ndg.toml +++ b/docs/ndg.toml @@ -14,6 +14,9 @@ footer_text = "Generated with ndg" generate_anchors = true +# For our custom queries +syntax_queries_path = "queries" + # Search configuration [search] enable = true diff --git a/modules/plugins/treesitter/treesitter.nix b/modules/plugins/treesitter/treesitter.nix index 876ee9e9..05239107 100644 --- a/modules/plugins/treesitter/treesitter.nix +++ b/modules/plugins/treesitter/treesitter.nix @@ -3,7 +3,7 @@ lib, ... }: let - inherit (lib.options) mkOption mkEnableOption literalExpression; + inherit (lib.options) mkOption mkEnableOption literalExpression literalMD; inherit (lib.types) listOf nullOr package bool str lines enum submodule oneOf attrsOf; queriesType = submodule { @@ -20,6 +20,26 @@ query = mkOption { type = lines; description = "The queries scm script."; + example = literalMD '' + ```nix + { + query = ''' + ;; extends + + ((apply_expression + function: (variable_expression + name: (identifier) @_func + (#eq? @_func "mkLuaInline")) + + argument: (indented_string_expression + (string_fragment) @injection.content) + + (#set! injection.language "lua") + (#set! injection.combined))) + '''; + } + ``` + ''; }; }; };