Skip to content
This repository was archived by the owner on Oct 21, 2022. It is now read-only.

Commit 1c0d762

Browse files
committed
Move function to autoload folder
Does this have any effect on startup time? I don't know.
1 parent 85d866d commit 1c0d762

File tree

3 files changed

+47
-41
lines changed

3 files changed

+47
-41
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ git clone https://github.com/h3xx/vim-shitespace.git ~/.vim/pack/dist/start/vim-
3232
Vim 7 and older:
3333

3434
```sh
35-
mkdir -p ~/.vim/plugin
35+
mkdir -p ~/.vim/{autoload,plugin}
36+
wget -O ~/.vim/autoload/shitespace.vim https://raw.githubusercontent.com/h3xx/vim-shitespace/main/autoload/shitespace.vim
3637
wget -O ~/.vim/plugin/shitespace.vim https://raw.githubusercontent.com/h3xx/vim-shitespace/main/plugin/shitespace.vim
3738
```
3839

@@ -90,7 +91,7 @@ lightweight.
9091

9192
## License
9293

93-
Copyright (C) 2021 Dan Church.
94+
Copyright (C) 2021-2022 Dan Church.
9495

9596
License GPLv3+: GNU GPL version 3 or later (http://gnu.org/licenses/gpl.html).
9697
This is free software: you are free to change and redistribute it. There is NO

autoload/shitespace.vim

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
" Shitespace -- Show bad whitespace
2+
" Source: https://github.com/h3xx/vim-shitespace
3+
" Author: Dan Church [ h3xx{azzzzat}gmx{dizzzzot}com; h3xx@GitHub ]
4+
" Last Change: 2022-09-13
5+
6+
if exists('g:shitespaceColor')
7+
let s:color = g:shitespaceColor
8+
else
9+
let s:color = 'red'
10+
endif
11+
if exists('g:shitespaceMatch')
12+
let s:matchpat = g:shitespaceMatch
13+
else
14+
" Show trailing whitespace and spaces before a tab
15+
let s:matchpat = '/\s\+$\| \+\ze\t/'
16+
endif
17+
18+
let s:on = 0
19+
function! shitespace#Toggle()
20+
let s:on = !s:on
21+
if s:on
22+
let l:matchcmd = 'match ExtraWhitespace ' . s:matchpat
23+
let l:hlcmd = 'hi ExtraWhitespace term=reverse ctermbg=' . s:color . ' guibg=' . s:color
24+
exe l:hlcmd
25+
aug Shitespace
26+
" If the user changes the colorscheme while Shitespace is on, keep
27+
" highlights.
28+
exe 'autocmd ColorScheme * ' . l:hlcmd
29+
exe 'autocmd BufEnter,WinEnter * ' . l:matchcmd
30+
aug END
31+
else
32+
hi clear ExtraWhitespace
33+
aug Shitespace
34+
au!
35+
aug END
36+
endif
37+
endfunction
38+
39+
" vi: noet sts=4 sw=4 ts=4

plugin/shitespace.vim

Lines changed: 5 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -31,60 +31,26 @@
3131
" If you don't like mixed spaces-and-tabs, stick this in your ~/.vimrc:
3232
" let g:shitespaceMatch = '/\s\+$\| \+\t\+\|\t\+ \+/'
3333
"
34-
" Updated: 2021-01-18
34+
" Updated: 2022-09-13
3535
" Version: 0.1.0
3636
" Source: https://github.com/h3xx/vim-shitespace
3737
" Project: https://github.com/h3xx/vim-shitespace
3838
" Author: Dan Church [ h3xx{azzat}gmx{dizzot}com; h3xx@GitHub ]
3939
" License: GPLv3 (http://www.gnu.org/licenses/gpl.html)
4040
"
41-
" Copyright (C) 2015-2021 Dan Church
41+
" Copyright (C) 2015-2022 Dan Church
4242
" License GPLv3+: GNU GPL version 3 or later (http://gnu.org/licenses/gpl.html).
4343
" This is free software: you are free to change and redistribute it. There is
4444
" NO WARRANTY, to the extent permitted by law.
4545

4646
if exists('g:shitespaceShortcut')
4747
" e.g. let g:shitespaceShortcut = '<F5>'
48-
exec 'imap <silent> ' . g:shitespaceShortcut . " <C-o>:call Shitespace_toggle()<cr>"
49-
exec 'nmap <silent> ' . g:shitespaceShortcut . " :call Shitespace_toggle()<cr>"
48+
exec 'imap <silent> ' . g:shitespaceShortcut . " <C-o>:call shitespace#Toggle()<cr>"
49+
exec 'nmap <silent> ' . g:shitespaceShortcut . " :call shitespace#Toggle()<cr>"
5050
endif
5151

52-
if exists('g:shitespaceColor')
53-
let s:color = g:shitespaceColor
54-
else
55-
let s:color = 'red'
56-
endif
57-
if exists('g:shitespaceMatch')
58-
let s:matchpat = g:shitespaceMatch
59-
else
60-
" Show trailing whitespace and spaces before a tab
61-
let s:matchpat = '/\s\+$\| \+\ze\t/'
62-
endif
63-
64-
65-
let s:on = 0
66-
function! Shitespace_toggle()
67-
let s:on = !s:on
68-
if s:on
69-
let l:matchcmd = 'match ExtraWhitespace ' . s:matchpat
70-
let l:hlcmd = 'hi ExtraWhitespace term=reverse ctermbg=' . s:color . ' guibg=' . s:color
71-
exe l:hlcmd
72-
aug Shitespace
73-
" If the user changes the colorscheme while Shitespace is on, keep
74-
" highlights.
75-
exe 'autocmd ColorScheme * ' . l:hlcmd
76-
exe 'autocmd BufEnter,WinEnter * ' . l:matchcmd
77-
aug END
78-
else
79-
hi clear ExtraWhitespace
80-
aug Shitespace
81-
au!
82-
aug END
83-
endif
84-
endfunction
85-
8652
if !exists('g:shitespaceDefaultOn') || g:shitespaceDefaultOn
87-
call Shitespace_toggle()
53+
call shitespace#Toggle()
8854
endif
8955

9056
" vi: noet sts=4 sw=4 ts=4

0 commit comments

Comments
 (0)