diff options
Diffstat (limited to 'plugin')
-rw-r--r-- | plugin/help.vim | 16 | ||||
-rw-r--r-- | plugin/ignores.vim | 11 | ||||
-rw-r--r-- | plugin/maps.vim | 58 | ||||
-rw-r--r-- | plugin/statusline.vim | 137 |
4 files changed, 222 insertions, 0 deletions
diff --git a/plugin/help.vim b/plugin/help.vim new file mode 100644 index 0000000..decdab6 --- /dev/null +++ b/plugin/help.vim | |||
@@ -0,0 +1,16 @@ | |||
1 | " Only apply to .txt files... | ||
2 | augroup HelpInTabs | ||
3 | autocmd! | ||
4 | autocmd BufEnter *.txt call HelpInNewTab() | ||
5 | augroup END | ||
6 | |||
7 | " Only apply to help files... | ||
8 | function! HelpInNewTab () | ||
9 | if &buftype == 'help' && g:help_in_tabs | ||
10 | "Convert the help window to a tab... | ||
11 | execute "normal \<C-W>T" | ||
12 | endif | ||
13 | endfunction | ||
14 | |||
15 | let g:help_in_tabs = 0 | ||
16 | |||
diff --git a/plugin/ignores.vim b/plugin/ignores.vim new file mode 100644 index 0000000..3ab37f0 --- /dev/null +++ b/plugin/ignores.vim | |||
@@ -0,0 +1,11 @@ | |||
1 | set wildignore+=.git,.hg,.svn | ||
2 | set wildignore+=*.aux,*.out,*.toc | ||
3 | set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest,*.rbc,*.class | ||
4 | set wildignore+=*.ai,*.bmp,*.gif,*.ico,*.jpg,*.jpeg,*.png,*.psd,*.webp | ||
5 | set wildignore+=*.avi,*.divx,*.mp4,*.webm,*.mov,*.m2ts,*.mkv,*.vob,*.mpg,*.mpeg | ||
6 | set wildignore+=*.mp3,*.oga,*.ogg,*.wav,*.flac | ||
7 | set wildignore+=*.eot,*.otf,*.ttf,*.woff | ||
8 | set wildignore+=*.doc,*.pdf,*.cbr,*.cbz | ||
9 | set wildignore+=*.zip,*.tar.gz,*.tar.bz2,*.rar,*.tar.xz,*.kgb | ||
10 | set wildignore+=*.swp,.lock,.DS_Store,._* | ||
11 | |||
diff --git a/plugin/maps.vim b/plugin/maps.vim new file mode 100644 index 0000000..b61e994 --- /dev/null +++ b/plugin/maps.vim | |||
@@ -0,0 +1,58 @@ | |||
1 | mapclear | ||
2 | |||
3 | let mapleader=' ' | ||
4 | |||
5 | " clipboard | ||
6 | map <leader>cc :w !xclip -sel c<CR> | ||
7 | |||
8 | " normal | ||
9 | nnoremap <Leader>o : only<cr> | ||
10 | nnoremap - : b#<cr> | ||
11 | nnoremap <Leader>b : Buffers<cr> | ||
12 | nnoremap <Leader>n : bnext<cr> | ||
13 | nnoremap <Leader>p : bprev<cr> | ||
14 | nnoremap <Leader>z : FZF<cr> | ||
15 | nnoremap <Leader>l : Lines<cr> | ||
16 | nnoremap <Leader>e : Explore<cr> | ||
17 | nnoremap <Leader>t : call GetTabber()<cr> | ||
18 | nnoremap <Leader><ESC> : nohlsearch<cr> | ||
19 | nnoremap <C-l> :nohlsearch<cr>:diffupdate<cr>:syntax sync fromstart<cr><c-l> | ||
20 | nnoremap H H:exec 'norm! '. &scrolloff . 'k'<cr> | ||
21 | nnoremap L L:exec 'norm! '. &scrolloff . 'j'<cr> | ||
22 | nnoremap <expr> gb '`[' . strpart(getregtype(), 0, 1) . '`]' | ||
23 | |||
24 | |||
25 | nnoremap <F10> :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<' | ||
26 | \ . synIDattr(synID(line("."),col("."),0),"name") . "> lo<" | ||
27 | \ . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">"<CR> | ||
28 | |||
29 | nnoremap <Leader>s <Plug>(leap-forward-to) | ||
30 | nnoremap <Leader>S <Plug>(leap-backward-to) | ||
31 | |||
32 | cmap w!! %!sudo -S tee > /dev/null % | ||
33 | |||
34 | " visual | ||
35 | vnoremap > >gv | ||
36 | vnoremap < <gv | ||
37 | vnoremap <silent> * :<C-U> | ||
38 | \let old_reg=getreg('"')<Bar>let old_regtype=getregtype('"')<CR> | ||
39 | \gvy/<C-R>=&ic?'\c':'\C'<CR><C-R><C-R>=substitute( | ||
40 | \escape(@", '/\.*$^~['), '\_s\+', '\\_s\\+', 'g')<CR><CR> | ||
41 | \gVzv:call setreg('"', old_reg, old_regtype)<CR> | ||
42 | vnoremap <silent> # :<C-U> | ||
43 | \let old_reg=getreg('"')<Bar>let old_regtype=getregtype('"')<CR> | ||
44 | \gvy?<C-R>=&ic?'\c':'\C'<CR><C-R><C-R>=substitute( | ||
45 | \escape(@", '?\.*$^~['), '\_s\+', '\\_s\\+', 'g')<CR><CR> | ||
46 | \gVzv:call setreg('"', old_reg, old_regtype)<CR> | ||
47 | |||
48 | " operator-pending | ||
49 | onoremap ax a` | ||
50 | onoremap ix i` | ||
51 | |||
52 | " visual block | ||
53 | xnoremap + g<C-a> | ||
54 | xnoremap - g<C-x> | ||
55 | |||
56 | " completions | ||
57 | inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>" | ||
58 | inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>" | ||
diff --git a/plugin/statusline.vim b/plugin/statusline.vim new file mode 100644 index 0000000..a5264a4 --- /dev/null +++ b/plugin/statusline.vim | |||
@@ -0,0 +1,137 @@ | |||
1 | scriptencoding utf-8 | ||
2 | |||
3 | " statusline | ||
4 | |||
5 | let g:currentmode={ | ||
6 | \ 'n' : 'NORMAL ', | ||
7 | \ 'no' : 'N·OPERATOR PENDING ', | ||
8 | \ 'v' : 'VISUAL ', | ||
9 | \ 'V' : 'V·LINE ', | ||
10 | \ '' : 'V·BLOCK ', | ||
11 | \ 's' : 'SELECT ', | ||
12 | \ 'S' : 'S·LINE ', | ||
13 | \ '' : 'S·BLOCK ', | ||
14 | \ 'i' : 'INSERT ', | ||
15 | \ 'R' : 'REPLACE ', | ||
16 | \ 'Rv' : 'V·REPLACE ', | ||
17 | \ 'c' : 'COMMAND ', | ||
18 | \ 'cv' : 'VIM EX ', | ||
19 | \ 'ce' : 'EX ', | ||
20 | \ 'r' : 'PROMPT ', | ||
21 | \ 'rm' : 'MORE ', | ||
22 | \ 'r?' : 'CONFIRM ', | ||
23 | \ '!' : 'SHELL ', | ||
24 | \ 't' : 'TERMINAL '} | ||
25 | |||
26 | hi PrimaryBlock ctermfg=00 ctermbg=6 | ||
27 | hi SecondaryBlock ctermfg=07 ctermbg=10 | ||
28 | hi Blanks ctermfg=08 ctermbg=0 | ||
29 | |||
30 | hi User1 ctermfg=01 ctermbg=0 | ||
31 | hi User2 ctermfg=02 ctermbg=0 | ||
32 | hi User3 ctermfg=03 ctermbg=0 | ||
33 | hi User4 ctermfg=12 ctermbg=0 | ||
34 | hi User5 ctermfg=05 ctermbg=0 | ||
35 | hi User6 ctermfg=06 ctermbg=0 | ||
36 | hi User7 ctermfg=07 ctermbg=0 | ||
37 | hi User8 ctermfg=08 ctermbg=0 | ||
38 | hi User9 ctermfg=00 ctermbg=0 | ||
39 | |||
40 | highlight EndOfBuffer ctermfg=black ctermbg=black | ||
41 | |||
42 | function! ReadOnly() abort | ||
43 | if !&modifiable && &readonly | ||
44 | return ' RO' | ||
45 | elseif &modifiable && &readonly | ||
46 | return 'RO' | ||
47 | elseif !&modifiable && !&readonly | ||
48 | return '' | ||
49 | else | ||
50 | return '' | ||
51 | endif | ||
52 | endfunction | ||
53 | |||
54 | function! Filepath() abort | ||
55 | let l:basename = expand('%:h') | ||
56 | let l:filename = expand('%:t') | ||
57 | let l:extension = expand('%:e') | ||
58 | let l:prefix = (l:basename ==# '' || l:basename ==# '.') ? | ||
59 | \ '' : substitute(l:basename . '/', '\C^' . $HOME, '~', '') | ||
60 | |||
61 | if empty(l:prefix) && empty(l:filename) | ||
62 | return printf('%%4*%%f%%*%s %%m%%*', '%4*') | ||
63 | elseif empty(l:prefix) | ||
64 | return printf('%%4*%%f%%*%s %%m%%*', '%6*') | ||
65 | else | ||
66 | return printf('%%4*%s%%*%s%s%%*', l:prefix, &modified ? '%6*' : '%4*', l:filename) | ||
67 | endif | ||
68 | endfunction | ||
69 | |||
70 | function! QuickFixStatus() abort | ||
71 | let l:qfl=getqflist() | ||
72 | let l:qftitle = getqflist({'title' : 0}).title | ||
73 | if len(qfl) != 0 | ||
74 | return l:qftitle | ||
75 | else | ||
76 | return '' | ||
77 | endfunction | ||
78 | |||
79 | function! LinterStatus() abort | ||
80 | let sl = '' | ||
81 | let msgs = [] | ||
82 | if luaeval('not vim.tbl_isempty(vim.lsp.buf_get_clients(0))') | ||
83 | let errs = luaeval("#vim.diagnostic.get(0, { severity = vim.diagnostic.severity.ERROR })") | ||
84 | let warns = luaeval("#vim.diagnostic.get(0, { severity = vim.diagnostic.severity.WARN })") | ||
85 | if errs != 0 | ||
86 | call add(msgs, printf('%%5*%s×%%* ', errs)) | ||
87 | endif | ||
88 | if warns != 0 | ||
89 | call add(msgs, printf('%%3*%s!%%* ', warns)) | ||
90 | endif | ||
91 | return join(msgs, '') | ||
92 | else | ||
93 | return '' | ||
94 | endif | ||
95 | endfunction | ||
96 | |||
97 | function! StatusLine(mode) abort | ||
98 | let l:line='' | ||
99 | |||
100 | " help or man pages | ||
101 | if &filetype ==# 'help' || &filetype ==# 'man' | ||
102 | let l:line.=' %#StatusLineNC# ['. &filetype .'] %f ' | ||
103 | return l:line | ||
104 | endif | ||
105 | |||
106 | " active | ||
107 | if a:mode ==# 'active' | ||
108 | let l:line.=Filepath() | ||
109 | let l:line.='%5*' | ||
110 | let l:line.=QuickFixStatus() | ||
111 | |||
112 | let l:line.='%5*' | ||
113 | let l:line.=' %{ReadOnly()} %w%*' | ||
114 | let l:line.='%9* %=%*' | ||
115 | |||
116 | let l:line.=' ' . '%7*%l,%c%*' . ' ' | ||
117 | let l:line.=LinterStatus() | ||
118 | let l:line.='%4*'. &filetype | ||
119 | |||
120 | else | ||
121 | " inactive | ||
122 | let l:line.='%#Blanks#' | ||
123 | let l:line.='%f %5*%m%*' | ||
124 | let l:line.='%#Blanks# %=%*' | ||
125 | endif | ||
126 | |||
127 | let l:line.='%*' | ||
128 | |||
129 | return l:line | ||
130 | endfunction | ||
131 | |||
132 | set statusline=%!StatusLine('active') | ||
133 | augroup MyStatusLine | ||
134 | autocmd! | ||
135 | autocmd WinEnter * setl statusline=%!StatusLine('active') | ||
136 | autocmd WinLeave * setl statusline=%!StatusLine('inactive') | ||
137 | augroup END | ||