aboutsummaryrefslogtreecommitdiffhomepage
path: root/sundry/misc/editor-syntax-etc/vim/ftplugin/sisu.vim
blob: 43c7e531fedf612ceaa0c50c3378e873b0fc3f49 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
"%% SiSU Vim ftplugin
" SiSU Maintainer: Ralph Amissah <ralph@amissah.com>
" SiSU Markup:     SiSU (sisu-3.3) 2012-08-18
" an ftplugin setting defaults for editing sisu markup files
:syntax on
:filetype off
":filetype on
:filetype indent on
:autocmd FileType sisu :set nonumber
:set encoding=utf-8 fileencodings=
:set ff=unix
:set autowrite          " Automatically save before commands like :next and :make
:set nocompatible
:set tabstop=2
:set expandtab
:set shiftwidth=2
:set autoindent
:set showcmd            " Show (partial) command in status line.
:set showmatch          " Show matching brackets.
:set ignorecase         " Do case insensitive matching
:set smartcase
:set incsearch
:set hlsearch
:set gdefault
:set guioptions=agr     " add 'm' for menu
:map <silent> <C-m> :if &guioptions =~# 'm' <Bar>
    \set guioptions-=m <Bar>
    \set guioptions-=T <Bar>
  \else <Bar>
    \set guioptions+=m <Bar>
    \set guioptions-=T <Bar>
  \endif<CR>
