mirror of
https://github.com/mawww/kakoune.git
synced 2024-12-18 00:42:13 +03:00
Add commenting characters to all supported languages
The default commenting character is now '#', considering the superior amount of files that use it for comments compared to the previous C-style comment characters. The logic now also prioritize the opening commenting characters if they contain a colon, to be able to use selection commenting on markdown files.
This commit is contained in:
parent
68d3eda270
commit
ac42ea414e
@ -1,23 +1,50 @@
|
||||
## Characters that will be used to surround a selection with
|
||||
decl str-list comment_selection_chars "/*:*/"
|
||||
|
||||
## Characters that will be inserted at the beginning of a line to comment
|
||||
decl str comment_line_chars "//"
|
||||
decl str comment_line_chars "#"
|
||||
|
||||
## Characters that will be used to surround a selection with
|
||||
decl str-list comment_selection_chars ""
|
||||
|
||||
## Default characters for all languages
|
||||
hook global BufSetOption filetype=asciidoc %{
|
||||
set buffer comment_selection_chars '///:///'
|
||||
}
|
||||
|
||||
hook global BufSetOption filetype=(c|cpp|go|java|javascript|objc|sass|scala|scss|swift) %{
|
||||
set buffer comment_line_chars '//'
|
||||
set buffer comment_selection_chars '/*:*/'
|
||||
}
|
||||
|
||||
hook global BufSetOption filetype=(cabal|haskell|moon) %{
|
||||
set buffer comment_line_chars '--'
|
||||
}
|
||||
|
||||
hook global BufSetOption filetype=clojure %{
|
||||
set buffer comment_line_chars '#_ '
|
||||
set buffer comment_selection_chars '(comment :)'
|
||||
}
|
||||
|
||||
hook global BufSetOption filetype=coffee %{
|
||||
set buffer comment_line_chars '#'
|
||||
set buffer comment_selection_chars '###:###'
|
||||
}
|
||||
|
||||
hook global BufSetOption filetype=css %{
|
||||
set buffer comment_line_chars ''
|
||||
set buffer comment_selection_chars '/*:*/'
|
||||
}
|
||||
|
||||
hook global BufSetOption filetype=d %{
|
||||
set buffer comment_line_chars '//'
|
||||
set buffer comment_selection_chars '/+:+/'
|
||||
}
|
||||
|
||||
hook global BufSetOption filetype=(gas|ini) %{
|
||||
set buffer comment_line_chars ';'
|
||||
}
|
||||
|
||||
hook global BufSetOption filetype=haml %{
|
||||
set buffer comment_line_chars '-#'
|
||||
}
|
||||
|
||||
hook global BufSetOption filetype=html %{
|
||||
set buffer comment_line_chars ''
|
||||
set buffer comment_selection_chars '<!--:-->'
|
||||
@ -25,7 +52,11 @@ hook global BufSetOption filetype=html %{
|
||||
|
||||
hook global BufSetOption filetype=latex %{
|
||||
set buffer comment_line_chars '%'
|
||||
set buffer comment_selection_chars ''
|
||||
}
|
||||
|
||||
hook global BufSetOption filetype=lisp %{
|
||||
set buffer comment_line_chars ';'
|
||||
set buffer comment_selection_chars '#|:|#'
|
||||
}
|
||||
|
||||
hook global BufSetOption filetype=lua %{
|
||||
@ -33,18 +64,29 @@ hook global BufSetOption filetype=lua %{
|
||||
set buffer comment_selection_chars '--[[:]]'
|
||||
}
|
||||
|
||||
hook global BufSetOption filetype=moon %{
|
||||
set buffer comment_line_chars '--'
|
||||
set buffer comment_selection_chars ''
|
||||
hook global BufSetOption filetype=markdown %{
|
||||
set buffer comment_line_chars ''
|
||||
set buffer comment_selection_chars '[//]: # (:)'
|
||||
}
|
||||
|
||||
hook global BufSetOption filetype=(perl|makefile) %{
|
||||
set buffer comment_line_chars '#'
|
||||
set buffer comment_selection_chars ''
|
||||
hook global BufSetOption filetype=perl %{
|
||||
set buffer comment_selection_chars '#[:]'
|
||||
}
|
||||
|
||||
hook global BufSetOption filetype=(pug|rust) %{
|
||||
set buffer comment_line_chars '//'
|
||||
}
|
||||
|
||||
hook global BufSetOption filetype=python %{
|
||||
set buffer comment_selection_chars '""":"""'
|
||||
}
|
||||
|
||||
hook global BufSetOption filetype=ragel %{
|
||||
set buffer comment_line_chars '%%'
|
||||
set buffer comment_selection_chars '%%{:}%%'
|
||||
}
|
||||
|
||||
hook global BufSetOption filetype=ruby %{
|
||||
set buffer comment_line_chars '#'
|
||||
set buffer comment_selection_chars '^begin=:^=end'
|
||||
}
|
||||
|
||||
@ -55,7 +97,7 @@ def comment-selection -docstring "Comment/uncomment the current selection" %{
|
||||
printf %s\\n "$@" | sed 's,<,<lt>,g'
|
||||
}
|
||||
|
||||
readonly opening=$(exec_proof "${kak_opt_comment_selection_chars%%:*}")
|
||||
readonly opening=$(exec_proof "${kak_opt_comment_selection_chars%:*}")
|
||||
readonly closing=$(exec_proof "${kak_opt_comment_selection_chars##*:}")
|
||||
|
||||
if [ -z "${opening}" ] || [ -z "${closing}" ]; then
|
||||
|
Loading…
Reference in New Issue
Block a user