summaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
authorAkshay <[email protected]>2021-02-15 08:52:32 +0000
committerAkshay <[email protected]>2021-02-15 08:52:32 +0000
commitfcaf13a267b7bacd26ad8b2e952a793645e42bba (patch)
tree6e795b46b1fbefb05151e95c0346951d67fac4e7 /plugin
init
Diffstat (limited to 'plugin')
-rw-r--r--plugin/help.vim16
-rw-r--r--plugin/ignores.vim11
-rw-r--r--plugin/maps.vim46
-rw-r--r--plugin/statusline.vim139
4 files changed, 212 insertions, 0 deletions
diff --git a/plugin/help.vim b/plugin/help.vim
new file mode 100644
index 0000000..9e1c998
--- /dev/null
+++ b/plugin/help.vim
@@ -0,0 +1,16 @@
1" Only apply to .txt files...
2augroup HelpInTabs
3 autocmd!
4 autocmd BufEnter *.txt call HelpInNewTab()
5augroup END
6
7" Only apply to help files...
8function! 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
13endfunction
14
15let g:help_in_tabs = 1
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 @@
1set wildignore+=.git,.hg,.svn
2set wildignore+=*.aux,*.out,*.toc
3set wildignore+=*.o,*.obj,*.exe,*.dll,*.manifest,*.rbc,*.class
4set wildignore+=*.ai,*.bmp,*.gif,*.ico,*.jpg,*.jpeg,*.png,*.psd,*.webp
5set wildignore+=*.avi,*.divx,*.mp4,*.webm,*.mov,*.m2ts,*.mkv,*.vob,*.mpg,*.mpeg
6set wildignore+=*.mp3,*.oga,*.ogg,*.wav,*.flac
7set wildignore+=*.eot,*.otf,*.ttf,*.woff
8set wildignore+=*.doc,*.pdf,*.cbr,*.cbz
9set wildignore+=*.zip,*.tar.gz,*.tar.bz2,*.rar,*.tar.xz,*.kgb
10set wildignore+=*.swp,.lock,.DS_Store,._*
11
diff --git a/plugin/maps.vim b/plugin/maps.vim
new file mode 100644
index 0000000..188cb69
--- /dev/null
+++ b/plugin/maps.vim
@@ -0,0 +1,46 @@
1mapclear
2
3let mapleader=' '
4
5" clipboard
6map <leader>cc :w !xclip -sel c<CR>
7
8" normal
9nnoremap <Leader>o : only<cr>
10" nnoremap <Leader>l : Lines<cr>
11nnoremap <Leader>b : Buffers<cr>
12nnoremap <Leader>n : bnext<cr>
13nnoremap <Leader>p : bprev<cr>
14nnoremap <Leader>z : FZF<cr>
15nnoremap <Leader>l : Lines<cr>
16nnoremap <Leader>w : MtaJumpToOtherTag<cr>
17nnoremap <Leader>t : call GetTabber()<cr>
18nnoremap <Leader><ESC> : nohlsearch<cr>
19nnoremap <C-l> :nohlsearch<cr>:diffupdate<cr>:syntax sync fromstart<cr><c-l>
20nnoremap H H:exec 'norm! '. &scrolloff . 'k'<cr>
21nnoremap L L:exec 'norm! '. &scrolloff . 'j'<cr>
22nnoremap <expr> gb '`[' . strpart(getregtype(), 0, 1) . '`]'
23
24
25nnoremap <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
29cmap w!! %!sudo -S tee > /dev/null %
30
31" visual
32vnoremap > >gv
33vnoremap < <gv
34
35" operator-pending
36onoremap ax a`
37onoremap ix i`
38
39" visual block
40xnoremap + g<C-a>
41xnoremap - g<C-x>
42
43" completions
44inoremap <silent><expr> <C-Space> compe#complete()
45inoremap <silent><expr> <CR> compe#confirm('<CR>')
46inoremap <silent><expr> <C-e> compe#close('<C-e>')
diff --git a/plugin/statusline.vim b/plugin/statusline.vim
new file mode 100644
index 0000000..5465d40
--- /dev/null
+++ b/plugin/statusline.vim
@@ -0,0 +1,139 @@
1scriptencoding utf-8
2
3" statusline
4
5let 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
26hi PrimaryBlock ctermfg=00 ctermbg=6
27hi SecondaryBlock ctermfg=07 ctermbg=10
28hi Blanks ctermfg=08 ctermbg=0
29
30hi User1 ctermfg=01 ctermbg=0
31hi User2 ctermfg=02 ctermbg=0
32hi User3 ctermfg=03 ctermbg=0
33hi User4 ctermfg=12 ctermbg=0
34hi User5 ctermfg=05 ctermbg=0
35hi User6 ctermfg=06 ctermbg=0
36hi User7 ctermfg=07 ctermbg=0
37hi User8 ctermfg=08 ctermbg=0
38hi User9 ctermfg=00 ctermbg=0
39
40highlight EndOfBuffer ctermfg=black ctermbg=black
41
42function! GitBranch()
43 return system("git rev-parse --abbrev-ref HEAD 2>/dev/null | tr -d '\n'")
44endfunction
45
46function! StatuslineGit()
47 let l:branchname = GitBranch()
48 return strlen(l:branchname) > 0?l:branchname.' ':''
49endfunction
50
51function! ReadOnly() abort
52 if !&modifiable && &readonly
53 return ' RO'
54 elseif &modifiable && &readonly
55 return 'RO'
56 elseif !&modifiable && !&readonly
57 return ''
58 else
59 return ''
60 endif
61endfunction
62
63function! Filepath() abort
64 let l:basename = expand('%:h')
65 let l:filename = expand('%:t')
66 let l:extension = expand('%:e')
67 let l:prefix = (l:basename ==# '' || l:basename ==# '.') ?
68 \ '' : substitute(l:basename . '/', '\C^' . $HOME, '~', '')
69
70 if empty(l:prefix) && empty(l:filename)
71 return printf('%%4*%%f%%*%s %%m%%*', '%4*')
72 elseif empty(l:prefix)
73 return printf('%%4*%%f%%*%s %%m%%*', '%6*')
74 else
75 return printf('%%4*%s%%*%s%s%%*', l:prefix, &modified ? '%6*' : '%4*', l:filename)
76 endif
77endfunction
78
79function! 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.lsp.diagnostic.get_count(0, [[Error]])")
84 let warns = luaeval("vim.lsp.diagnostic.get_count(0, [[Warning]])")
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
95endfunction
96
97function! 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.='%6*·%*' . ' '
109 let l:line.='%7*%{StatuslineGit()}'
110 let l:line.='%<'
111 let l:line.=Filepath()
112
113 let l:line.='%5*'
114 let l:line.=' %{ReadOnly()} %w%*'
115 let l:line.='%9* %=%*'
116
117 let l:line.=' ' . '%7*%l,%c%*' . ' '
118 let l:line.=LinterStatus()
119 let l:line.='%4*'. &filetype
120
121 else
122 " inactive
123 let l:line.='%5*·%*' . ' '
124 let l:line.='%#Blanks#'
125 let l:line.='%f %5*%m%*'
126 let l:line.='%#Blanks# %=%*'
127 endif
128
129 let l:line.='%*'
130
131 return l:line
132endfunction
133
134set statusline=%!StatusLine('active')
135augroup MyStatusLine
136 autocmd!
137 autocmd WinEnter * setl statusline=%!StatusLine('active')
138 autocmd WinLeave * setl statusline=%!StatusLine('inactive')
139augroup END