From a93bb89b86eee5d41d7777bc3cf70359320b0da6 Mon Sep 17 00:00:00 2001
From: "Kenneth Benzie (Benie)" <benie@infektor.net>
Date: Sat, 12 Mar 2016 20:35:11 +0000
Subject: [PATCH] Move vim autocommands into ftdetect or ftplugin

---
 after/ftdetect/markdown.vim  |  2 ++
 after/ftdetect/opencl.vim    |  2 ++
 after/ftdetect/python.vim    |  2 ++
 after/ftdetect/tablegen.vim  |  2 ++
 after/ftplugin/c.vim         |  2 ++
 after/ftplugin/cmake.vim     | 14 ++++++++++++++
 after/ftplugin/gitcommit.vim |  3 +++
 after/ftplugin/help.vim      |  4 ++++
 after/ftplugin/html.vim      |  2 ++
 after/ftplugin/markdown.vim  |  6 ++++++
 after/ftplugin/snippets.vim  |  5 +++++
 after/ftplugin/text.vim      |  4 ++++
 after/ftplugin/vim.vim       |  1 +
 after/ftplugin/zsh.vim       |  1 +
 14 files changed, 50 insertions(+)
 create mode 100644 after/ftdetect/markdown.vim
 create mode 100644 after/ftdetect/opencl.vim
 create mode 100644 after/ftdetect/python.vim
 create mode 100644 after/ftdetect/tablegen.vim
 create mode 100644 after/ftplugin/cmake.vim
 create mode 100644 after/ftplugin/gitcommit.vim
 create mode 100644 after/ftplugin/help.vim
 create mode 100644 after/ftplugin/html.vim
 create mode 100644 after/ftplugin/markdown.vim
 create mode 100644 after/ftplugin/snippets.vim
 create mode 100644 after/ftplugin/text.vim
 create mode 100644 after/ftplugin/vim.vim
 create mode 100644 after/ftplugin/zsh.vim

diff --git a/after/ftdetect/markdown.vim b/after/ftdetect/markdown.vim
new file mode 100644
index 0000000..17ef121
--- /dev/null
+++ b/after/ftdetect/markdown.vim
@@ -0,0 +1,2 @@
+" Force *.md to markdown filetype
+au BufNewFile,BufReadPost *.md set filetype=markdown
diff --git a/after/ftdetect/opencl.vim b/after/ftdetect/opencl.vim
new file mode 100644
index 0000000..001d5ed
--- /dev/null
+++ b/after/ftdetect/opencl.vim
@@ -0,0 +1,2 @@
+" Force *.cl to OpenCL C filetype
+au BufNewFile,BufReadPost *.cl set filetype=opencl
diff --git a/after/ftdetect/python.vim b/after/ftdetect/python.vim
new file mode 100644
index 0000000..3a67625
--- /dev/null
+++ b/after/ftdetect/python.vim
@@ -0,0 +1,2 @@
+" Python convention is to use 4 space tabs.
+setlocal tabstop=4 shiftwidth=4 softtabstop=4
diff --git a/after/ftdetect/tablegen.vim b/after/ftdetect/tablegen.vim
new file mode 100644
index 0000000..4492ce7
--- /dev/null
+++ b/after/ftdetect/tablegen.vim
@@ -0,0 +1,2 @@
+" Force *.td to tablegen filetype
+au BufNewFile,BufReadPost *.td set filetype=tablegen
diff --git a/after/ftplugin/c.vim b/after/ftplugin/c.vim
index f46edaf..037103b 100644
--- a/after/ftplugin/c.vim
+++ b/after/ftplugin/c.vim
@@ -1,2 +1,4 @@
 " Set 'comments' to format dashed lists in comments.
 setlocal comments=sO:*\ -,mO:*\ \ ,exO:*/,s1:/*,mb:*,ex:*/,:///,://
+" Stop automatic new lines which typing long single liners
+setlocal textwidth=0
diff --git a/after/ftplugin/cmake.vim b/after/ftplugin/cmake.vim
new file mode 100644
index 0000000..f68caa2
--- /dev/null
+++ b/after/ftplugin/cmake.vim
@@ -0,0 +1,14 @@
+" TODO Create fold markers based on cmake syntax, eg.
+"
+"   if() <- open
+"   endif() <- close
+"
+"   foreach() <- open
+"   endforeach() <- close
+"
+" and so on for all other begin end style command pairs.
+"
+" Then change the setting.
+"
+"   setlocal foldmethod=syntax
+setlocal foldmethod=indent
diff --git a/after/ftplugin/gitcommit.vim b/after/ftplugin/gitcommit.vim
new file mode 100644
index 0000000..b551a3c
--- /dev/null
+++ b/after/ftplugin/gitcommit.vim
@@ -0,0 +1,3 @@
+if !has("win32") || has("gui_running")
+  setlocal spell
+endif
diff --git a/after/ftplugin/help.vim b/after/ftplugin/help.vim
new file mode 100644
index 0000000..d930f51
--- /dev/null
+++ b/after/ftplugin/help.vim
@@ -0,0 +1,4 @@
+" Disable spell checking which is enabled for text files
+setlocal nospell
+" Show help in the rightmost vertical split
+wincmd L
diff --git a/after/ftplugin/html.vim b/after/ftplugin/html.vim
new file mode 100644
index 0000000..34546e9
--- /dev/null
+++ b/after/ftplugin/html.vim
@@ -0,0 +1,2 @@
+" Set text and tab width for certain file types
+setlocal textwidth=80
diff --git a/after/ftplugin/markdown.vim b/after/ftplugin/markdown.vim
new file mode 100644
index 0000000..f6ad3c2
--- /dev/null
+++ b/after/ftplugin/markdown.vim
@@ -0,0 +1,6 @@
+if !has("win32") || has("gui_running")
+  setlocal spell
+endif
+setlocal textwidth=80
+" Use tabwidth of 4 to be markdown complient
+setlocal tabstop=4 shiftwidth=4 softtabstop=4
diff --git a/after/ftplugin/snippets.vim b/after/ftplugin/snippets.vim
new file mode 100644
index 0000000..47591dd
--- /dev/null
+++ b/after/ftplugin/snippets.vim
@@ -0,0 +1,5 @@
+" Disable expansion of tabs in snippet files as snippets must correctly insert
+" the current filetypes tab settings.
+setlocal noexpandtab
+" Set tab width to 4 spaces as UltiSnips supports inline python.
+setlocal tabstop=4 shiftwidth=4 softtabstop=4
diff --git a/after/ftplugin/text.vim b/after/ftplugin/text.vim
new file mode 100644
index 0000000..82f3384
--- /dev/null
+++ b/after/ftplugin/text.vim
@@ -0,0 +1,4 @@
+if !has("win32") || has("gui_running")
+  setlocal spell
+endif
+setlocal textwidth=80
diff --git a/after/ftplugin/vim.vim b/after/ftplugin/vim.vim
new file mode 100644
index 0000000..b18cb38
--- /dev/null
+++ b/after/ftplugin/vim.vim
@@ -0,0 +1 @@
+setlocal foldmethod=marker
diff --git a/after/ftplugin/zsh.vim b/after/ftplugin/zsh.vim
new file mode 100644
index 0000000..b18cb38
--- /dev/null
+++ b/after/ftplugin/zsh.vim
@@ -0,0 +1 @@
+setlocal foldmethod=marker