xaizek / vim-preamble (License: Unspecified) (since 2018-12-07)
Preamble Vim plugin by Mel Davis with a couple of fixes.
Commit 7a8b897b87ce36e1a28fbd5c7dda990530d9e0cb

Improve parsing to handle comments in PHP
Author: xaizek
Author date (UTC): 2016-02-08 21:26
Committer name: xaizek
Committer date (UTC): 2016-02-08 21:26
Parent(s): 7eac6cee0b0081ba2e145cb72188fb3a9923f43b
Signing key:
Tree: 6da07ba721ae8091f7c971560989a49b91b98cdd
File Lines added Lines deleted
autoload/Preamble.vim 27 11
File autoload/Preamble.vim changed (mode: 100644) (index 92950b9..7890ef4)
... ... endfunction
170 170 fun! s:Length() fun! s:Length()
171 171
172 172 let line_pos = 1 let line_pos = 1
173 let is_blankline = 1
174 173
175 174 while(line_pos <= s:preamble_max_lines) while(line_pos <= s:preamble_max_lines)
175 let synId = synID(line_pos, 1, 1)
176 let realSynId = synIDtrans(synId)
177 let attrName = synIDattr( realSynId, 'name' )
178 " skip shebang in python
179 if attrName == 'PreProc'
180 let line_pos += 1
181 continue
182 endif
183
184 " skip <?php line in PHP sources
185 if attrName == 'Delimiter'
186 let line_pos += 1
187 break
188 endif
176 189
177 190 " skip blank lines at top of file " skip blank lines at top of file
178 if is_blankline && getline(line_pos) =~ '\S'
179 let is_blankline = 0
191 if getline(line_pos) =~ '\S'
192 break
180 193 endif endif
181 194
195 let line_pos += 1
196 endwhile
197
198 while(line_pos <= s:preamble_max_lines)
182 199 " assume each line of a preamble has a character in col one " assume each line of a preamble has a character in col one
183 if !is_blankline
184 let synId = synID(line_pos, 1, 1)
185 let realSynId = synIDtrans(synId)
186 let attrName = synIDattr( realSynId, 'name' )
187 if attrName != 'Comment' && !s:IsInString(line_pos)
188 break
189 endif
200 let synStack = synstack(line_pos, 1)
201 let synId = empty(synStack) ? 0 : synStack[-1]
202 let realSynId = synIDtrans(synId)
203 let attrName = synIDattr( realSynId, 'name' )
204 if attrName != 'Comment' && !s:IsInString(line_pos)
205 break
190 206 endif endif
191 207
192 let line_pos = line_pos + 1
208 let line_pos += 1
193 209 endwhile endwhile
194 210
195 211 return line_pos-1 return line_pos-1
Hints

Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://code.reversed.top/user/xaizek/vim-preamble

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@code.reversed.top/user/xaizek/vim-preamble

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a pull request:
... clone the repository ...
... make some changes and some commits ...
git push origin master