-
Notifications
You must be signed in to change notification settings - Fork 0
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
21c0e05
commit 1b020d6
Showing
12 changed files
with
136 additions
and
2 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
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,16 @@ | ||
local JSDoc = require'splitjoin.languages.jsdoc.functions' | ||
|
||
---@type SplitjoinLanguageConfig | ||
return { | ||
|
||
nodes = { | ||
|
||
description = { | ||
split = JSDoc.split_jsdoc_description, | ||
join = JSDoc.join_jsdoc_description, | ||
trailing_separator = false, | ||
}, | ||
|
||
}, | ||
|
||
} |
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,39 @@ | ||
local Node = require'splitjoin.util.node' | ||
local String = require'splitjoin.util.string' | ||
|
||
local JSDoc = {} | ||
|
||
function JSDoc.split_jsdoc_description(node, options) | ||
local text = Node.get_text(node) | ||
if String.is_multiline(text) then return end | ||
text = text:gsub([[%*$]], '') | ||
local indent = options.default_indent or ' ' | ||
local append, get = String.append('') | ||
append( | ||
'\n', | ||
indent, | ||
'* ', | ||
text, | ||
'\n *' | ||
) | ||
local row, col = unpack(vim.api.nvim_win_get_cursor(0)); | ||
Node.replace(node, get()) | ||
Node.trim_line_end(node) | ||
Node.trim_line_end(node, 1) | ||
vim.api.nvim_win_set_cursor(0, { row + 1, col - 1 }) | ||
end | ||
|
||
function JSDoc.join_jsdoc_description(node, options) | ||
local text = Node.get_text(node) | ||
if String.is_multiline(text) then return end | ||
local nrow, ncol = node:range() | ||
local comment = vim.treesitter.get_node { pos = { nrow, ncol - 1 } } | ||
if comment and not String.is_singleline(Node.get_text(comment)) then | ||
local row, col = unpack(vim.api.nvim_win_get_cursor(0)); | ||
Node.replace(comment, '/** ' .. text .. ' */') | ||
Node.goto_node(comment) | ||
vim.api.nvim_win_set_cursor(0, { row - 1, col + 1 }) | ||
end | ||
end | ||
|
||
return JSDoc |
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
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
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 @@ | ||
(description) @splitjoin.jsdoc.description |
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
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