Unnamed repository; edit this file 'description' to name the repository.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# Kanagawa
# Author: zetashift

# Adaptation of https://github.com/rebelot/kanagawa.nvim
# Original author: rebelot
# All credits to the original author, the palette is taken from the README
# because of some theming differences, it's not an exact copy of the original.

## User interface
"ui.selection" = { bg = "waveBlue1" }
"ui.background" = { fg = "fujiWhite", bg = "sumiInk1" }

"ui.linenr" = { fg = "sumiInk4" }

"ui.statusline" = { fg = "oldWhite", bg = "sumiInk0" }
"ui.statusline.inactive" = { fg = "fujiGray", bg = "sumiInk0" }
"ui.statusline.normal" = { fg = "sumiInk0", bg = "crystalBlue", modifiers = ["bold"] }
"ui.statusline.insert" = { fg = "sumiInk0", bg = "autumnGreen"  }
"ui.statusline.select" = { fg = "sumiInk0", bg = "oniViolet" }

"ui.bufferline" = { fg = "oldWhite", bg = "sumiInk0" }
"ui.bufferline.inactive" = { fg = "fujiGray", bg = "sumiInk0" }

"ui.popup" = { fg = "fujiWhite", bg = "sumiInk0" }
"ui.window" = { fg = "fujiWhite" }
"ui.help" = { fg = "fujiWhite", bg = "waveBlue1" }
"ui.text" = "fujiWhite"
"ui.text.focus" = { fg = "fujiWhite", bg = "waveBlue1", modifiers = ["bold"] }
"ui.virtual" = "waveBlue1"

"ui.cursor" = { fg = "fujiWhite", bg = "waveBlue1"}
"ui.cursor.primary" = { fg = "seaFoam", bg = "waveBlue1" }
"ui.cursor.match" = { fg = "seaFoam", modifiers = ["bold"] }
"ui.highlight" = { fg = "fujiWhite", bg = "waveBlue2" }

diagnostic = { modifiers = ["underlined"] }

error = "samuraiRed"
warning = "roninYellow"
info = "waveAqua1"
hint = "dragonBlue"

## Syntax highlighting
"type" = "waveAqua2"
"constant" = "surimiOrange"
"constant.numeric" = "sakuraPink"
"constant.character.escape" = "springBlue"
"string" = "springGreen"
"string.regexp" = "boatYellow2"
"comment" = "fujiGray"
"variable" = "fujiWhite"
"variable.builtin" = "waveRed"
"variable.parameter" = "carpYellow"
"variable.other.member" = "carpYellow"
"label" = "springBlue"
"punctuation" = "springViolet2"
"punctuation.delimiter" = "springViolet2" 
"punctuation.bracket" = "springViolet2" 
"keyword" = "oniViolet"
"keyword.directive" = "peachRed"
"operator" = "boatYellow2"
"function" = "crystalBlue"
"function.builtin" = "peachRed"
"function.macro" = "waveRed"
"tag" = "springBlue"
"namespace" = "surimiOrange"
"attribute" = "peachRed"
"constructor" = "springBlue"
"module" = "waveAqua2"
"special" = "peachRed"

## Markup modifiers
"markup.heading.marker" = "fujiGray"
"markup.heading.1" = { fg = "surimiOrange", modifiers = ["bold"] }
"markup.heading.2" = { fg = "carpYellow", modifiers = ["bold"] }
"markup.heading.3" = { fg = "waveAqua2", modifiers = ["bold"] }
"markup.heading.4" = { fg = "springGreen", modifiers = ["bold"] }
"markup.heading.5" = { fg = "waveRed", modifiers = ["bold"] }
"markup.heading.6" = { fg = "autumnRed", modifiers = ["bold"] }
"markup.list" = "oniViolet"
"markup.bold" = { modifiers = ["bold"] }
"markup.italic" = { modifiers = ["italic"] }
"markup.link.url" = { fg = "springBlue", modifiers = ["underlined"] }
"markup.link.text" = "crystalBlue"
"markup.quote" = "seaFoam"
"markup.raw" = "seaFoam"

[palette]
seaFoam       = "#C7CCD1" # custom lighter foreground
fujiWhite     = "#DCD7BA" # default foreground
oldWhite      = "#C8C093" # dark foreground, e.g. statuslines
sumiInk0      = "#16161D" # dark background, e.g. statuslines, floating windows
sumiInk1      = "#1F1F28" # default background
sumiInk3      = "#363646" # lighter background, e.g. colorcolumns and folds
sumiInk4      = "#54546D" # darker foreground, e.g. linenumbers, fold column
waveBlue1     = "#223249" # popup background, visual selection background
waveBlue2     = "#2D4F67" # popup selection background, search background
winterGreen   = "#2B3328" # diff add background
winterYellow  = "#49443C" # diff change background
winterRed     = "#43242B" # diff deleted background
winterBlue    = "#252535" # diff line background
autumnGreen   = "#76946A" # git add
autumnRed     = "#C34043" # git delete
autumnYellow  = "#DCA561" # git change
samuraiRed    = "#E82424" # diagnostic error
roninYellow   = "#FF9E3B" # diagnostic warning
waveAqua1     = "#6A9589" # diagnostic info
dragonBlue    = "#658594" # diagnostic hint
fujiGray      = "#727169" # comments
springViolet1 = "#938AA9" # light foreground
oniViolet     = "#957FB8" # statements and keywords
crystalBlue   = "#7E9CD8" # functions and titles
springViolet2 = "#9CABCA" # brackets and punctuation
springBlue    = "#7FB4CA" # specials and builtins
lightBlue     = "#A3D4D5" # not used!
waveAqua2     = "#7AA89F" # types
springGreen   = "#98BB6C" # strings
boatYellow1   = "#938056" # not used
boatYellow2   = "#C0A36E" # operators, regex
carpYellow    = "#E6C384" # identifiers
sakuraPink    = "#D27E99" # numbers
waveRed       = "#E46876" # standout specials 1, e.g. builtin variables
peachRed      = "#FF5D62" # standout specials 2, e.g. exception handling, returns
surimiOrange  = "#FFA066" # constants, imports, booleans
katanaGray    = "#717C7C" # deprecated
l )* ; ) => {{ Box::new(provider::CommandProvider { get_cmd: provider::CommandConfig { prg: $get_prg, args: &[ $( $get_arg ),* ], }, set_cmd: provider::CommandConfig { prg: $set_prg, args: &[ $( $set_arg ),* ], }, get_primary_cmd: Some(provider::CommandConfig { prg: $pr_get_prg, args: &[ $( $pr_get_arg ),* ], }), set_primary_cmd: Some(provider::CommandConfig { prg: $pr_set_prg, args: &[ $( $pr_set_arg ),* ], }), }) }}; } pub fn get_clipboard_provider() -> Box<dyn ClipboardProvider> { // TODO: support for user-defined provider, probably when we have plugin support by setting a // variable? if exists("pbcopy") && exists("pbpaste") { command_provider! { paste => "pbpaste"; copy => "pbcopy"; } } else if env_var_is_set("WAYLAND_DISPLAY") && exists("wl-copy") && exists("wl-paste") { command_provider! { paste => "wl-paste", "--no-newline"; copy => "wl-copy", "--type", "text/plain"; primary_paste => "wl-paste", "-p", "--no-newline"; primary_copy => "wl-copy", "-p", "--type", "text/plain"; } } else if env_var_is_set("DISPLAY") && exists("xclip") { command_provider! { paste => "xclip", "-o", "-selection", "clipboard"; copy => "xclip", "-i", "-selection", "clipboard"; primary_paste => "xclip", "-o"; primary_copy => "xclip", "-i"; } } else if env_var_is_set("DISPLAY") && exists("xsel") && is_exit_success("xsel", &["-o", "-b"]) { // FIXME: check performance of is_exit_success command_provider! { paste => "xsel", "-o", "-b"; copy => "xsel", "-i", "-b"; primary_paste => "xsel", "-o"; primary_copy => "xsel", "-i"; } } else if exists("lemonade") { command_provider! { paste => "lemonade", "paste"; copy => "lemonade", "copy"; } } else if exists("doitclient") { command_provider! { paste => "doitclient", "wclip", "-r"; copy => "doitclient", "wclip"; } } else if exists("win32yank.exe") { // FIXME: does it work within WSL? command_provider! { paste => "win32yank.exe", "-o", "--lf"; copy => "win32yank.exe", "-i", "--crlf"; } } else if exists("termux-clipboard-set") && exists("termux-clipboard-get") { command_provider! { paste => "termux-clipboard-get"; copy => "termux-clipboard-set"; } } else if env_var_is_set("TMUX") && exists("tmux") { command_provider! { paste => "tmux", "save-buffer", "-"; copy => "tmux", "load-buffer", "-"; } } else { #[cfg(target_os = "windows")] return Box::new(provider::WindowsProvider::new()); #[cfg(not(target_os = "windows"))] return Box::new(provider::NopProvider::new()); } } fn exists(executable_name: &str) -> bool { which::which(executable_name).is_ok() } fn env_var_is_set(env_var_name: &str) -> bool { std::env::var_os(env_var_name).is_some() } fn is_exit_success(program: &str, args: &[&str]) -> bool { std::process::Command::new(program) .args(args) .output() .ok() .and_then(|out| out.status.success().then(|| ())) // TODO: use then_some when stabilized .is_some() } mod provider { use super::{ClipboardProvider, ClipboardType}; use anyhow::{bail, Context as _, Result}; use std::borrow::Cow; #[derive(Debug)] pub struct NopProvider { buf: String, primary_buf: String, } impl NopProvider { #[allow(dead_code)] // Only dead_code on Windows. pub fn new() -> Self { Self { buf: String::new(), primary_buf: String::new(), } } } impl ClipboardProvider for NopProvider { fn name(&self) -> Cow<str> { Cow::Borrowed("none") } fn get_contents(&self, clipboard_type: ClipboardType) -> Result<String> { let value = match clipboard_type { ClipboardType::Clipboard => self.buf.clone(), ClipboardType::Selection => self.primary_buf.clone(), }; Ok(value) } fn set_contents(&mut self, content: String, clipboard_type: ClipboardType) -> Result<()> { match clipboard_type { ClipboardType::Clipboard => self.buf = content, ClipboardType::Selection => self.primary_buf = content, } Ok(()) } } #[cfg(target_os = "windows")] #[derive(Debug)] pub struct WindowsProvider { selection_buf: String, } #[cfg(target_os = "windows")] impl WindowsProvider { pub fn new() -> Self { Self { selection_buf: String::new(), } } } #[cfg(target_os = "windows")] impl ClipboardProvider for WindowsProvider { fn name(&self) -> Cow<str> { Cow::Borrowed("clipboard-win") } fn get_contents(&self, clipboard_type: ClipboardType) -> Result<String> { match clipboard_type { ClipboardType::Clipboard => { let contents = clipboard_win::get_clipboard(clipboard_win::formats::Unicode)?; Ok(contents) } ClipboardType::Selection => Ok(String::new()), } } fn set_contents(&mut self, contents: String, clipboard_type: ClipboardType) -> Result<()> { match clipboard_type { ClipboardType::Clipboard => { clipboard_win::set_clipboard(clipboard_win::formats::Unicode, contents)?; } ClipboardType::Selection => {} }; Ok(()) } } #[derive(Debug)] pub struct CommandConfig { pub prg: &'static str, pub args: &'static [&'static str], } impl CommandConfig { fn execute(&self, input: Option<&str>, pipe_output: bool) -> Result<Option<String>> { use std::io::Write; use std::process::{Command, Stdio}; let stdin = input.map(|_| Stdio::piped()).unwrap_or_else(Stdio::null); let stdout = pipe_output.then(Stdio::piped).unwrap_or_else(Stdio::null); let mut child = Command::new(self.prg) .args(self.args) .stdin(stdin) .stdout(stdout) .stderr(Stdio::null()) .spawn()?; if let Some(input) = input { let mut stdin = child.stdin.take().context("stdin is missing")?; stdin .write_all(input.as_bytes()) .context("couldn't write in stdin")?; } // TODO: add timer? let output = child.wait_with_output()?; if !output.status.success() { bail!("clipboard provider {} failed", self.prg); } if pipe_output { Ok(Some(String::from_utf8(output.stdout)?)) } else { Ok(None) } } } #[derive(Debug)] pub struct CommandProvider { pub get_cmd: CommandConfig, pub set_cmd: CommandConfig, pub get_primary_cmd: Option<CommandConfig>, pub set_primary_cmd: Option<CommandConfig>, } impl ClipboardProvider for CommandProvider { fn name(&self) -> Cow<str> { if self.get_cmd.prg != self.set_cmd.prg { Cow::Owned(format!("{}+{}", self.get_cmd.prg, self.set_cmd.prg)) } else { Cow::Borrowed(self.get_cmd.prg) } } fn get_contents(&self, clipboard_type: ClipboardType) -> Result<String> { match clipboard_type { ClipboardType::Clipboard => Ok(self .get_cmd .execute(None, true)? .context("output is missing")?), ClipboardType::Selection => { if let Some(cmd) = &self.get_primary_cmd { return cmd.execute(None, true)?.context("output is missing"); } Ok(String::new()) } } } fn set_contents(&mut self, value: String, clipboard_type: ClipboardType) -> Result<()> { let cmd = match clipboard_type { ClipboardType::Clipboard => &self.set_cmd, ClipboardType::Selection => { if let Some(cmd) = &self.set_primary_cmd { cmd } else { return Ok(()); } } }; cmd.execute(Some(&value), false).map(|_| ()) } } }