:set paste
""% statusline
"set statusline=                                  "
"set fillchars=stl:―,stlnc:—,vert:│,fold:۰,diff:·
"" [ buffer number ]
"set statusline +=%#Normal#[                      "
"set statusline +=%#Identifier#%n                 " buffer number
"set statusline +=%#PreProc#%M                    " modified flag
"set statusline +=%#Normal#]                      "
"" [ file name (& modified?) ]
"set statusline +=%#Normal#\ [                    "
"set statusline +=%#Statement#%<%F%*              " full path
""set statusline +=%#Statement#%<%t               " full path
"set statusline +=%#PreProc#%M                    " modified flag
"set statusline +=%#Normal#]                      "
"" [ column : line number / number of lines in file, percentage of file ] [%v:%l/%L\ %p%%]
"set statusline +=%#Normal#\ [                    "
"set statusline +=%#Identifier#%v                 " column & line
"set statusline +=%#Normal#:                      "
"set statusline +=%#Identifier#%l                 " column & line
"set statusline +=%#SpecialKey#/%L\               " total lines
"set statusline +=%#Identifier#%p                 " percentage of file
"set statusline +=%#SpecialKey#%%                 "
"set statusline +=%#Normal#]     "                "
"" [ file format : file type ]
"set statusline +=%#Normal#\ [                    "
"set statusline +=%#SpecialKey#%{&fenc}           " file format
"set statusline +=%#Normal#:                      "
"set statusline +=%#SpecialKey#%{&ff}             " file format
"set statusline +=%#Normal#:                      "
"set statusline +=%#SpecialKey#%y                 " file type
"set statusline +=%#Normal#]                      "
"" [ character under cursor ]
"set statusline +=%#Normal#\ [                    "
"set statusline +=%#String#0x%04B                 " character under cursor
"set statusline +=%#Normal#]\                     "
"" [ syntastic ]
"set statusline +=%#warningmsg#
"set statusline +=%{SyntasticStatuslineFlag()}\   "
""set statusline+=%*
""  Status line background
"set statusline +=%#Folded#\                  "
"" misc
"set laststatus=2                                 " status line always on
"% textwrap
:set whichwrap=<,>,h,l,[,]
:set nolinebreak        " only affects display not buffer
:set wrap
:set wrapmargin=0
"% map
":let mapleader = ","    " consider
:map <leader>paste :set invpaste<cr>
"% wrap/formatting paragraph according to the current 'textwidth' with ^\ (control-\):
:imap <C-\> <C-O>gqap
:nmap <C-\>      gqap
:vmap <C-\>      gq
"% save file, go to next file in buffer
:map <leader>nf :w <enter> :n <enter>
"% vimdiff q exits
:if &diff
:  cmap q qa
:endif
"% directory files, placed in vertical split window
:map <leader>ls :vs<cr> :Explore<cr>
:map <leader>dir :vs<cr> :Explore<cr>
"% remapping lines make cursor jump a line at a time within wrapped text
:nnoremap j gj
:nnoremap k gk
:vnoremap j gj
:vnoremap k gk
:nnoremap <Down> gj
:nnoremap <Up> gk
:vnoremap <Down> gj
:vnoremap <Up> gk
:inoremap <Down> <C-o>gj
:inoremap  <Up> <C-o>gk
"% search and replace
:map <leader>rd :.,$s///c "search and replace down
:map <leader>rg :%s///c "search and replace whole file
:map <leader>rr :rubyd gsub!(//,"")
"% pwd t64 working directory set to that of the file you're editing
"changes pwd to directory of file in current buffer
:function! CHANGE_CURR_DIR()
:  let _dir = expand("%:p:h")
:    exec "cd " . _dir
:    unlet _dir
:endfunction
"% Change to the directory the file in your current buffer is in
:if has("autocmd")
   autocmd BufEnter * :lcd %:p:h
:endif
"% autocompletefilenames To search for files in the current directory
:set path=,,
"auto-completion for file to edit in current dir, used in normal mode
:map <leader>e :e <c-r>=expand("%:p:h") . "/" <cr>
:map <leader>pwd :exe 'cd ' . expand ("%:p:h")<cr>
"% searchhighlight t93: Toggle search highlight <C-n>
:function! ToggleHLSearched()
:  if &hls
:    set nohls
:  else
:    set hls
:  endif
:endfun
:nmap <silent> <C-n> :silent call ToggleHLSearched()<cr>
"%% SiSU vim folds
"% foldsearchx FoldSearch (opens result of search all else closed) t77
:map <leader>fs :set foldmethod=expr foldcolumn=2 foldlevel=0 <cr>
:map <leader>ff :F<cr>
:map <leader>fe :F<cr> zE
"% foldtoggle Fold Toggle mapped to <space>
:fun! ToggleFold()
:  if foldlevel('.') == 0
:    normal! l
:  else
:    if foldclosed('.') < 0
:      foldclose
:    else
:      foldopen
:    endif
:  endif
"  Clear status line
:  echo
:endfun
" Map this function to Space key.
:noremap <space> :call ToggleFold()<cr>
"% foldtype Fold? set foldtext
:set foldtext=v:folddashes.substitute(getline(v:foldstart),'\\=','','g',)
:set foldexpr=getline(v:lnum-1)!~@/&&getline(v:lnum)!~@/&&getline(v:lnum+1)!~@/
"% foldsearch t77: Fold on search result
:function! FoldMake(search)
:  set fdm=manual
:  normal zE
:  normal G$
:  let folded = 0     "flag to set when a fold is found
:  let flags = "w"    "allow wrapping in the search
:  let line1 =  0     "set marker for beginning of fold
:  while search(a:search, flags) > 0
:    let  line2 = line(".")
:      if (line2 -1 > line1)
:        "echo line1 . ":" . (line2-1)
:        "echo "a fold goes here."
:        execute ":" . line1 . "," . (line2-1) . "fold"
:        let folded = 1       "at least one fold has been found
:     endif
:     let line1 = line2     "update marker
:     let flags = "W"       "turn off wrapping
:  endwhile
"  create the last fold which goes to the end of the file.
:  normal $G
:  let  line2 = line(".")
:  if (line2  > line1 && folded == 1)
:    execute ":". line1 . "," . line2 . "fold"
:  endif
:  normal 1G
:endfunction
"% folds Fold Patterns
:command! -nargs=+ -complete=command FMake call FoldMake(<q-args>)
:  if ( &filetype == "ruby" )
:    command! F FMake ^# ==\?\|^\s*\(\(def\|class\|module\)\s\|\(public\|protected\|private\|__END__\)\s*$\)\|\(^\s*\|\s\+\)#%\s
:    command! Fa FMake \(^# ==\?\|^\s*\(\(\(def\|class\|module\)\s\)\|\(\(public\|protected\|private\|__END__\)\(\s*$\)\)\)\)\|^[0-9]\~\|\([#%]\|^["]\)\{1,4\}\s*%\|{\({\|!!\)
:    command! FD FMake \(^# ==\?\|^\s*\(\(def\|class\|module\)\s\)\)\|^\s*\([#%"0-9]\{0,4\}\~\(%\+\s\|!!\)\|#\s\+=\+\s\+\)
:  else
"% folds :F Fold Patterns SiSU Markup :F
:    command! F FMake  ^\([1-8]\|:\?[A-C]\)\~\|\(^%\|\(^\|\s\+\)[#"]\)%\{1,2\}\(\s\|$\)\|^<<\s*|
:    command! Fa FMake ^\([1-8]\|:\?[A-C]\)\~\|\(^%\|\(^\|\s\+\)[#"]\)%\{1,2\}\(\s\|$\)\|^<<\s*|\|^\(Book\|Part\|Chapter\|Section\|Article\|BOOK\|PART\|CHAPTER\|SECTION\|ARTICLE\)\s
:    command! F0 FMake ^\(\s*0\~\|@\S\+:[+-]\?\s\+\)
:    command! FA FMake ^:\?A\~
:    command! FB FMake ^:\?[AB]\~
:    command! FC FMake ^:\?[A-C]\~
:    command! F1 FMake ^\(:\?[A-C]\|1\)\~
:    command! F2 FMake ^\(:\?[A-C]\|[12]\)\~
:    command! F3 FMake ^\(:\?[A-C]\|[1-3]\)\~
:    command! F4 FMake ^[1-4]\~
:    command! F5 FMake ^[4-5]\~
:    command! F6 FMake ^[4-6]\~
:    command! Fc FMake ^[%]\+\s\+
:  endif
"% folds Fold Patterns misc
":command! Fp FMake ^\s*[A-Za-z0-9#]
:command! Fp FMake ^\s*\S
:command! Fo FMake ^[%\"]\s*[{>]
"% linenumbering, on, relative, off
:map <Leader>nn :set <c-r>={'00':'','01':'r','10':'nor'}[&rnu.&nu]<CR>nu<CR>
"% cursorline
:map <leader>cu :if &cursorcolumn <Bar>
    \set nocursorline nocursorcolumn <Bar>
  \else <Bar>
    \set cursorline cursorcolumn <Bar>
  \endif<cr>
:map <leader>cu- :set nocursorline nocursorcolumn<cr>
:map <leader>cu+ :set cursorline cursorcolumn<cr>