Skip to content

Commit 9b23085

Browse files
update: dependencies
1 parent 548c72f commit 9b23085

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

README.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Execute the following command to sort your PHP "use" statements:
2020
## ⚡️ Requirements
2121

2222
- Neovim >= 0.5.0
23+
- Treesitter >= 0.9.2
2324

2425
## 📦 Installation
2526

@@ -30,15 +31,21 @@ Install the plugin with your preferred package manager:
3031
```lua
3132
{
3233
"ricardoramirezr/php-use-sort.nvim",
34+
dependencies = {
35+
"nvim-treesitter/nvim-treesitter",
36+
},
3337
ft = "php",
3438
opts = {
3539
order = "asc",
3640
autocmd = true,
3741
rm_unused = true,
3842
},
39-
config = function()
40-
require("php-use-sort").setup()
41-
vim.keymap.set("n", "<leader>su", ":PhpUseSort<CR>", { desc = "Sort PHP use lines by length", silent = true })
43+
config = function(opts)
44+
require("php-use-sort").setup(opts)
45+
vim.keymap.set("n", "<leader>su", ":PhpUseSort<CR>", {
46+
desc = "Sort PHP use lines by length",
47+
silent = true,
48+
})
4249
end,
4350
}
4451
```

lua/php-use-sort/init.lua

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,7 @@ local function setup_autocmd()
9696

9797
vim.api.nvim_create_autocmd("BufWritePre", {
9898
pattern = { "*.php" },
99-
callback = function()
100-
if vim.bo.filetype == "php" then
101-
vim.api.nvim_command("PhpUseSort")
102-
end
103-
end,
99+
command = "PhpUseSort",
104100
group = group,
105101
})
106102
end
@@ -122,7 +118,6 @@ function M.get_config_options()
122118
end
123119

124120
function M.main(sort_order)
125-
local options = M.get_config_options()
126121
local parser = parsers.get_parser()
127122

128123
if not parser then
@@ -145,6 +140,8 @@ function M.main(sort_order)
145140
return
146141
end
147142

143+
local options = M.get_config_options()
144+
148145
sort_order = sort_order ~= "" and sort_order or options.order
149146

150147
local use_statements, range = extract_use_statements(root, lang, options.rm_unused)

0 commit comments

Comments
 (0)