-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
79b2a48
commit bda72f3
Showing
5 changed files
with
37 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
return { | ||
"html", | ||
"css", | ||
"php", | ||
"twig", | ||
"vue", | ||
"svelte", | ||
"astro", | ||
"heex", | ||
"elixir", | ||
"htmldjango", | ||
"javascriptreact", | ||
"typescriptreact", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,13 @@ | ||
local M = {} | ||
|
||
local levels = vim.log.levels | ||
|
||
local notify_fn = function(level) | ||
return | ||
---@param message string | ||
return ---@param message string | ||
function(message) vim.notify("[tailwind-tools] " .. message, level) end | ||
end | ||
|
||
M.debug = notify_fn(levels.DEBUG) | ||
M.info = notify_fn(levels.INFO) | ||
M.warn = notify_fn(levels.WARN) | ||
M.error = notify_fn(levels.ERROR) | ||
M.debug = notify_fn(vim.log.levels.DEBUG) | ||
M.info = notify_fn(vim.log.levels.INFO) | ||
M.warn = notify_fn(vim.log.levels.WARN) | ||
M.error = notify_fn(vim.log.levels.ERROR) | ||
|
||
return M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,39 @@ | ||
local M = {} | ||
|
||
local log = require("tailwind-tools.log") | ||
local treesitter = require("tailwind-tools.treesitter") | ||
|
||
M.move_to_next_class = function() | ||
---@param comp fun(a: number, b: number): boolean | ||
local move_to_class = function(comp) | ||
local nodes = treesitter.get_class_nodes(0, true) | ||
|
||
if not nodes then return end | ||
if #nodes == 0 then return log.info("No classes") end | ||
|
||
local cursor_row, cursor_col = unpack(vim.api.nvim_win_get_cursor(0)) | ||
|
||
table.sort(nodes, function(a, b) | ||
local a_row, a_col = treesitter.get_class_range(a, 0) | ||
local b_row, b_col = treesitter.get_class_range(b, 0) | ||
return a_row == b_row and a_col < b_col or a_row < b_row | ||
return a_row == b_row and comp(b_col, a_col) or comp(b_row, a_row) | ||
end) | ||
|
||
for _, node in ipairs(nodes) do | ||
local node_row, node_col = treesitter.get_class_range(node, 0) | ||
local row = cursor_row - 1 | ||
|
||
if node_row > cursor_row - 1 or (node_row == cursor_row - 1 and node_col > cursor_col) then | ||
if comp(node_row, row) or (node_row == row and comp(node_col, cursor_col)) then | ||
return vim.api.nvim_win_set_cursor(0, { node_row + 1, node_col }) | ||
end | ||
end | ||
end | ||
|
||
M.move_to_prev_class = function() | ||
local nodes = treesitter.get_class_nodes(0, true) | ||
|
||
if not nodes then return end | ||
|
||
local cursor_row, cursor_col = unpack(vim.api.nvim_win_get_cursor(0)) | ||
|
||
table.sort(nodes, function(a, b) | ||
local a_row, a_col = treesitter.get_class_range(a, 0) | ||
local b_row, b_col = treesitter.get_class_range(b, 0) | ||
return a_row == b_row and a_col > b_col or a_row > b_row | ||
end) | ||
|
||
for _, node in ipairs(nodes) do | ||
local node_row, node_col = treesitter.get_class_range(node, 0) | ||
M.move_to_next_class = function() | ||
move_to_class(function(a, b) return a > b end) | ||
end | ||
|
||
if node_row < cursor_row - 1 or (node_row == cursor_row - 1 and node_col < cursor_col) then | ||
return vim.api.nvim_win_set_cursor(0, { node_row + 1, node_col }) | ||
end | ||
end | ||
M.move_to_prev_class = function() | ||
move_to_class(function(a, b) return a < b end) | ||
end | ||
|
||
return M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters