diff options
author | Akshay <[email protected]> | 2020-07-22 03:34:08 +0100 |
---|---|---|
committer | Akshay <[email protected]> | 2020-07-22 03:34:08 +0100 |
commit | 51810b5c07e20982ebdf66f0bfb384c4bf55ad7d (patch) | |
tree | b5120bfc9b0ca72c9293afb9ed6e2e632a811deb /nvim/.config/nvim/plugin |
squash again
Diffstat (limited to 'nvim/.config/nvim/plugin')
-rw-r--r-- | nvim/.config/nvim/plugin/help.vim | 16 | ||||
-rw-r--r-- | nvim/.config/nvim/plugin/ignores.vim | 11 | ||||
-rw-r--r-- | nvim/.config/nvim/plugin/maps.vim | 78 | ||||
-rw-r--r-- | nvim/.config/nvim/plugin/statusline.vim | 136 | ||||
-rw-r--r-- | nvim/.config/nvim/plugin/textobjs.vim | 27 |
5 files changed, 268 insertions, 0 deletions
diff --git a/nvim/.config/nvim/plugin/help.vim b/nvim/.config/nvim/plugin/help.vim new file mode 100644 index 0000000..9e1c998 --- /dev/null +++ b/nvim/.config/nvim/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 = 1 | ||
16 | |||
diff --git a/nvim/.config/nvim/plugin/ignores.vim b/nvim/.config/nvim/plugin/ignores.vim new file mode 100644 index 0000000..3ab37f0 --- /dev/null +++ b/nvim/.config/nvim/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/nvim/.config/nvim/plugin/maps.vim b/nvim/.config/nvim/plugin/maps.vim new file mode 100644 index 0000000..55990d2 --- /dev/null +++ b/nvim/.config/nvim/plugin/maps.vim | |||
@@ -0,0 +1,78 @@ | |||
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 <Leader>l : Lines<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>w : MtaJumpToOtherTag<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 | cmap w!! %!sudo tee > /dev/null % | ||
30 | |||
31 | " visual | ||
32 | vnoremap > >gv | ||
33 | vnoremap < <gv | ||
34 | |||
35 | " operator-pending | ||
36 | onoremap ax a` | ||
37 | onoremap ix i` | ||
38 | |||
39 | " visual block | ||
40 | xnoremap + g<C-a> | ||
41 | xnoremap - g<C-x> | ||
42 | |||
43 | " COC keymaps | ||
44 | inoremap <silent><expr> <TAB> | ||
45 | \ pumvisible() ? "\<C-n>" : | ||
46 | \ <SID>check_back_space() ? "\<TAB>" : | ||
47 | \ coc#refresh() | ||
48 | inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>" | ||
49 | |||
50 | function! s:check_back_space() abort | ||
51 | let col = col('.') - 1 | ||
52 | return !col || getline('.')[col - 1] =~# '\s' | ||
53 | endfunction | ||
54 | |||
55 | inoremap <silent><expr> <c-space> coc#refresh() | ||
56 | |||
57 | inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>" | ||
58 | |||
59 | nmap <silent> [g <Plug>(coc-diagnostic-prev) | ||
60 | nmap <silent> ]g <Plug>(coc-diagnostic-next) | ||
61 | nmap <silent> gd <Plug>(coc-definition) | ||
62 | nmap <silent> gy <Plug>(coc-type-definition) | ||
63 | nmap <silent> gr <Plug>(coc-references) | ||
64 | |||
65 | nnoremap <silent> K :call <SID>show_documentation()<CR> | ||
66 | |||
67 | function! s:show_documentation() | ||
68 | if (index(['vim','help'], &filetype) >= 0) | ||
69 | execute 'h '.expand('<cword>') | ||
70 | else | ||
71 | call CocAction('doHover') | ||
72 | endif | ||
73 | endfunction | ||
74 | |||
75 | nmap <leader>rn <Plug>(coc-rename) | ||
76 | |||
77 | xmap <leader>f <Plug>(coc-format-selected) | ||
78 | nmap <leader>f <Plug>(coc-format-selected) | ||
diff --git a/nvim/.config/nvim/plugin/statusline.vim b/nvim/.config/nvim/plugin/statusline.vim new file mode 100644 index 0000000..a25fb6d --- /dev/null +++ b/nvim/.config/nvim/plugin/statusline.vim | |||
@@ -0,0 +1,136 @@ | |||
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=11 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=04 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=09 ctermbg=0 | ||
39 | |||
40 | highlight EndOfBuffer ctermfg=black ctermbg=black | ||
41 | |||
42 | function! GitBranch() | ||
43 | return system("git rev-parse --abbrev-ref HEAD 2>/dev/null | tr -d '\n'") | ||
44 | endfunction | ||
45 | |||
46 | function! StatuslineGit() | ||
47 | let l:branchname = GitBranch() | ||
48 | return strlen(l:branchname) > 0?' '.l:branchname.' ':'' | ||
49 | endfunction | ||
50 | |||
51 | function! 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 | ||
61 | endfunction | ||
62 | |||
63 | function! 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('%%8*%%f%%*%s %%m%%*', '%8*') | ||
72 | elseif empty(l:prefix) | ||
73 | return printf('%%8*%%f%%*%s %%m%%*', '%6*') | ||
74 | else | ||
75 | return printf('%%8*%s%%*%s%s%%*', l:prefix, &modified ? '%6*' : '%8*', l:filename) | ||
76 | endif | ||
77 | endfunction | ||
78 | |||
79 | function! LinterStatus() abort | ||
80 | let info = get(b:, 'coc_diagnostic_info', {}) | ||
81 | if empty(info) | return '' | endif | ||
82 | let msgs = [] | ||
83 | if get(info, 'error', 0) | ||
84 | call add(msgs, printf('%%5*%s×%%*', info['error'])) | ||
85 | endif | ||
86 | if get(info, 'warning', 0) | ||
87 | call add(msgs, printf('%%3*%s!%%*', info['warning'])) | ||
88 | endif | ||
89 | return join(msgs, ' ') | ||
90 | endfunction | ||
91 | |||
92 | function! StatusLine(mode) abort | ||
93 | let l:line='' | ||
94 | |||
95 | " help or man pages | ||
96 | if &filetype ==# 'help' || &filetype ==# 'man' | ||
97 | let l:line.=' %#StatusLineNC# ['. &filetype .'] %f ' | ||
98 | return l:line | ||
99 | endif | ||
100 | |||
101 | " active | ||
102 | if a:mode ==# 'active' | ||
103 | let l:line.='%7*%{StatuslineGit()}' | ||
104 | let l:line.='%<' | ||
105 | let l:line.=Filepath() | ||
106 | |||
107 | let l:line.='%5*' | ||
108 | let l:line.=' %{ReadOnly()} %w%*' | ||
109 | let l:line.='%9* %=%*' | ||
110 | |||
111 | let l:line.='%7* %l,%c %*' | ||
112 | let l:line.='%8* %{g:currentmode[mode()]}%*' | ||
113 | let l:line.=' ' | ||
114 | let l:line.=LinterStatus() | ||
115 | let l:line.=' ' | ||
116 | let l:line.='%8*'. &filetype | ||
117 | |||
118 | else | ||
119 | " inactive | ||
120 | let l:line.='%#Blanks#' | ||
121 | let l:line.='%f %5*%m%*' | ||
122 | let l:line.='%#Blanks# %=%*' | ||
123 | endif | ||
124 | |||
125 | let l:line.='%*' | ||
126 | |||
127 | return l:line | ||
128 | endfunction | ||
129 | |||
130 | set statusline=%!StatusLine('active') | ||
131 | augroup MyStatusLine | ||
132 | autocmd! | ||
133 | autocmd WinEnter * setl statusline=%!StatusLine('active') | ||
134 | autocmd WinLeave * setl statusline=%!StatusLine('inactive') | ||
135 | augroup END | ||
136 | |||
diff --git a/nvim/.config/nvim/plugin/textobjs.vim b/nvim/.config/nvim/plugin/textobjs.vim new file mode 100644 index 0000000..16f9a46 --- /dev/null +++ b/nvim/.config/nvim/plugin/textobjs.vim | |||
@@ -0,0 +1,27 @@ | |||
1 | " line text-objects | ||
2 | xnoremap il g_o^ | ||
3 | onoremap il :normal vil<CR> | ||
4 | xnoremap al $o0 | ||
5 | onoremap al :normal val<CR> | ||
6 | |||
7 | " buffer text-objects | ||
8 | " ------------------- | ||
9 | " i% a% | ||
10 | xnoremap i% :<C-u>let z = @/\|1;/^./kz<CR>G??<CR>:let @/ = z<CR>V'z | ||
11 | onoremap i% :normal vi%<CR> | ||
12 | xnoremap a% GoggV | ||
13 | onoremap a% :normal va%<CR> | ||
14 | |||
15 | " comment text-objects | ||
16 | " -------------------- | ||
17 | " i? a? | ||
18 | xnoremap <buffer> i? ?/\*<CR>o/\*\/<CR> | ||
19 | onoremap <buffer> i? :normal vi?<CR> | ||
20 | |||
21 | " square brackets text-objects | ||
22 | " ---------------------------- | ||
23 | " ir ar | ||
24 | xnoremap ir i[ | ||
25 | xnoremap ar a[ | ||
26 | onoremap ir :normal vi[<CR> | ||
27 | onoremap ar :normal va[<CR> | ||