From 4a839dd82d94ba8f0e6fede96bdbad1fc9cb0274 Mon Sep 17 00:00:00 2001 From: Tovi Jaeschke-Rogers Date: Thu, 6 Jun 2024 08:12:27 +0930 Subject: [PATCH] feat: add blade syntax highlighting --- .config/nvim/lua/tovi/core/autocmd.lua | 5 - .config/nvim/lua/tovi/plugins/linting.lua | 1 + .../nvim/lua/tovi/plugins/nvim-treesitter.lua | 103 +++--------------- .config/nvim/lua/tovi/plugins/vim-blade.lua | 3 + .zshrc | 2 +- 5 files changed, 20 insertions(+), 94 deletions(-) create mode 100644 .config/nvim/lua/tovi/plugins/vim-blade.lua diff --git a/.config/nvim/lua/tovi/core/autocmd.lua b/.config/nvim/lua/tovi/core/autocmd.lua index 2d6aabd..33acae5 100644 --- a/.config/nvim/lua/tovi/core/autocmd.lua +++ b/.config/nvim/lua/tovi/core/autocmd.lua @@ -54,11 +54,6 @@ local aucmd_dict = { vim.opt_local.syntax = 'dockerfile' end }, - - { - pattern = { '*.blade.php' }, - command = [[set syntax=html]], - }, }, VimLeave = { diff --git a/.config/nvim/lua/tovi/plugins/linting.lua b/.config/nvim/lua/tovi/plugins/linting.lua index 2b5e8fc..10bcc4c 100644 --- a/.config/nvim/lua/tovi/plugins/linting.lua +++ b/.config/nvim/lua/tovi/plugins/linting.lua @@ -64,6 +64,7 @@ return { golang = { "gospell", "golangci-lint" }, python = { "pylint" }, dockerfile = { "hadolint" }, + blade = { "phpcs" }, } local lint_augroup = vim.api.nvim_create_augroup("lint", { diff --git a/.config/nvim/lua/tovi/plugins/nvim-treesitter.lua b/.config/nvim/lua/tovi/plugins/nvim-treesitter.lua index 7eb4f94..ac40c75 100644 --- a/.config/nvim/lua/tovi/plugins/nvim-treesitter.lua +++ b/.config/nvim/lua/tovi/plugins/nvim-treesitter.lua @@ -5,7 +5,6 @@ return { build = ":TSUpdate", dependencies = { "windwp/nvim-ts-autotag", - "nvim-treesitter/nvim-treesitter-textobjects", }, config = function() -- import nvim-treesitter plugin @@ -41,6 +40,7 @@ return { "dockerfile", "gitignore", "php", + "blade", }, -- enable nvim-ts-context-commentstring plugin for commenting tsx and jsx context_commentstring = { @@ -49,97 +49,24 @@ return { }, -- auto install above language parsers auto_install = true, - - textobjects = { - select = { - enable = true, - - -- Automatically jump forward to textobj, similar to targets.vim - lookahead = true, - - keymaps = { - -- You can use the capture groups defined in textobjects.scm - ["aa"] = "@parameter.outer", - ["ia"] = "@parameter.inner", - - ["af"] = "@function.outer", - ["if"] = "@function.inner", - - ["ac"] = "@class.outer", - ["ic"] = "@class.inner", - - ["ab"] = "@block.outer", - ["ib"] = "@block.inner", - - ["al"] = "@loop.outer", - ["il"] = "@loop.inner", - - ["am"] = "@call.outer", - ["im"] = "@call.inner", - - ["ai"] = "@conditional.outer", - ["ii"] = "@conditional.inner", - }, - selection_modes = { - ['@parameter.outer'] = 'v', -- charwise - ['@function.outer'] = 'V', -- linewise - ['@class.outer'] = '', -- blockwise - }, - include_surrounding_whitespace = true, - }, - move = { - enable = true, - set_jumps = true, -- whether to set jumps in the jumplist - goto_next_start = { - ["]m"] = "@function.outer", - ["]]"] = "@class.outer", - }, - goto_next_end = { - ["]M"] = "@function.outer", - ["]["] = "@class.outer", - }, - goto_previous_start = { - ["[m"] = "@function.outer", - ["[["] = "@class.outer", - }, - goto_previous_end = { - ["[M"] = "@function.outer", - ["[]"] = "@class.outer", - }, - goto_next = { - ["]i"] = "@conditional.outer", - ["]l"] = "@loop.outer", - }, - goto_previous = { - ["[i"] = "@conditional.outer", - ["[l"] = "@loop.outer", - } - }, - swap = { - enable = true, - swap_next = { - ["s"] = "@parameter.inner", - }, - swap_previous = { - ["S"] = "@parameter.inner", - }, - }, - }, }) - local ts_repeat_move = require("nvim-treesitter.textobjects.repeatable_move") + local parser_config = require "nvim-treesitter.parsers".get_parser_configs() - local keymap = vim.keymap - - -- vim way: ; goes to the direction you were moving. - keymap.set({ "n", "x", "o" }, ";", ts_repeat_move.repeat_last_move) - keymap.set({ "n", "x", "o" }, ",", ts_repeat_move.repeat_last_move_opposite) + parser_config.blade = { + install_info = { + url = "https://github.com/EmranMR/tree-sitter-blade", + files = { "src/parser.c" }, + branch = "main", + }, + filetype = "blade" + } - -- Optionally, make builtin f, F, t, T also repeatable with ; and , - keymap.set({ "n", "x", "o" }, "f", ts_repeat_move.builtin_f) - keymap.set({ "n", "x", "o" }, "F", ts_repeat_move.builtin_F) - keymap.set({ "n", "x", "o" }, "t", ts_repeat_move.builtin_t) - keymap.set({ "n", "x", "o" }, "T", ts_repeat_move.builtin_T) + vim.filetype.add({ + pattern = { + ['.*%.blade%.php'] = 'blade', + } + }) end, }, } diff --git a/.config/nvim/lua/tovi/plugins/vim-blade.lua b/.config/nvim/lua/tovi/plugins/vim-blade.lua new file mode 100644 index 0000000..f1c92a4 --- /dev/null +++ b/.config/nvim/lua/tovi/plugins/vim-blade.lua @@ -0,0 +1,3 @@ +return { + 'jwalton512/vim-blade' +} diff --git a/.zshrc b/.zshrc index 5f3fb6d..8539c7d 100644 --- a/.zshrc +++ b/.zshrc @@ -68,7 +68,7 @@ HISTFILE=${ZDOTDIR:-$HOME}/.zsh_history HISTSIZE=99999999 SAVEHIST=$HISTSIZE -export PATH="~/.local/bin/:$PATH" +export PATH="${HOME}/.local/bin/:${HOME}/.cargo/bin:$PATH" if [[ $(uname) == 'Darwin' ]]; then fi