Skip to content

Commit 348e4ac

Browse files
committed
Version 2
1 parent 7499145 commit 348e4ac

File tree

6 files changed

+576
-198
lines changed

6 files changed

+576
-198
lines changed

README.md

+62-18
Original file line numberDiff line numberDiff line change
@@ -29,55 +29,99 @@ Plug 'segeljakt/vim-silicon'
2929

3030
# Commands
3131

32-
The available commands are `Silicon`, and `SiliconHighlight`:
32+
This plugin provides a single command `Silicon`:
3333

3434
```vim
3535
" Generate an image of the current buffer and write it to /path/to/output.png
3636
:Silicon /path/to/output.png
3737
38+
" Generate an image of the current buffer and write it to /path/to/output.png and clipboard.
39+
:Silicon /path/to/output.png --to-clipboard
40+
3841
" Generate an image of the current buffer and write it to /path/to/<filename>.png
3942
:Silicon /path/to/
4043
4144
" Generate an image of the current visual line selection and write it to /path/to/output.png
4245
:'<,'>Silicon /path/to/output.png
4346
4447
" Generate an image of the current buffer, with the current visual line selection highlighted.
45-
:'<,'>SiliconHighlight /path/to/output.png
48+
:'<,'>Silicon! /path/to/output.png
4649
```
4750

48-
If no `/path/to/output.png` is specified, then the generated image is copied to clipboard. However, this feature is only supported on Linux at the moment.
49-
5051
# Options
5152

5253
This is the default configuration:
5354

5455
```vim
5556
let g:silicon = {
56-
\ 'theme': 'Dracula',
57-
\ 'font': 'Hack',
58-
\ 'background': '#aaaaff',
59-
\ 'shadow-color': '#555555',
60-
\ 'line-pad': 2,
61-
\ 'pad-horiz': 80,
62-
\ 'pad-vert': 100,
63-
\ 'shadow-blur-radius': 0,
64-
\ 'shadow-offset-x': 0,
65-
\ 'shadow-offset-y': 0,
66-
\ 'line-number': v:true,
67-
\ 'round-corner': v:true,
68-
\ 'window-controls': v:true,
69-
\ 'default-file-pattern' '',
57+
\ 'theme': 'Dracula',
58+
\ 'font': 'Hack',
59+
\ 'background': '#AAAAFF',
60+
\ 'shadow-color': '#555555',
61+
\ 'line-pad': 2,
62+
\ 'pad-horiz': 80,
63+
\ 'pad-vert': 100,
64+
\ 'shadow-blur-radius': 0,
65+
\ 'shadow-offset-x': 0,
66+
\ 'shadow-offset-y': 0,
67+
\ 'line-number': v:true,
68+
\ 'round-corner': v:true,
69+
\ 'window-controls': v:true,
7070
\ }
7171
```
7272

73+
Images are by default saved to the working directory with a unique filename,
74+
you can change this filepath by setting:
75+
76+
```vim
77+
let g:silicon['output'] = '~/images/silicon-{time:%Y-%m-%d-%H%M%S}.png'
78+
```
79+
7380
To get the list of available themes, you can run this in the terminal:
7481

7582
```sh
7683
silicon --list-themes
7784
```
7885

86+
Silicon internally uses [`bat`'s](https://github.com/sharkdp/bat) themes and syntaxes. To get the list of supported languages, you could:
87+
88+
```sh
89+
cargo install bat
90+
bat --list-languages
91+
```
92+
7993
For more details about options, see https://github.com/Aloxaf/silicon.
8094

95+
## Advanced Configuration
96+
97+
Instead of assigning values to flags in g:silicon, you can assign functions which expand into values right before generating the images.
98+
99+
For example, to save images into different directories depending on whether you are at work or not:
100+
101+
```vim
102+
let s:workhours = {
103+
\ 'Monday': [8, 16],
104+
\ 'Tuesday': [9, 17],
105+
\ 'Wednesday': [9, 17],
106+
\ 'Thursday': [9, 17],
107+
\ 'Friday': [9, 15],
108+
\ }
109+
110+
function! s:working()
111+
let day = strftime('%u')
112+
if has_key(s:workhours, day)
113+
let hour = strftime('%H')
114+
let [start_hour, stop_hour] = s:workhours[day]
115+
if start_hour <= hour && hour <= stop_hour
116+
return "~/Work-Snippets/"
117+
endif
118+
endif
119+
return "~/Personal-Snippets/"
120+
endfunction
121+
122+
let g:silicon['output'] = function('s:working')
123+
```
124+
81125
# Credits
82126

83127
Credits goes to:

0 commit comments

Comments
 (0)