From dd3257e3f2d2a2dec759b2d2b530ff4dc5444a64 Mon Sep 17 00:00:00 2001 From: Ivan Tham Date: Sun, 24 May 2020 11:20:24 +0800 Subject: [PATCH] Rust take indentation before comment to next line --- rc/filetype/rust.kak | 2 +- test/indent/rust/comment/cmd | 1 + test/indent/rust/comment/in | 8 ++++++++ test/indent/rust/comment/out | 11 +++++++++++ test/indent/rust/comment/rc | 3 +++ 5 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 test/indent/rust/comment/cmd create mode 100644 test/indent/rust/comment/in create mode 100644 test/indent/rust/comment/out create mode 100644 test/indent/rust/comment/rc diff --git a/rc/filetype/rust.kak b/rc/filetype/rust.kak index bb998216..35788fd8 100644 --- a/rc/filetype/rust.kak +++ b/rc/filetype/rust.kak @@ -75,7 +75,7 @@ define-command -hidden rust-indent-on-new-line %~ evaluate-commands -draft -itersel %< # copy // comments prefix and following white spaces try %{ - execute-keys -draft k s ^\h*\K//[!/]?\h* y gh j P + execute-keys -draft k s ^\h*//[!/]?\h* y gh j P } catch %` # preserve previous line indent try %{ execute-keys -draft K } diff --git a/test/indent/rust/comment/cmd b/test/indent/rust/comment/cmd new file mode 100644 index 00000000..8682d51e --- /dev/null +++ b/test/indent/rust/comment/cmd @@ -0,0 +1 @@ +cbar diff --git a/test/indent/rust/comment/in b/test/indent/rust/comment/in new file mode 100644 index 00000000..bb887d68 --- /dev/null +++ b/test/indent/rust/comment/in @@ -0,0 +1,8 @@ + // foo%( ) + + //! foo%( ) + + /// foo%( ) + + println!("hello world"); // foo%( ) + diff --git a/test/indent/rust/comment/out b/test/indent/rust/comment/out new file mode 100644 index 00000000..813ec7f2 --- /dev/null +++ b/test/indent/rust/comment/out @@ -0,0 +1,11 @@ + // foo + // bar + + //! foo + //! bar + + /// foo + /// bar + + println!("hello world"); // foo + bar diff --git a/test/indent/rust/comment/rc b/test/indent/rust/comment/rc new file mode 100644 index 00000000..64064c25 --- /dev/null +++ b/test/indent/rust/comment/rc @@ -0,0 +1,3 @@ +source "%val{runtime}/colors/default.kak" +source "%val{runtime}/rc/filetype/rust.kak" +set buffer filetype rust