fallback to toggle-line-comment and vice versa if needed
This commit is contained in:
parent
4d31b1bc40
commit
69a857bbbf
|
@ -293,8 +293,13 @@ local commands = {
|
||||||
end,
|
end,
|
||||||
|
|
||||||
["doc:toggle-block-comments"] = function()
|
["doc:toggle-block-comments"] = function()
|
||||||
local comment = doc().syntax.multiline_comment
|
local comment = doc().syntax.block_comment
|
||||||
if not comment then return end
|
if not comment then
|
||||||
|
if doc().syntax.comment then
|
||||||
|
command.perform "doc:toggle-line-comments"
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
for idx, line1, col1, line2, col2 in doc_multiline_selections(true) do
|
for idx, line1, col1, line2, col2 in doc_multiline_selections(true) do
|
||||||
local text = doc():get_text(line1, col1, line2, col2)
|
local text = doc():get_text(line1, col1, line2, col2)
|
||||||
|
@ -342,7 +347,12 @@ local commands = {
|
||||||
|
|
||||||
["doc:toggle-line-comments"] = function()
|
["doc:toggle-line-comments"] = function()
|
||||||
local comment = doc().syntax.comment
|
local comment = doc().syntax.comment
|
||||||
if not comment then return end
|
if not comment then
|
||||||
|
if doc().syntax.block_comment then
|
||||||
|
command.perform "doc:toggle-block-comments"
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
local indentation = doc():get_indent_string()
|
local indentation = doc():get_indent_string()
|
||||||
local comment_text = comment .. " "
|
local comment_text = comment .. " "
|
||||||
for idx, line1, _, line2 in doc_multiline_selections(true) do
|
for idx, line1, _, line2 in doc_multiline_selections(true) do
|
||||||
|
|
|
@ -5,7 +5,7 @@ syntax.add {
|
||||||
name = "C",
|
name = "C",
|
||||||
files = { "%.c$", "%.h$", "%.inl$" },
|
files = { "%.c$", "%.h$", "%.inl$" },
|
||||||
comment = "//",
|
comment = "//",
|
||||||
multiline_comment = { "/*", "*/" },
|
block_comment = { "/*", "*/" },
|
||||||
patterns = {
|
patterns = {
|
||||||
{ pattern = "//.-\n", type = "comment" },
|
{ pattern = "//.-\n", type = "comment" },
|
||||||
{ pattern = { "/%*", "%*/" }, type = "comment" },
|
{ pattern = { "/%*", "%*/" }, type = "comment" },
|
||||||
|
|
|
@ -10,7 +10,7 @@ syntax.add {
|
||||||
"%.c++$", "%.hh$", "%.H$", "%.hxx$", "%.hpp$", "%.h++$"
|
"%.c++$", "%.hh$", "%.H$", "%.hxx$", "%.hpp$", "%.h++$"
|
||||||
},
|
},
|
||||||
comment = "//",
|
comment = "//",
|
||||||
multiline_comment = { "/*", "*/" },
|
block_comment = { "/*", "*/" },
|
||||||
patterns = {
|
patterns = {
|
||||||
{ pattern = "//.-\n", type = "comment" },
|
{ pattern = "//.-\n", type = "comment" },
|
||||||
{ pattern = { "/%*", "%*/" }, type = "comment" },
|
{ pattern = { "/%*", "%*/" }, type = "comment" },
|
||||||
|
|
|
@ -4,7 +4,7 @@ local syntax = require "core.syntax"
|
||||||
syntax.add {
|
syntax.add {
|
||||||
name = "CSS",
|
name = "CSS",
|
||||||
files = { "%.css$" },
|
files = { "%.css$" },
|
||||||
multiline_comment = { "/*", "*/" },
|
block_comment = { "/*", "*/" },
|
||||||
patterns = {
|
patterns = {
|
||||||
{ pattern = "\\.", type = "normal" },
|
{ pattern = "\\.", type = "normal" },
|
||||||
{ pattern = "//.-\n", type = "comment" },
|
{ pattern = "//.-\n", type = "comment" },
|
||||||
|
|
|
@ -4,7 +4,7 @@ local syntax = require "core.syntax"
|
||||||
syntax.add {
|
syntax.add {
|
||||||
name = "HTML",
|
name = "HTML",
|
||||||
files = { "%.html?$" },
|
files = { "%.html?$" },
|
||||||
multiline_comment = { "<!--", "-->" },
|
block_comment = { "<!--", "-->" },
|
||||||
patterns = {
|
patterns = {
|
||||||
{
|
{
|
||||||
pattern = {
|
pattern = {
|
||||||
|
|
|
@ -5,7 +5,7 @@ syntax.add {
|
||||||
name = "JavaScript",
|
name = "JavaScript",
|
||||||
files = { "%.js$", "%.json$", "%.cson$" },
|
files = { "%.js$", "%.json$", "%.cson$" },
|
||||||
comment = "//",
|
comment = "//",
|
||||||
multiline_comment = { "/*", "*/" },
|
block_comment = { "/*", "*/" },
|
||||||
patterns = {
|
patterns = {
|
||||||
{ pattern = "//.-\n", type = "comment" },
|
{ pattern = "//.-\n", type = "comment" },
|
||||||
{ pattern = { "/%*", "%*/" }, type = "comment" },
|
{ pattern = { "/%*", "%*/" }, type = "comment" },
|
||||||
|
|
|
@ -6,7 +6,7 @@ syntax.add {
|
||||||
files = "%.lua$",
|
files = "%.lua$",
|
||||||
headers = "^#!.*[ /]lua",
|
headers = "^#!.*[ /]lua",
|
||||||
comment = "--",
|
comment = "--",
|
||||||
multiline_comment = { "--[[", "]]" },
|
block_comment = { "--[[", "]]" },
|
||||||
patterns = {
|
patterns = {
|
||||||
{ pattern = { '"', '"', '\\' }, type = "string" },
|
{ pattern = { '"', '"', '\\' }, type = "string" },
|
||||||
{ pattern = { "'", "'", '\\' }, type = "string" },
|
{ pattern = { "'", "'", '\\' }, type = "string" },
|
||||||
|
|
|
@ -5,7 +5,7 @@ syntax.add {
|
||||||
name = "XML",
|
name = "XML",
|
||||||
files = { "%.xml$" },
|
files = { "%.xml$" },
|
||||||
headers = "<%?xml",
|
headers = "<%?xml",
|
||||||
multiline_comment = { "<!--", "-->" },
|
block_comment = { "<!--", "-->" },
|
||||||
patterns = {
|
patterns = {
|
||||||
{ pattern = { "<!%-%-", "%-%->" }, type = "comment" },
|
{ pattern = { "<!%-%-", "%-%->" }, type = "comment" },
|
||||||
{ pattern = { '%f[^>][^<]', '%f[<]' }, type = "normal" },
|
{ pattern = { '%f[^>][^<]', '%f[<]' }, type = "normal" },
|
||||||
|
|
Loading…
Reference in New Issue