diff --git a/after/ftplugin/blade.lua b/after/ftplugin/blade.lua new file mode 100644 index 0000000..1931f8b --- /dev/null +++ b/after/ftplugin/blade.lua @@ -0,0 +1 @@ +vim.bo.commentstring = '{{-- %s --}}' diff --git a/after/ftplugin/php.lua b/after/ftplugin/php.lua new file mode 100644 index 0000000..f398d66 --- /dev/null +++ b/after/ftplugin/php.lua @@ -0,0 +1 @@ +vim.bo.commentstring = '// %s' diff --git a/after/ftplugin/vue.lua b/after/ftplugin/vue.lua new file mode 100644 index 0000000..b7e2345 --- /dev/null +++ b/after/ftplugin/vue.lua @@ -0,0 +1 @@ +vim.bo.commentstring = '' diff --git a/after/queries/blade/highlights.scm b/after/queries/blade/highlights.scm new file mode 100644 index 0000000..2c9c2cd --- /dev/null +++ b/after/queries/blade/highlights.scm @@ -0,0 +1,4 @@ +(directive) @tag +(directive_start) @tag +(directive_end) @tag +(comment) @comment @spell diff --git a/after/queries/blade/injections.scm b/after/queries/blade/injections.scm new file mode 100644 index 0000000..5283841 --- /dev/null +++ b/after/queries/blade/injections.scm @@ -0,0 +1,16 @@ +((text) @injection.content + (#not-has-ancestor? @injection.content "envoy") + (#set! injection.combined) + (#set! injection.language php)) + +((text) @injection.content + (#has-ancestor? @injection.content "envoy") + (#set! injection.combined) + (#set! injection.language bash)) + + +((php_only) @injection.content + (#set! injection.combined) + (#set! injection.language php_only)) +((parameter) @injection.content + (#set! injection.language php_only)) diff --git a/after/queries/html/injections.scm b/after/queries/html/injections.scm new file mode 100644 index 0000000..e183fb0 --- /dev/null +++ b/after/queries/html/injections.scm @@ -0,0 +1,36 @@ +;; extends + +; AlpineJS attributes +(attribute + (attribute_name) @_attr + (#lua-match? @_attr "^x%-%l") + (#not-any-of? @_attr "x-teleport" "x-ref" "x-transition") + (quoted_attribute_value + (attribute_value) @injection.content) + (#set! injection.language "javascript")) + +; Blade escaped JS attributes +; +(element + (_ + (tag_name) @_tag + (#lua-match? @_tag "^x%-%l") + (attribute + (attribute_name) @_attr + (#lua-match? @_attr "^::%l") + (quoted_attribute_value + (attribute_value) @injection.content) + (#set! injection.language "javascript")))) + +; Blade PHP attributes +; +(element + (_ + (tag_name) @_tag + (#lua-match? @_tag "^x%-%l") + (attribute + (attribute_name) @_attr + (#lua-match? @_attr "^:%l") + (quoted_attribute_value + (attribute_value) @injection.content) + (#set! injection.language "php_only")))) diff --git a/after/queries/php/indents.scm b/after/queries/php/indents.scm new file mode 100644 index 0000000..b2044f3 --- /dev/null +++ b/after/queries/php/indents.scm @@ -0,0 +1,10 @@ +;; extends + +[ + ; prevent double indent for `return new class ...` + (return_statement + (object_creation_expression)) + ; prevent double indent for `return function() { ... }` + (return_statement + (anonymous_function_creation_expression)) +] @indent.dedent diff --git a/after/queries/php/injections.scm b/after/queries/php/injections.scm new file mode 100644 index 0000000..204482f --- /dev/null +++ b/after/queries/php/injections.scm @@ -0,0 +1,9 @@ +;; extends + +; ((text) @injection.content +; (#set! injection.language "html") +; (#set! injection.combined)) + +; ((php) @injection.content +; (#set! injection.language "php_only") +; (#set! injection.combined)) diff --git a/lazy-lock.json b/lazy-lock.json index 05d8040..8d8e0ef 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -19,6 +19,7 @@ "friendly-snippets": { "branch": "main", "commit": "682157939e57bd6a2c86277dfd4d6fbfce63dbac" }, "gitsigns.nvim": { "branch": "main", "commit": "0b04035bb7b3c83e999b9676e2fb46fd0aa9f910" }, "indent-blankline.nvim": { "branch": "master", "commit": "4036c8ae9cc29faf8e6443fa5b23e679db055d24" }, + "laravel.nvim": { "branch": "main", "commit": "8aaf614b5c8fc045f75ebc2ba69d68e33847b06d" }, "lazy.nvim": { "branch": "main", "commit": "378bfb465673a747e9e9f966e518063499e20cfe" }, "lsp-progress.nvim": { "branch": "main", "commit": "55a04895ea20c365b670051a3128265d43bdfa3d" }, "lualine.nvim": { "branch": "master", "commit": "0a5a66803c7407767b799067986b4dc3036e1983" }, @@ -28,7 +29,6 @@ "mini.indentscope": { "branch": "main", "commit": "56d42be090e8fcc68eda69cfe55af8c5e562300e" }, "neoscroll.nvim": { "branch": "master", "commit": "a731f66f1d39ec6175fd201c5bf849e54abda99c" }, "neotest": { "branch": "master", "commit": "f30bab1faef13d47f3905e065215c96a42d075ad" }, - "neotest-gtest": { "branch": "main", "commit": "b44c8afc26cea75ffc80617ce07b4e745a56e589" }, "neotest-phpunit": { "branch": "main", "commit": "baae8dfa0a3aaacd9f0bb6845d6348f5bcdc48bb" }, "noice.nvim": { "branch": "main", "commit": "d580646db85f49b8226d52b143a458161f41954a" }, "none-ls-extras.nvim": { "branch": "main", "commit": "336e84b9e43c0effb735b08798ffac382920053b" }, @@ -48,6 +48,7 @@ "nvim-scrollview": { "branch": "main", "commit": "fd334e5ad0c616987d1b9114890a59c97165cf83" }, "nvim-tree.lua": { "branch": "master", "commit": "2086e564c4d23fea714e8a6d63b881e551af2f41" }, "nvim-treesitter": { "branch": "master", "commit": "d4a888ae3cff358cb239643c45b2b38bb60e29c6" }, + "nvim-treesitter-context": { "branch": "master", "commit": "5efba33af0f39942e426340da7bc15d7dec16474" }, "nvim-treesitter-textobjects": { "branch": "master", "commit": "34867c69838078df7d6919b130c0541c0b400c47" }, "nvim-ts-autotag": { "branch": "main", "commit": "ddfccbf0df1b9349c2b9e9b17f4afa8f9b6c1ed1" }, "nvim-ts-context-commentstring": { "branch": "main", "commit": "cb064386e667def1d241317deed9fd1b38f0dc2e" }, @@ -59,7 +60,6 @@ "smart-splits.nvim": { "branch": "master", "commit": "66fda3a601a5b4c679656f15eb6ddd613c8d3216" }, "telescope.nvim": { "branch": "master", "commit": "f2bfde705ac752c52544d5cfa8b0aee0a766c1ed" }, "tiny-devicons-auto-colors.nvim": { "branch": "main", "commit": "9be4af5b1bc1f26a11206ed7ce8bf44312e7941a" }, - "todo-comments.nvim": { "branch": "main", "commit": "a7e39ae9e74f2c8c6dc4eea6d40c3971ae84752d" }, "toggleterm.nvim": { "branch": "main", "commit": "fee58a0473fd92b28c34f8f724e4918b15ba30a3" }, "vim-illuminate": { "branch": "master", "commit": "5eeb7951fc630682c322e88a9bbdae5c224ff0aa" }, "vim-startuptime": { "branch": "master", "commit": "97a88e688482a09c3c4b777d07b509b328a5ec29" }, diff --git a/lua/core/init.lua b/lua/core/init.lua index df0d77a..3b4b5ef 100644 --- a/lua/core/init.lua +++ b/lua/core/init.lua @@ -1,4 +1,9 @@ _G.pcode = _G.pcode or {} +vim.filetype.add({ + pattern = { + [".*%.blade%.php"] = "blade", + }, +}) require("custom.default") require("custom.dashboard") require("config.lazy_lib") diff --git a/lua/custom/default.lua b/lua/custom/default.lua index 6f8cea8..9317a20 100644 --- a/lua/custom/default.lua +++ b/lua/custom/default.lua @@ -132,7 +132,7 @@ pcode.columnline = true pcode.auto_save = true -- https://github.com/folke/todo-comments.nvim -pcode.todo_comment = true +pcode.todo_comment = false -- https://github.com/nvim-telescope/telescope.nvim ---@alias telescope_themes @@ -165,7 +165,7 @@ pcode.active_javascript_config = { pcode.active_php_config = true pcode.active_golang_config = false pcode.active_python_config = false -pcode.active_cpp_config = true +pcode.active_cpp_config = false pcode.active_java_config = { active = false, project = "gradle", -- gradle or maven diff --git a/lua/plugins/phpcfg.lua b/lua/plugins/phpcfg.lua index 3cad5d8..5d8b3a2 100644 --- a/lua/plugins/phpcfg.lua +++ b/lua/plugins/phpcfg.lua @@ -116,6 +116,24 @@ if pcode.active_php_config then require("lint").linters_by_ft = opts.linters_by_ft end, }, + { + "adalessa/laravel.nvim", + dependencies = { + "nvim-telescope/telescope.nvim", + -- "tpope/vim-dotenv", + "MunifTanjim/nui.nvim", + "nvimtools/none-ls.nvim", + }, + cmd = { "Sail", "Artisan", "Composer", "Npm", "Yarn", "Laravel" }, + keys = { + { "L", "", desc = " 󰫐 Laravel" }, + { "La", ":Laravel artisan", desc = "Artisan" }, + { "Lr", ":Laravel routes", desc = "Routes" }, + { "Lm", ":Laravel related", desc = "Related" }, + }, + event = { "VeryLazy" }, + config = true, + }, } end diff --git a/lua/plugins/themes/_globalvar.lua b/lua/plugins/themes/_globalvar.lua index 5351079..e5ca88f 100644 --- a/lua/plugins/themes/_globalvar.lua +++ b/lua/plugins/themes/_globalvar.lua @@ -56,7 +56,7 @@ if pcode.active_javascript_config.active then end -- run if php config true if pcode.active_php_config then - local lst_ts = { "php", "phpdoc" } + local lst_ts = { "html", "php_only", "php", "bash", "blade" } for _, ts in pairs(lst_ts) do table.insert(pcode.treesitter_ensure_installed, ts) end diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua index 2146cae..9a035ed 100644 --- a/lua/plugins/treesitter.lua +++ b/lua/plugins/treesitter.lua @@ -1,11 +1,3 @@ -local ts_list = { - "lua", - "vim", - "vimdoc", -} -for _, ts in pairs(pcode.treesitter_ensure_installed or {}) do - table.insert(ts_list, ts) -end return { { "nvim-treesitter/nvim-treesitter", @@ -73,7 +65,7 @@ return { return { highlight = { enable = true }, indent = { enable = true }, - ensure_installed = ts_list, + ensure_installed = {}, incremental_selection = { enable = true, }, diff --git a/lua/plugins/treesitter_blade.lua b/lua/plugins/treesitter_blade.lua new file mode 100644 index 0000000..1026804 --- /dev/null +++ b/lua/plugins/treesitter_blade.lua @@ -0,0 +1,36 @@ +local ts_list = { + "lua", + "vim", + "vimdoc", +} +for _, ts in pairs(pcode.treesitter_ensure_installed or {}) do + table.insert(ts_list, ts) +end +return { + { + "nvim-treesitter/nvim-treesitter", + opts = { + ensure_installed = ts_list, + }, + config = function(_, opts) + local parser_config = require("nvim-treesitter.parsers").get_parser_configs() + + parser_config.blade = { + install_info = { + url = "https://github.com/EmranMR/tree-sitter-blade", + files = { "src/parser.c" }, + branch = "main", + }, + filetype = "blade", + } + + vim.filetype.add({ + pattern = { + [".*%.blade%.php"] = "blade", + }, + }) + + require("nvim-treesitter.configs").setup(opts) + end, + }, +} diff --git a/lua/user/autocommands.lua b/lua/user/autocommands.lua index 886da81..eaf163f 100644 --- a/lua/user/autocommands.lua +++ b/lua/user/autocommands.lua @@ -80,6 +80,12 @@ vim.api.nvim_create_autocmd("FileType", { end, }) +vim.filetype.add({ + pattern = { + [".*%.blade%.php"] = "blade", + }, +}) + -- Autoformat -- augroup _lsp -- autocmd! diff --git a/queries/blade/folds.scm b/queries/blade/folds.scm new file mode 100644 index 0000000..0705d92 --- /dev/null +++ b/queries/blade/folds.scm @@ -0,0 +1,8 @@ +((directive_start) @start + (directive_end) @end.after + (#set! role block)) + + +((bracket_start) @start + (bracket_end) @end + (#set! role block)) diff --git a/queries/blade/highlights.scm b/queries/blade/highlights.scm new file mode 100644 index 0000000..2c9c2cd --- /dev/null +++ b/queries/blade/highlights.scm @@ -0,0 +1,4 @@ +(directive) @tag +(directive_start) @tag +(directive_end) @tag +(comment) @comment @spell diff --git a/queries/blade/injections.scm b/queries/blade/injections.scm new file mode 100644 index 0000000..5283841 --- /dev/null +++ b/queries/blade/injections.scm @@ -0,0 +1,16 @@ +((text) @injection.content + (#not-has-ancestor? @injection.content "envoy") + (#set! injection.combined) + (#set! injection.language php)) + +((text) @injection.content + (#has-ancestor? @injection.content "envoy") + (#set! injection.combined) + (#set! injection.language bash)) + + +((php_only) @injection.content + (#set! injection.combined) + (#set! injection.language php_only)) +((parameter) @injection.content + (#set! injection.language php_only))