From 7e75253e061c00996ba4805a5bb02a1231968548 Mon Sep 17 00:00:00 2001 From: codepuncher Date: Mon, 20 May 2024 11:15:41 +0100 Subject: [PATCH] fix(nvim): nvim `0.10`, update `nvim-ts-autotag`, add blade TS parser --- nvim/after/queries/blade/highlights.scm | 9 ++++++ nvim/after/queries/blade/injections.scm | 4 +++ nvim/ftdetect/blade.vim | 4 ++- nvim/lua/plugins/configs/nvim-ts-autotag.lua | 6 +++- nvim/lua/plugins/configs/treesitter.lua | 30 +++++++++++++------- 5 files changed, 41 insertions(+), 12 deletions(-) create mode 100644 nvim/after/queries/blade/highlights.scm create mode 100644 nvim/after/queries/blade/injections.scm diff --git a/nvim/after/queries/blade/highlights.scm b/nvim/after/queries/blade/highlights.scm new file mode 100644 index 0000000..9edc25f --- /dev/null +++ b/nvim/after/queries/blade/highlights.scm @@ -0,0 +1,9 @@ +(directive) @function +(directive_start) @function +(directive_end) @function +(comment) @comment +((parameter) @include (#set! "priority" 110)) +((php_only) @include (#set! "priority" 110)) +((bracket_start) @function (#set! "priority" 120)) +((bracket_end) @function (#set! "priority" 120)) +(keyword) @function diff --git a/nvim/after/queries/blade/injections.scm b/nvim/after/queries/blade/injections.scm new file mode 100644 index 0000000..8f7af78 --- /dev/null +++ b/nvim/after/queries/blade/injections.scm @@ -0,0 +1,4 @@ +((text) @injection.content + (#not-has-ancestor? @injection.content "envoy") + (#set! injection.combined) + (#set! injection.language php)) diff --git a/nvim/ftdetect/blade.vim b/nvim/ftdetect/blade.vim index eb4f923..df4716d 100644 --- a/nvim/ftdetect/blade.vim +++ b/nvim/ftdetect/blade.vim @@ -1 +1,3 @@ -au BufRead,BufNewFile *.blade.php set filetype=blade +augroup BladeFiltypeRelated + au BufRead,BufNewFile *.blade.php set filetype=blade +augroup END diff --git a/nvim/lua/plugins/configs/nvim-ts-autotag.lua b/nvim/lua/plugins/configs/nvim-ts-autotag.lua index d5b1a5e..ab7b7cd 100644 --- a/nvim/lua/plugins/configs/nvim-ts-autotag.lua +++ b/nvim/lua/plugins/configs/nvim-ts-autotag.lua @@ -4,7 +4,11 @@ if not _plugin then end plugin.setup({ - enable = true, + opts = { + enable_close = true, + enable_rename = true, + enable_close_on_slash = true, + }, filetypes = { 'blade', --Not working 'html', diff --git a/nvim/lua/plugins/configs/treesitter.lua b/nvim/lua/plugins/configs/treesitter.lua index af224e9..bb99bdf 100644 --- a/nvim/lua/plugins/configs/treesitter.lua +++ b/nvim/lua/plugins/configs/treesitter.lua @@ -4,9 +4,6 @@ if not _plugin then end plugin.setup({ - autotag = { - enable = true, - }, highlight = { enable = true, disable = {}, @@ -36,10 +33,12 @@ plugin.setup({ }, ensure_installed = { 'bash', + 'blade', 'css', 'go', 'html', 'hurl', + 'hurl', 'javascript', 'jsdoc', 'json', @@ -60,19 +59,30 @@ plugin.setup({ }, }) -local parser_config = require "nvim-treesitter.parsers".get_parser_configs() +local parser_config = require('nvim-treesitter.parsers').get_parser_configs() parser_config.hurl = { install_info = { - url = "~/Code/misc/tree-sitter-hurl", -- or your own path, i.e. where you cloned the repository - files = { "src/parser.c" }, - branch = "main", + url = '~/Code/misc/tree-sitter-hurl', -- or your own path, i.e. where you cloned the repository + files = { 'src/parser.c' }, + branch = 'main', generate_requires_npm = false, requires_generate_from_grammar = false, }, - filetype = "hurl", + filetype = 'hurl', } + +parser_config.blade = { + install_info = { + url = 'https://github.com/EmranMR/tree-sitter-blade', + files = { 'src/parser.c' }, + branch = 'main', + }, + filetype = 'blade', +} + vim.filetype.add({ extension = { - hurl = "hurl" - } + hurl = 'hurl', + blade = 'blade', + }, })