aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2019-06-14 22:20:05 +1200
committerTom Ryder <tom@sanctum.geek.nz>2019-06-14 22:20:05 +1200
commitc11c409c60603e6735833a2a57cf90c6e83567e6 (patch)
tree8e36a3e8de08c09842c408f91f07a07fa7b1300a
parentMove autocmd definitions out of augroup block (diff)
downloaddotfiles-c11c409c60603e6735833a2a57cf90c6e83567e6.tar.gz
dotfiles-c11c409c60603e6735833a2a57cf90c6e83567e6.zip
Replace and refactor Vim paste plugins
-rw-r--r--.gitmodules3
-rw-r--r--vim/autoload/paste_insert.vim14
m---------vim/bundle/paste_open0
-rw-r--r--vim/plugin/paste_insert.vim6
-rw-r--r--vim/vimrc17
5 files changed, 29 insertions, 11 deletions
diff --git a/.gitmodules b/.gitmodules
index 86bad115..77c7e443 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -29,9 +29,6 @@
[submodule "vim/bundle/insert_timeout"]
path = vim/bundle/insert_timeout
url = https://sanctum.geek.nz/code/vim-insert-timeout.git
-[submodule "vim/bundle/paste_open"]
- path = vim/bundle/paste_open
- url = https://sanctum.geek.nz/code/vim-paste-open.git
[submodule "vim/bundle/put_blank_lines"]
path = vim/bundle/put_blank_lines
url = https://sanctum.geek.nz/code/vim-put-blank-lines.git
diff --git a/vim/autoload/paste_insert.vim b/vim/autoload/paste_insert.vim
new file mode 100644
index 00000000..fe7cb35f
--- /dev/null
+++ b/vim/autoload/paste_insert.vim
@@ -0,0 +1,14 @@
+augroup paste_insert
+ autocmd!
+augroup END
+
+function! paste_insert#() abort
+ autocmd! paste_insert
+ autocmd paste_insert CursorHold,CursorMoved,User <buffer>
+ \ set nopaste paste?
+ \|autocmd! paste_insert
+ autocmd paste_insert InsertEnter <buffer>
+ \ set paste paste?
+ \|autocmd paste_insert InsertLeave <buffer>
+ \ doautocmd paste_insert User
+endfunction
diff --git a/vim/bundle/paste_open b/vim/bundle/paste_open
deleted file mode 160000
-Subproject 79ee83eac32dbadf722df687e65f07d75a2f8ea
diff --git a/vim/plugin/paste_insert.vim b/vim/plugin/paste_insert.vim
new file mode 100644
index 00000000..be578746
--- /dev/null
+++ b/vim/plugin/paste_insert.vim
@@ -0,0 +1,6 @@
+if exists('loaded_paste_insert')
+ finish
+endif
+let loaded_paste_insert = 1
+command! -bar PasteInsert
+ \ call paste_insert#()
diff --git a/vim/vimrc b/vim/vimrc
index 124e3af7..f5dfc8fd 100644
--- a/vim/vimrc
+++ b/vim/vimrc
@@ -1254,10 +1254,6 @@ xmap <Leader>n <Esc><Leader>ngv
nnoremap <Leader>N
\ :<C-U>set ruler! ruler?<CR>
xmap <Leader>N <Esc><Leader>Ngv
-"" Leader,p toggles paste mode
-nnoremap <Leader>p
- \ :<C-U>set paste! paste?<CR>
-xmap <Leader>p <Esc><Leader>pgv
"" Leader,w toggles soft wrapping
nnoremap <Leader>w
\ :<C-U>setlocal wrap! wrap?<CR>
@@ -1317,6 +1313,15 @@ nnoremap <Leader>L
\ :<C-U>ToggleFlagLocal colorcolumn +1<CR>
xmap <Leader>L <Esc><Leader>Lgv
+" This mapping uses my paste_insert.vim plugin to queue up automatic commands
+" for the next insert operation. It's still pretty new. It replaces my old
+" paste_open.vim plugin which did this only for opening new lines, and which
+" kept confusing me. I'm hoping this will be better.
+
+"" Leader,p prepares the next insert for paste mode
+nnoremap <Leader>p
+ \ :<C-U>PasteInsert<CR>
+
" These mappings are for managing filetypes. The first one uses the
" :ReloadFileType command that was defined much earlier in this file for
" application in the vimrc reload command.
@@ -1494,10 +1499,6 @@ nnoremap <Leader>?
"" Leader,. runs the configured make program into the location list
nnoremap <Leader>.
\ :<C-U>lmake!<CR>
-"" Leader,o opens a line below in paste mode
-nmap <Leader>o <Plug>(PasteOpenBelow)
-"" Leader,O opens a line above in paste mode
-nmap <Leader>O <Plug>(PasteOpenAbove)
"" Leader,q formats the current paragraph
nnoremap <Leader>q gqap
"" Leader,r acts as a replacement operator