Révision | 17ea707f3bd57c677a3c7a566296a2a831c4061e (tree) |
---|---|
l'heure | 2018-02-24 08:03:56 |
Auteur | Markus Prepens <markus.prepens@gmai...> |
Commiter | Markus Prepens |
Merge branch 'master' of https://github.com/analogbit/nvim
@@ -9,7 +9,7 @@ | ||
9 | 9 | function! shellcommand#Run(cmdLine) |
10 | 10 | |
11 | 11 | if !exists("s:outputBuffer") |
12 | - let s:outputBuffer = tempname() | |
12 | + let s:outputBuffer = "[SCRun]" | |
13 | 13 | endif |
14 | 14 | |
15 | 15 | let winnr = bufwinnr(s:outputBuffer) |
@@ -27,7 +27,7 @@ function! shellcommand#Run(cmdLine) | ||
27 | 27 | else |
28 | 28 | " No ShellCommand buffer |
29 | 29 | execute "edit " . s:outputBuffer |
30 | - setlocal noswapfile nowrap | |
30 | + setlocal noswapfile nowrap buftype=nofile | |
31 | 31 | endif |
32 | 32 | |
33 | 33 | let cmdRun = "" |
@@ -23,15 +23,15 @@ endfunction | ||
23 | 23 | " Description: Delete empty lines around cursor. |
24 | 24 | function! s:OneBlankLine() |
25 | 25 | while line('.') > 1 && empty(getline(line('.') - 1)) |
26 | - normal kdd | |
26 | + normal k"_dd | |
27 | 27 | endwhile |
28 | 28 | while line('.') < line('$') && empty(getline(line('.'))) && empty(getline(line('.') + 1)) |
29 | - normal dd | |
29 | + normal "_dd | |
30 | 30 | endwhile |
31 | 31 | " Top and last lines needs special treatment. |
32 | 32 | if line('.') == 1 || line('.') == line('$') |
33 | 33 | if empty(getline('.')) |
34 | - normal dd | |
34 | + normal "_dd | |
35 | 35 | endif |
36 | 36 | endif |
37 | 37 | endfunction |
@@ -40,10 +40,10 @@ endfunction | ||
40 | 40 | function! s:OneSpace() |
41 | 41 | if s:CharUnderCursor("curr") == " " |
42 | 42 | while s:CharUnderCursor("prev") == " " && getcurpos()[2] > 1 |
43 | - normal hx | |
43 | + normal h"_x | |
44 | 44 | endwhile |
45 | 45 | while s:CharUnderCursor("next") == " " |
46 | - normal x | |
46 | + normal "_x | |
47 | 47 | endwhile |
48 | 48 | endif |
49 | 49 | endfunction |
@@ -98,7 +98,7 @@ set completeopt=menu | ||
98 | 98 | set pumheight=10 |
99 | 99 | |
100 | 100 | " Command line completion |
101 | -set nowildmenu wildmode=list:full | |
101 | +set nowildmenu wildmode=list:longest | |
102 | 102 | set wildignorecase |
103 | 103 | set wildignore=*.*~ |
104 | 104 |
@@ -125,19 +125,15 @@ set diffopt=context:3,vertical,iwhite,filler | ||
125 | 125 | " Note: 'cursorline' may delay cursor movement in buffer with filetype 'c'. |
126 | 126 | " This behavior may be caused by Doxygen syntax highlighting. |
127 | 127 | function! s:TurnCursorLineOn() |
128 | - | |
129 | 128 | if g:use_sticky_cursorline !=0 && &diff == 0 && &buftype == "" |
130 | 129 | set cursorline |
131 | 130 | endif |
132 | - | |
133 | 131 | endfunction |
134 | 132 | |
135 | 133 | function! ToggleStickyCursorLine() |
136 | - | |
137 | 134 | if !exists("g:use_sticky_cursorline") |
138 | 135 | let g:use_sticky_cursorline = 0 |
139 | 136 | endif |
140 | - | |
141 | 137 | if g:use_sticky_cursorline == 0 |
142 | 138 | let g:use_sticky_cursorline = 1 |
143 | 139 | set cursorline |
@@ -153,25 +149,20 @@ function! ToggleStickyCursorLine() | ||
153 | 149 | au! |
154 | 150 | augroup END |
155 | 151 | endif |
156 | - | |
157 | 152 | endfunction |
158 | 153 | |
159 | 154 | " Description: Jump to last location. Check out :help line(). Function checks |
160 | 155 | " if the '" marker is valid. Jump to the mark, but don't change the jumplist |
161 | 156 | " when jumping within the current buffer (:help g'). |
162 | 157 | function! RestoreCursor () |
163 | - | |
164 | 158 | if line("'\"") > 1 && line("'\"") <= line("$") |
165 | 159 | exe "normal! g'\"" |
166 | 160 | endif |
167 | - | |
168 | 161 | endfunction |
169 | 162 | |
170 | 163 | " Description: A context sensitve file movement function. |
171 | 164 | function! FastForwardAndRewind(direction) |
172 | - | |
173 | 165 | if a:direction == "fastforward" |
174 | - | |
175 | 166 | if &diff |
176 | 167 | normal ]czz |
177 | 168 | elseif &filetype == "diff" |
@@ -183,9 +174,7 @@ function! FastForwardAndRewind(direction) | ||
183 | 174 | else |
184 | 175 | normal ]] |
185 | 176 | endif |
186 | - | |
187 | 177 | elseif a:direction == "rewind" |
188 | - | |
189 | 178 | if &diff |
190 | 179 | normal [czz |
191 | 180 | elseif &filetype == "diff" |
@@ -197,32 +186,38 @@ function! FastForwardAndRewind(direction) | ||
197 | 186 | else |
198 | 187 | normal [[ |
199 | 188 | endif |
200 | - | |
201 | 189 | endif |
202 | - | |
203 | 190 | endfunction |
204 | 191 | |
205 | 192 | function! HiName() |
206 | - | |
207 | 193 | let synid = synID(line("."), col("."), 0) |
208 | 194 | let synidtrans = synIDtrans(synid) |
209 | 195 | echo synIDattr(synidtrans, "name") |
210 | - | |
211 | 196 | endfunction |
212 | 197 | |
198 | +" Description: My splash screen (with one-liner Vim script in it) | |
213 | 199 | function! Welcome() |
214 | - | |
215 | 200 | let l:welcome_text_file = '~/Documents/welcome.txt' |
216 | - | |
217 | 201 | if filereadable(expand(l:welcome_text_file)) |
218 | 202 | execute 'edit ' . l:welcome_text_file |
219 | 203 | nmap <buffer> <CR> 0y$:<C-r>"<CR> |
220 | 204 | endif |
205 | +endfunction | |
221 | 206 | |
207 | +" Description: Create or move to buffer ClipboardTxt, start to write text, | |
208 | +" switch to another application and copy the clipboard, filled with | |
209 | +" ClipboardTxt. | |
210 | +function! ClipboardBuffer() | |
211 | + if bufexists("ClipboardTxt") | |
212 | + buffer ClipboardTxt | |
213 | + else | |
214 | + edit ClipboardTxt | |
215 | + setlocal buftype=nofile | |
216 | + autocmd FocusLost clipboard.txt normal gg"*yG | |
217 | + endif | |
222 | 218 | endfunction |
223 | 219 | |
224 | 220 | function! HighlightWord(word) |
225 | - | |
226 | 221 | if !exists("s:thisHighlightWord") |
227 | 222 | let s:thisHighlightWord = "" |
228 | 223 | endif |
@@ -234,7 +229,6 @@ function! HighlightWord(word) | ||
234 | 229 | let s:thisHighlightWord = "" |
235 | 230 | match none |
236 | 231 | endif |
237 | - | |
238 | 232 | endfunction |
239 | 233 | |
240 | 234 | " }}} |
@@ -254,7 +248,6 @@ command! -nargs=0 SwitchWorkspace call workspace#Switch() | ||
254 | 248 | command! -nargs=0 ShowHiName call HiName() |
255 | 249 | command! -nargs=0 ToggleStickyCursorline call ToggleStickyCursorLine() |
256 | 250 | |
257 | - | |
258 | 251 | command! -nargs=0 WhitespaceCleanup call whitespace#Cleanup() |
259 | 252 | command! -nargs=0 WhitespaceMelt call whitespace#Melt() |
260 | 253 |
@@ -327,6 +320,7 @@ nnoremap <Leader>h :call HighlightWord("<C-r><C-w>")<CR> | ||
327 | 320 | nnoremap <Leader>tn :$tabnew<CR> |
328 | 321 | nnoremap <Leader>tc :tabclose<CR> |
329 | 322 | |
323 | +nnoremap <Leader>c :call ClipboardBuffer()<CR> | |
330 | 324 | nnoremap <Leader>dt :ToggleVimdiff<CR> |
331 | 325 | nnoremap <Leader>du :wa <BAR> diffupdate<CR> |
332 | 326 | nnoremap <Leader>do :VimdiffFileContext<CR> |
@@ -398,8 +392,7 @@ cnoremap <A-.> <C-r>=expand("%:p:h")<CR> | ||
398 | 392 | |
399 | 393 | " }}} |
400 | 394 | |
401 | - | |
402 | -" Save when losing focus | |
395 | +" Save when Neovim's losing or gaining focus | |
403 | 396 | augroup ginit |
404 | 397 | " clear group in case file sourced several times |
405 | 398 | autocmd! |