aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2018-06-29 23:24:06 +1200
committerTom Ryder <tom@sanctum.geek.nz>2018-06-29 23:24:06 +1200
commitad69b8aca286a9aa5f95f920199370e5512abcf7 (patch)
treecae556b33a548283a82dfadb2e38bbf2cd1652d7
parentRefine 'comments' ftplugins further (diff)
downloaddotfiles-ad69b8aca286a9aa5f95f920199370e5512abcf7.tar.gz
dotfiles-ad69b8aca286a9aa5f95f920199370e5512abcf7.zip
Use ftplugins for filetype mappings instead
-rw-r--r--.gitmodules3
-rw-r--r--Makefile2
-rw-r--r--vim/after/ftplugin/diff/maps.vim23
-rw-r--r--vim/after/ftplugin/html/maps.vim25
-rw-r--r--vim/after/ftplugin/make/maps.vim21
-rw-r--r--vim/after/ftplugin/perl/maps.vim25
-rw-r--r--vim/after/ftplugin/php/maps.vim21
-rw-r--r--vim/after/ftplugin/sh/maps.vim23
-rw-r--r--vim/after/ftplugin/vim/maps.vim (renamed from vim/after/ftplugin/vim/clear_maps.vim)22
-rw-r--r--vim/after/ftplugin/zsh/maps.vim21
m---------vim/bundle/clear_local_maps0
-rw-r--r--vim/filemap.vim55
-rw-r--r--vim/vimrc1
13 files changed, 171 insertions, 71 deletions
diff --git a/.gitmodules b/.gitmodules
index 939eed66..0e03292a 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -5,9 +5,6 @@
[submodule "vim/bundle/big_file_options"]
path = vim/bundle/big_file_options
url = https://sanctum.geek.nz/code/vim-big-file-options.git
-[submodule "vim/bundle/clear_local_maps"]
- path = vim/bundle/clear_local_maps
- url = https://sanctum.geek.nz/code/vim-clear-local-maps.git
[submodule "vim/bundle/copy_linebreak"]
path = vim/bundle/copy_linebreak
url = https://sanctum.geek.nz/code/vim-copy-linebreak.git
diff --git a/Makefile b/Makefile
index d031574c..81d2e711 100644
--- a/Makefile
+++ b/Makefile
@@ -548,7 +548,7 @@ install-vim-config:
cp -p -- vim/vimrc $(VIMRC)
install-vim-filetype:
- cp -p -- vim/filemap.vim vim/filetype.vim vim/scripts.vim $(VIMDIR)
+ cp -p -- vim/filetype.vim vim/scripts.vim $(VIMDIR)
install-vim-ftplugin:
mkdir -p -- $(VIMDIR)/ftplugin
diff --git a/vim/after/ftplugin/diff/maps.vim b/vim/after/ftplugin/diff/maps.vim
new file mode 100644
index 00000000..f4ef8fd6
--- /dev/null
+++ b/vim/after/ftplugin/diff/maps.vim
@@ -0,0 +1,23 @@
+" diff/maps.vim: tejr's mappings for 'diff' filetypes
+
+" Don't load if running compatible or too old
+if &compatible || v:version < 700
+ finish
+endif
+
+" Don't load if already loaded
+if exists('b:did_ftplugin_diff_maps')
+ finish
+endif
+
+" Flag as loaded
+let b:did_ftplugin_diff_maps = 1
+let b:undo_ftplugin = b:undo_ftplugin
+ \ . '|unlet b:did_ftplugin_diff_maps'
+
+" Set mappings
+nmap <buffer> <LocalLeader>p <Plug>DiffPrune
+xmap <buffer> <LocalLeader>p <Plug>DiffPrune
+let b:undo_ftplugin = b:undo_ftplugin
+ \ . '|nunmap <buffer> <LocalLeader>p'
+ \ . '|xunmap <buffer> <LocalLeader>p'
diff --git a/vim/after/ftplugin/html/maps.vim b/vim/after/ftplugin/html/maps.vim
new file mode 100644
index 00000000..e355d0e6
--- /dev/null
+++ b/vim/after/ftplugin/html/maps.vim
@@ -0,0 +1,25 @@
+" html/maps.vim: tejr's mappings for 'html' filetypes
+
+" Don't load if running compatible or too old
+if &compatible || v:version < 700
+ finish
+endif
+
+" Don't load if already loaded
+if exists('b:did_ftplugin_html_maps')
+ finish
+endif
+
+" Flag as loaded
+let b:did_ftplugin_html_maps = 1
+let b:undo_ftplugin = b:undo_ftplugin
+ \ . '|unlet b:did_ftplugin_html_maps'
+
+" Set mappings
+nmap <buffer> <LocalLeader>l <Plug>HtmlLint
+nmap <buffer> <LocalLeader>r <Plug>HtmlUrlLink
+nmap <buffer> <LocalLeader>t <Plug>HtmlTidy
+let b:undo_ftplugin = b:undo_ftplugin
+ \ . '|nunmap <buffer> <LocalLeader>l'
+ \ . '|nunmap <buffer> <LocalLeader>r'
+ \ . '|nunmap <buffer> <LocalLeader>t'
diff --git a/vim/after/ftplugin/make/maps.vim b/vim/after/ftplugin/make/maps.vim
new file mode 100644
index 00000000..bfe82891
--- /dev/null
+++ b/vim/after/ftplugin/make/maps.vim
@@ -0,0 +1,21 @@
+" make/maps.vim: tejr's mappings for 'make' filetypes
+
+" Don't load if running compatible or too old
+if &compatible || v:version < 700
+ finish
+endif
+
+" Don't load if already loaded
+if exists('b:did_ftplugin_make_maps')
+ finish
+endif
+
+" Flag as loaded
+let b:did_ftplugin_make_maps = 1
+let b:undo_ftplugin = b:undo_ftplugin
+ \ . '|unlet b:did_ftplugin_make_maps'
+
+" Set mappings
+nmap <buffer> <LocalLeader>m <Plug>MakeTarget
+let b:undo_ftplugin = b:undo_ftplugin
+ \ . '|nunmap <buffer> <LocalLeader>m'
diff --git a/vim/after/ftplugin/perl/maps.vim b/vim/after/ftplugin/perl/maps.vim
new file mode 100644
index 00000000..fe5def10
--- /dev/null
+++ b/vim/after/ftplugin/perl/maps.vim
@@ -0,0 +1,25 @@
+" perl/maps.vim: tejr's mappings for 'perl' filetypes
+
+" Don't load if running compatible or too old
+if &compatible || v:version < 700
+ finish
+endif
+
+" Don't load if already loaded
+if exists('b:did_ftplugin_perl_maps')
+ finish
+endif
+
+" Flag as loaded
+let b:did_ftplugin_perl_maps = 1
+let b:undo_ftplugin = b:undo_ftplugin
+ \ . '|unlet b:did_ftplugin_perl_maps'
+
+" Set mappings
+nmap <buffer> <LocalLeader>c <Plug>PerlCheck
+nmap <buffer> <LocalLeader>l <Plug>PerlLint
+nmap <buffer> <LocalLeader>t <Plug>PerlTidy
+let b:undo_ftplugin = b:undo_ftplugin
+ \ . '|nunmap <buffer> <LocalLeader>c'
+ \ . '|nunmap <buffer> <LocalLeader>l'
+ \ . '|nunmap <buffer> <LocalLeader>t'
diff --git a/vim/after/ftplugin/php/maps.vim b/vim/after/ftplugin/php/maps.vim
new file mode 100644
index 00000000..32cc8388
--- /dev/null
+++ b/vim/after/ftplugin/php/maps.vim
@@ -0,0 +1,21 @@
+" php/maps.vim: tejr's mappings for 'php' filetypes
+
+" Don't load if running compatible or too old
+if &compatible || v:version < 700
+ finish
+endif
+
+" Don't load if already loaded
+if exists('b:did_ftplugin_php_maps')
+ finish
+endif
+
+" Flag as loaded
+let b:did_ftplugin_php_maps = 1
+let b:undo_ftplugin = b:undo_ftplugin
+ \ . '|unlet b:did_ftplugin_php_maps'
+
+" Set mappings
+nmap <buffer> <LocalLeader>c <Plug>PhpCheck
+let b:undo_ftplugin = b:undo_ftplugin
+ \ . '|nunmap <buffer> <LocalLeader>c'
diff --git a/vim/after/ftplugin/sh/maps.vim b/vim/after/ftplugin/sh/maps.vim
new file mode 100644
index 00000000..e93a84c4
--- /dev/null
+++ b/vim/after/ftplugin/sh/maps.vim
@@ -0,0 +1,23 @@
+" sh/maps.vim: tejr's mappings for 'sh' filetypes
+
+" Don't load if running compatible or too old
+if &compatible || v:version < 700
+ finish
+endif
+
+" Don't load if already loaded
+if exists('b:did_ftplugin_sh_maps')
+ finish
+endif
+
+" Flag as loaded
+let b:did_ftplugin_sh_maps = 1
+let b:undo_ftplugin = b:undo_ftplugin
+ \ . '|unlet b:did_ftplugin_sh_maps'
+
+" Set mappings
+nmap <buffer> <LocalLeader>c <Plug>ShCheck
+nmap <buffer> <LocalLeader>l <Plug>ShLint
+let b:undo_ftplugin = b:undo_ftplugin
+ \ . '|nunmap <buffer> <LocalLeader>c'
+ \ . '|nunmap <buffer> <LocalLeader>l'
diff --git a/vim/after/ftplugin/vim/clear_maps.vim b/vim/after/ftplugin/vim/maps.vim
index a84ca4b9..7f2a07a0 100644
--- a/vim/after/ftplugin/vim/clear_maps.vim
+++ b/vim/after/ftplugin/vim/maps.vim
@@ -1,5 +1,4 @@
-" vim/clear_maps.vim: Fix clearing buffer-local vim maps that the core
-" ftplugin leaves in place
+" vim/maps.vim: tejr's mappings for 'vim' filetypes
" Don't load if running compatible or too old
if &compatible || v:version < 700
@@ -7,21 +6,22 @@ if &compatible || v:version < 700
endif
" Don't load if already loaded
-if exists('b:did_ftplugin_vim_lint')
- finish
-endif
-
-" Don't load if the mappings probably weren't loaded in the first place
-if exists('g:no_plugin_maps') || exists('g:no_vim_maps')
+if exists('b:did_ftplugin_vim_maps')
finish
endif
" Flag as loaded
-let b:did_ftplugin_vim_clear_maps = 1
+let b:did_ftplugin_vim_maps = 1
let b:undo_ftplugin = b:undo_ftplugin
- \ . '|unlet b:did_ftplugin_vim_clear_maps'
+ \ . '|unlet b:did_ftplugin_vim_maps'
-" Add undo commands
+" Set mappings
+nmap <buffer> <LocalLeader>l <Plug>VimLint
+let b:undo_ftplugin = b:undo_ftplugin
+ \ . '|nunmap <buffer> <LocalLeader>l'
+
+" Add undo commands to fix clearing buffer-local vim maps that the core
+" ftplugin leaves in place
let b:undo_ftplugin = b:undo_ftplugin
\ . '|silent! nunmap <buffer> [['
\ . '|silent! vunmap <buffer> [['
diff --git a/vim/after/ftplugin/zsh/maps.vim b/vim/after/ftplugin/zsh/maps.vim
new file mode 100644
index 00000000..a670df46
--- /dev/null
+++ b/vim/after/ftplugin/zsh/maps.vim
@@ -0,0 +1,21 @@
+" zsh/maps.zsh: tejr's mappings for 'zsh' filetypes
+
+" Don't load if running compatible or too old
+if &compatible || v:version < 700
+ finish
+endif
+
+" Don't load if already loaded
+if exists('b:did_ftplugin_zsh_maps')
+ finish
+endif
+
+" Flag as loaded
+let b:did_ftplugin_zsh_maps = 1
+let b:undo_ftplugin = b:undo_ftplugin
+ \ . '|unlet b:did_ftplugin_zsh_maps'
+
+" Set mappings
+nmap <buffer> <LocalLeader>c <Plug>ZshCheck
+let b:undo_ftplugin = b:undo_ftplugin
+ \ . '|nunmap <buffer> <LocalLeader>c'
diff --git a/vim/bundle/clear_local_maps b/vim/bundle/clear_local_maps
deleted file mode 160000
-Subproject 61fb4c0926d4f26014e1765bf6d22c1d968c6f8
diff --git a/vim/filemap.vim b/vim/filemap.vim
deleted file mode 100644
index d20a2037..00000000
--- a/vim/filemap.vim
+++ /dev/null
@@ -1,55 +0,0 @@
-" Filetype-specific mappings
-if &compatible || v:version < 700 || !has('autocmd')
- finish
-endif
-
-" No 'loaded' guard; this file is an extension of our .vimrc, and we do want
-" to reload it if the .vimrc is re-sourced.
-
-" Set up filetype mapping hooks
-augroup filetypemap
- autocmd!
-
- " Clear existing local leader maps if possible
- autocmd FileType *
- \ silent! call clear_local_maps#Clear()
-
- " Diff: prune sections
- autocmd FileType diff
- \ nmap <buffer> <LocalLeader>p <Plug>DiffPrune
- \|xmap <buffer> <LocalLeader>p <Plug>DiffPrune
-
- " HTML: lint, URL-to-link, tidy
- autocmd FileType html
- \ nmap <buffer> <LocalLeader>l <Plug>HtmlLint
- \|nmap <buffer> <LocalLeader>r <Plug>HtmlUrlLink
- \|nmap <buffer> <LocalLeader>t <Plug>HtmlTidy
-
- " Makefile: make target
- autocmd FileType make
- \ nmap <buffer> <LocalLeader>m <Plug>MakeTarget
-
- " Perl: check, lint, and tidy
- autocmd FileType perl
- \ nmap <buffer> <LocalLeader>c <Plug>PerlCheck
- \|nmap <buffer> <LocalLeader>l <Plug>PerlLint
- \|nmap <buffer> <LocalLeader>t <Plug>PerlTidy
-
- " PHP: check
- autocmd FileType php
- \ nmap <buffer> <LocalLeader>c <Plug>PhpCheck
-
- " Shell: check and lint
- autocmd FileType sh
- \ nmap <buffer> <LocalLeader>c <Plug>ShCheck
- \|nmap <buffer> <LocalLeader>l <Plug>ShLint
-
- " VimL: lint
- autocmd FileType vim
- \ nmap <buffer> <LocalLeader>l <Plug>VimLint
-
- " Zsh: check
- autocmd FileType zsh
- \ nmap <buffer> <LocalLeader>c <Plug>ZshCheck
-
-augroup END
diff --git a/vim/vimrc b/vim/vimrc
index a0722a7c..1067d09a 100644
--- a/vim/vimrc
+++ b/vim/vimrc
@@ -8,7 +8,6 @@
if has('autocmd')
let g:maplocalleader = '_'
filetype plugin indent on
- runtime filemap.vim
endif
" Options dependent on the syntax feature