Added webdev to eclim
This commit is contained in:
196
vim/bundle/eclim/autoload/eclim/dltk/buildpath.vim
Normal file
196
vim/bundle/eclim/autoload/eclim/dltk/buildpath.vim
Normal file
@@ -0,0 +1,196 @@
|
||||
" Author: Eric Van Dewoestine
|
||||
"
|
||||
" Description: {{{
|
||||
" see http://eclim.org/vim/php/buildpath.html
|
||||
"
|
||||
" License:
|
||||
"
|
||||
" Copyright (C) 2005 - 2013 Eric Van Dewoestine
|
||||
"
|
||||
" This program is free software: you can redistribute it and/or modify
|
||||
" it under the terms of the GNU General Public License as published by
|
||||
" the Free Software Foundation, either version 3 of the License, or
|
||||
" (at your option) any later version.
|
||||
"
|
||||
" This program is distributed in the hope that it will be useful,
|
||||
" but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
" GNU General Public License for more details.
|
||||
"
|
||||
" You should have received a copy of the GNU General Public License
|
||||
" along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
"
|
||||
" }}}
|
||||
|
||||
" Script Variables {{{
|
||||
let s:command_variables = '-command dltk_buildpath_variables'
|
||||
let s:command_variable_create =
|
||||
\ '-command dltk_buildpath_variable_create -n "<name>" -p "<path>"'
|
||||
let s:command_variable_delete =
|
||||
\ '-command dltk_buildpath_variable_delete -n "<name>"'
|
||||
" }}}
|
||||
|
||||
" NewBuildPathEntry(template) {{{
|
||||
" Adds a new entry to the current .buildpath file.
|
||||
function! eclim#dltk#buildpath#NewBuildPathEntry(arg, template)
|
||||
let args = split(a:arg)
|
||||
let cline = line('.')
|
||||
let ccol = col('.')
|
||||
for arg in args
|
||||
call s:MoveToInsertPosition()
|
||||
let line = line('.')
|
||||
call append(line, split(substitute(a:template, '<arg>', arg, 'g'), '\n'))
|
||||
call cursor(line + 1, 1)
|
||||
endfor
|
||||
call cursor(cline + 1, ccol)
|
||||
endfunction " }}}
|
||||
|
||||
" MoveToInsertPosition() {{{
|
||||
" If necessary moves the cursor to a valid insert position.
|
||||
function! s:MoveToInsertPosition()
|
||||
let start = search('<buildpath\s*>', 'wn')
|
||||
let end = search('</buildpath\s*>', 'wn')
|
||||
if line('.') < start || line('.') >= end
|
||||
call cursor(end - 1, 1)
|
||||
else
|
||||
let start = search('<buildpathentry\s*>', 'n')
|
||||
let end = search('</buildpathentry\s*>', 'cn')
|
||||
if end > start
|
||||
call cursor(end, 1)
|
||||
endif
|
||||
endif
|
||||
endfunction " }}}
|
||||
|
||||
" GetVariableNames() {{{
|
||||
" Gets a list of all variable names.
|
||||
function! eclim#dltk#buildpath#GetVariableNames()
|
||||
let variables = eclim#Execute(s:command_variables)
|
||||
if type(variables) != g:LIST_TYPE
|
||||
return []
|
||||
endif
|
||||
return map(variables, "v:val.name")
|
||||
endfunction " }}}
|
||||
|
||||
" VariableList() {{{
|
||||
" Lists all the variables currently available.
|
||||
function! eclim#dltk#buildpath#VariableList()
|
||||
let variables = eclim#Execute(s:command_variables)
|
||||
if type(variables) != g:LIST_TYPE
|
||||
return
|
||||
endif
|
||||
if len(variables) == 0
|
||||
call eclim#util#Echo("No variables.")
|
||||
endif
|
||||
|
||||
let pad = 0
|
||||
for variable in variables
|
||||
let pad = len(variable.name) > pad ? len(variable.name) : pad
|
||||
endfor
|
||||
|
||||
let output = []
|
||||
for variable in variables
|
||||
call add(output, eclim#util#Pad(variable.name, pad) . ' - ' . variable.path)
|
||||
endfor
|
||||
|
||||
call eclim#util#Echo(join(output, "\n"))
|
||||
endfunction " }}}
|
||||
|
||||
" VariableCreate(name, path) {{{
|
||||
" Create or update a variable.
|
||||
function! eclim#dltk#buildpath#VariableCreate(name, path)
|
||||
let path = substitute(fnamemodify(a:path, ':p'), '\', '/', 'g')
|
||||
if has('win32unix')
|
||||
let path = eclim#cygwin#WindowsPath(path)
|
||||
endif
|
||||
let command = s:command_variable_create
|
||||
let command = substitute(command, '<name>', a:name, '')
|
||||
let command = substitute(command, '<path>', path, '')
|
||||
|
||||
let result = eclim#Execute(command)
|
||||
if result != '0'
|
||||
call eclim#util#Echo(result)
|
||||
endif
|
||||
endfunction " }}}
|
||||
|
||||
" VariableDelete(name) {{{
|
||||
" Delete a variable.
|
||||
function! eclim#dltk#buildpath#VariableDelete(name)
|
||||
let command = s:command_variable_delete
|
||||
let command = substitute(command, '<name>', a:name, '')
|
||||
|
||||
let result = eclim#Execute(command)
|
||||
if result != '0'
|
||||
call eclim#util#Echo(result)
|
||||
endif
|
||||
endfunction " }}}
|
||||
|
||||
" CommandCompleteVar(argLead, cmdLine, cursorPos) {{{
|
||||
" Custom command completion for classpath var relative files.
|
||||
function! eclim#dltk#buildpath#CommandCompleteVar(argLead, cmdLine, cursorPos)
|
||||
let cmdTail = strpart(a:cmdLine, a:cursorPos)
|
||||
let argLead = substitute(a:argLead, cmdTail . '$', '', '')
|
||||
|
||||
let vars = eclim#dltk#buildpath#GetVariableNames()
|
||||
call filter(vars, 'v:val =~ "^' . argLead . '"')
|
||||
|
||||
return vars
|
||||
endfunction " }}}
|
||||
|
||||
" CommandCompleteVarPath(argLead, cmdLine, cursorPos) {{{
|
||||
" Custom command completion for classpath var relative files.
|
||||
function! eclim#dltk#buildpath#CommandCompleteVarPath(argLead, cmdLine, cursorPos)
|
||||
let cmdLine = strpart(a:cmdLine, 0, a:cursorPos)
|
||||
let args = eclim#util#ParseCmdLine(cmdLine)
|
||||
let argLead = cmdLine =~ '\s$' ? '' : args[len(args) - 1]
|
||||
|
||||
let vars = eclim#Execute(s:command_variables)
|
||||
|
||||
" just the variable name
|
||||
if argLead !~ '/'
|
||||
let var_names = deepcopy(vars)
|
||||
call filter(var_names, 'v:val.name =~ "^' . argLead . '"')
|
||||
if len(var_names) > 0
|
||||
call map(var_names,
|
||||
\ "isdirectory(v:val.path) ? v:val.name . '/' : v:val.name")
|
||||
endif
|
||||
return var_names
|
||||
endif
|
||||
|
||||
" variable name + path
|
||||
let var = substitute(argLead, '\(.\{-}\)/.*', '\1', '')
|
||||
let var_dir = ""
|
||||
for cv in vars
|
||||
if cv.name =~ '^' . var
|
||||
let var_dir = cv.path
|
||||
break
|
||||
endif
|
||||
endfor
|
||||
if var_dir == ''
|
||||
return []
|
||||
endif
|
||||
|
||||
let var_dir = escape(substitute(var_dir, '\', '/', 'g'), ' ')
|
||||
let argLead = substitute(argLead, var, var_dir, '')
|
||||
let files = eclim#util#CommandCompleteFile(argLead, a:cmdLine, a:cursorPos)
|
||||
let replace = escape(var_dir, '\')
|
||||
call map(files, "substitute(v:val, '" . replace . "', '" . var . "', '')")
|
||||
|
||||
return files
|
||||
endfunction " }}}
|
||||
|
||||
" CommandCompleteVarAndDir(argLead, cmdLine, cursorPos) {{{
|
||||
" Custom command completion for classpath var relative files.
|
||||
function! eclim#dltk#buildpath#CommandCompleteVarAndDir(argLead, cmdLine, cursorPos)
|
||||
let cmdLine = strpart(a:cmdLine, 0, a:cursorPos)
|
||||
let args = eclim#util#ParseCmdLine(cmdLine)
|
||||
let argLead = cmdLine =~ '\s$' ? '' : args[len(args) - 1]
|
||||
|
||||
" complete dirs for first arg
|
||||
if cmdLine =~ '^' . args[0] . '\s*' . escape(argLead, '~.\') . '$'
|
||||
return eclim#dltk#buildpath#CommandCompleteVar(argLead, a:cmdLine, a:cursorPos)
|
||||
endif
|
||||
|
||||
return eclim#util#CommandCompleteDir(argLead, a:cmdLine, a:cursorPos)
|
||||
endfunction " }}}
|
||||
|
||||
" vim:ft=vim:fdm=marker
|
||||
124
vim/bundle/eclim/autoload/eclim/dltk/interpreter.vim
Normal file
124
vim/bundle/eclim/autoload/eclim/dltk/interpreter.vim
Normal file
@@ -0,0 +1,124 @@
|
||||
" Author: Eric Van Dewoestine
|
||||
"
|
||||
" Description: {{{
|
||||
" see http://eclim.org/vim/ruby/index.html
|
||||
"
|
||||
" License:
|
||||
"
|
||||
" Copyright (C) 2005 - 2014 Eric Van Dewoestine
|
||||
"
|
||||
" This program is free software: you can redistribute it and/or modify
|
||||
" it under the terms of the GNU General Public License as published by
|
||||
" the Free Software Foundation, either version 3 of the License, or
|
||||
" (at your option) any later version.
|
||||
"
|
||||
" This program is distributed in the hope that it will be useful,
|
||||
" but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
" GNU General Public License for more details.
|
||||
"
|
||||
" You should have received a copy of the GNU General Public License
|
||||
" along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
"
|
||||
" }}}
|
||||
|
||||
" Script Variables {{{
|
||||
let s:command_interpreters = '-command dltk_interpreters -l <nature>'
|
||||
let s:command_interpreter_addremove =
|
||||
\ '-command dltk_<action>_interpreter -l <nature> -p "<path>"'
|
||||
" }}}
|
||||
|
||||
function eclim#dltk#interpreter#GetInterpreters(nature) " {{{
|
||||
let command = s:command_interpreters
|
||||
let command = substitute(command, '<nature>', a:nature, '')
|
||||
let interpreters = eclim#Execute(command)
|
||||
if type(interpreters) != g:LIST_TYPE || len(interpreters) == 0
|
||||
return []
|
||||
endif
|
||||
|
||||
return interpreters
|
||||
endfunction " }}}
|
||||
|
||||
function eclim#dltk#interpreter#ListInterpreters(nature) " {{{
|
||||
let command = s:command_interpreters
|
||||
let command = substitute(command, '<nature>', a:nature, '')
|
||||
let interpreters = eclim#Execute(command)
|
||||
if type(interpreters) != g:LIST_TYPE
|
||||
return
|
||||
endif
|
||||
if len(interpreters) == 0
|
||||
call eclim#util#Echo("No interpreters.")
|
||||
endif
|
||||
|
||||
let pad = 0
|
||||
for interpreter in interpreters
|
||||
if interpreter.default
|
||||
let interpreter.name .= ' (default)'
|
||||
endif
|
||||
let pad = len(interpreter.name) > pad ? len(interpreter.name) : pad
|
||||
endfor
|
||||
|
||||
let output = []
|
||||
let nature = ''
|
||||
for interpreter in interpreters
|
||||
if interpreter.nature != nature
|
||||
let nature = interpreter.nature
|
||||
call add(output, 'Nature: ' . interpreter.nature)
|
||||
endif
|
||||
let name = interpreter.name
|
||||
if interpreter.default
|
||||
let name .= ' (default)'
|
||||
endif
|
||||
let name = eclim#util#Pad(interpreter.name, pad)
|
||||
call add(output, ' ' . name . ' - ' . interpreter.path)
|
||||
endfor
|
||||
call eclim#util#Echo(join(output, "\n"))
|
||||
endfunction " }}}
|
||||
|
||||
function eclim#dltk#interpreter#AddInterpreter(nature, type, path) " {{{
|
||||
return s:InterpreterAddRemove(a:nature, a:type, a:path, 'add')
|
||||
endfunction " }}}
|
||||
|
||||
function eclim#dltk#interpreter#RemoveInterpreter(nature, path) " {{{
|
||||
return s:InterpreterAddRemove(a:nature, '', a:path, 'remove')
|
||||
endfunction " }}}
|
||||
|
||||
function s:InterpreterAddRemove(nature, type, path, action) " {{{
|
||||
let path = a:path
|
||||
let path = substitute(path, '\ ', ' ', 'g')
|
||||
let path = substitute(path, '\', '/', 'g')
|
||||
let command = s:command_interpreter_addremove
|
||||
let command = substitute(command, '<action>', a:action, '')
|
||||
let command = substitute(command, '<nature>', a:nature, '')
|
||||
let command = substitute(command, '<path>', path, '')
|
||||
if a:action == 'add'
|
||||
let command .= ' -t ' . a:type
|
||||
endif
|
||||
let result = eclim#Execute(command)
|
||||
if result != '0'
|
||||
call eclim#util#Echo(result)
|
||||
return 1
|
||||
endif
|
||||
return 0
|
||||
endfunction " }}}
|
||||
|
||||
function! eclim#dltk#interpreter#CommandCompleteInterpreterAdd(argLead, cmdLine, cursorPos) " {{{
|
||||
let cmdLine = strpart(a:cmdLine, 0, a:cursorPos)
|
||||
let args = eclim#util#ParseCmdLine(cmdLine)[1:]
|
||||
let argLead = cmdLine =~ '\s$' ? '' : args[len(args) - 1]
|
||||
|
||||
if argLead == '-' && args[0] == '-'
|
||||
return ['-n']
|
||||
endif
|
||||
|
||||
if len(args) == 0 ||
|
||||
\ len(args) == 3 ||
|
||||
\ (len(args) == 1 && argLead !~ '^-\|^$') ||
|
||||
\ (len(args) == 2 && argLead == '')
|
||||
return eclim#util#CommandCompleteFile(a:argLead, a:cmdLine, a:cursorPos)
|
||||
endif
|
||||
|
||||
return []
|
||||
endfunction " }}}
|
||||
|
||||
" vim:ft=vim:fdm=marker
|
||||
41
vim/bundle/eclim/autoload/eclim/php/complete.vim
Normal file
41
vim/bundle/eclim/autoload/eclim/php/complete.vim
Normal file
@@ -0,0 +1,41 @@
|
||||
" Author: Eric Van Dewoestine
|
||||
"
|
||||
" Description: {{{
|
||||
" see http://eclim.org/vim/php/complete.html
|
||||
"
|
||||
" License:
|
||||
"
|
||||
" Copyright (C) 2005 - 2013 Eric Van Dewoestine
|
||||
"
|
||||
" This program is free software: you can redistribute it and/or modify
|
||||
" it under the terms of the GNU General Public License as published by
|
||||
" the Free Software Foundation, either version 3 of the License, or
|
||||
" (at your option) any later version.
|
||||
"
|
||||
" This program is distributed in the hope that it will be useful,
|
||||
" but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
" GNU General Public License for more details.
|
||||
"
|
||||
" You should have received a copy of the GNU General Public License
|
||||
" along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
"
|
||||
" }}}
|
||||
|
||||
" Script Varables {{{
|
||||
let s:complete_command =
|
||||
\ '-command php_complete -p "<project>" -f "<file>" -o <offset> -e <encoding>'
|
||||
" }}}
|
||||
|
||||
" CodeComplete(findstart, base) {{{
|
||||
" Handles php code completion.
|
||||
function! eclim#php#complete#CodeComplete(findstart, base)
|
||||
if !eclim#php#util#IsPhpCode(line('.'))
|
||||
return eclim#html#complete#CodeComplete(a:findstart, a:base)
|
||||
endif
|
||||
|
||||
return eclim#lang#CodeComplete(
|
||||
\ s:complete_command, a:findstart, a:base, {'temp': 0})
|
||||
endfunction " }}}
|
||||
|
||||
" vim:ft=vim:fdm=marker
|
||||
132
vim/bundle/eclim/autoload/eclim/php/search.vim
Normal file
132
vim/bundle/eclim/autoload/eclim/php/search.vim
Normal file
@@ -0,0 +1,132 @@
|
||||
" Author: Eric Van Dewoestine
|
||||
"
|
||||
" License: {{{
|
||||
"
|
||||
" Copyright (C) 2005 - 2014 Eric Van Dewoestine
|
||||
"
|
||||
" This program is free software: you can redistribute it and/or modify
|
||||
" it under the terms of the GNU General Public License as published by
|
||||
" the Free Software Foundation, either version 3 of the License, or
|
||||
" (at your option) any later version.
|
||||
"
|
||||
" This program is distributed in the hope that it will be useful,
|
||||
" but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
" GNU General Public License for more details.
|
||||
"
|
||||
" You should have received a copy of the GNU General Public License
|
||||
" along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
"
|
||||
" }}}
|
||||
|
||||
" Script Varables {{{
|
||||
let s:search = '-command php_search'
|
||||
let s:buildpaths = '-command dltk_buildpaths -p "<project>"'
|
||||
let s:options_map = {
|
||||
\ '-a': ['split', 'vsplit', 'edit', 'tabnew', 'lopen'],
|
||||
\ '-s': ['all', 'project'],
|
||||
\ '-i': [],
|
||||
\ '-p': [],
|
||||
\ '-t': ['class', 'function', 'constant'],
|
||||
\ '-x': ['all', 'declarations', 'references'],
|
||||
\ }
|
||||
" }}}
|
||||
|
||||
function! eclim#php#search#Search(argline) " {{{
|
||||
return eclim#lang#Search(s:search, g:EclimPhpSearchSingleResult, a:argline)
|
||||
endfunction " }}}
|
||||
|
||||
function! eclim#php#search#FindInclude(argline) " {{{
|
||||
if !eclim#project#util#IsCurrentFileInProject(1)
|
||||
return
|
||||
endif
|
||||
|
||||
let file = substitute(getline('.'),
|
||||
\ ".*\\<\\(require\\|include\\)\\(_once\\)\\?\\s*[(]\\?['\"]\\([^'\"]*\\)['\"].*", '\3', '')
|
||||
|
||||
let project = eclim#project#util#GetCurrentProjectName()
|
||||
let command = s:buildpaths
|
||||
let command = substitute(command, '<project>', project, '')
|
||||
let paths = eclim#Execute(command)
|
||||
if type(paths) != g:LIST_TYPE
|
||||
return
|
||||
endif
|
||||
|
||||
let results = split(globpath(expand('%:h') . ',' . join(paths, ','), file), '\n')
|
||||
|
||||
if !empty(results)
|
||||
call eclim#util#SetLocationList(eclim#util#ParseLocationEntries(results))
|
||||
|
||||
let [action_args, argline] = eclim#util#ExtractCmdArgs(a:argline, '-a:')
|
||||
let action = len(action_args) == 2 ? action_args[1] : g:EclimPhpSearchSingleResult
|
||||
|
||||
" single result in another file.
|
||||
if len(results) == 1 && action != "lopen"
|
||||
let entry = getloclist(0)[0]
|
||||
call eclim#util#GoToBufferWindowOrOpen(bufname(entry.bufnr), action)
|
||||
call eclim#display#signs#Update()
|
||||
|
||||
" multiple results and user specified an action other than lopen
|
||||
elseif len(results) && len(action_args) && action != 'lopen'
|
||||
let locs = getloclist(0)
|
||||
let files = map(copy(locs), 'printf(' .
|
||||
\ '"%s|%s col %s| %s", ' .
|
||||
\ 'bufname(v:val.bufnr), v:val.lnum, v:val.col, v:val.text)')
|
||||
let response = eclim#util#PromptList(
|
||||
\ 'Please choose the file to ' . action,
|
||||
\ files, g:EclimHighlightInfo)
|
||||
if response == -1
|
||||
return
|
||||
endif
|
||||
let entry = locs[response]
|
||||
let name = substitute(bufname(entry.bufnr), '\', '/', 'g')
|
||||
call eclim#util#GoToBufferWindowOrOpen(name, action)
|
||||
call eclim#display#signs#Update()
|
||||
call cursor(entry.lnum, entry.col)
|
||||
|
||||
else
|
||||
exec 'lopen ' . g:EclimLocationListHeight
|
||||
endif
|
||||
else
|
||||
call eclim#util#EchoInfo("File not found.")
|
||||
endif
|
||||
endfunction " }}}
|
||||
|
||||
function! eclim#php#search#SearchContext(argline) " {{{
|
||||
if getline('.')[col('.') - 1] == '$'
|
||||
call cursor(line('.'), col('.') + 1)
|
||||
let cnum = eclim#util#GetCurrentElementColumn()
|
||||
call cursor(line('.'), col('.') - 1)
|
||||
else
|
||||
let cnum = eclim#util#GetCurrentElementColumn()
|
||||
endif
|
||||
|
||||
if getline('.') =~ "\\<\\(require\\|include\\)\\(_once\\)\\?\\s*[(]\\?['\"][^'\"]*\\%" . cnum . "c"
|
||||
call eclim#php#search#FindInclude(a:argline)
|
||||
return
|
||||
elseif getline('.') =~ '\<\(class\|function\)\s\+\%' . cnum . 'c'
|
||||
call eclim#php#search#Search('-x references')
|
||||
return
|
||||
elseif getline('.') =~ "\\<define\\s*(['\"]\\%" . cnum . "c"
|
||||
call eclim#util#EchoInfo("TODO: Search constant references")
|
||||
return
|
||||
"elseif getline('.') =~ '\<var\s\+[$]\?\%' . cnum . 'c'
|
||||
" call eclim#util#EchoInfo("TODO: Search var references")
|
||||
" return
|
||||
endif
|
||||
|
||||
call eclim#php#search#Search(a:argline . ' -x declarations')
|
||||
endfunction " }}}
|
||||
|
||||
function! eclim#php#search#CommandCompleteSearch(argLead, cmdLine, cursorPos) " {{{
|
||||
return eclim#util#CommandCompleteOptions(
|
||||
\ a:argLead, a:cmdLine, a:cursorPos, s:options_map)
|
||||
endfunction " }}}
|
||||
|
||||
function! eclim#php#search#CommandCompleteSearchContext(argLead, cmdLine, cursorPos) " {{{
|
||||
let options_map = {'-a': s:options_map['-a']}
|
||||
return eclim#util#CommandCompleteOptions(
|
||||
\ a:argLead, a:cmdLine, a:cursorPos, options_map)
|
||||
endfunction " }}}
|
||||
|
||||
" vim:ft=vim:fdm=marker
|
||||
117
vim/bundle/eclim/autoload/eclim/php/util.vim
Normal file
117
vim/bundle/eclim/autoload/eclim/php/util.vim
Normal file
@@ -0,0 +1,117 @@
|
||||
" Author: Eric Van Dewoestine
|
||||
"
|
||||
" Description: {{{
|
||||
" see http://eclim.org/vim/php/validate.html
|
||||
"
|
||||
" License:
|
||||
"
|
||||
" Copyright (C) 2005 - 2014 Eric Van Dewoestine
|
||||
"
|
||||
" This program is free software: you can redistribute it and/or modify
|
||||
" it under the terms of the GNU General Public License as published by
|
||||
" the Free Software Foundation, either version 3 of the License, or
|
||||
" (at your option) any later version.
|
||||
"
|
||||
" This program is distributed in the hope that it will be useful,
|
||||
" but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
" GNU General Public License for more details.
|
||||
"
|
||||
" You should have received a copy of the GNU General Public License
|
||||
" along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
"
|
||||
" }}}
|
||||
|
||||
" Script Variables {{{
|
||||
let s:update_command = '-command php_src_update -p "<project>" -f "<file>"'
|
||||
let s:html_validate_command = '-command html_validate -p "<project>" -f "<file>"'
|
||||
" }}}
|
||||
|
||||
function! eclim#php#util#IsPhpCode(lnum) " {{{
|
||||
" Determines if the code under the cursor is php code (in a php block).
|
||||
|
||||
let pos = getpos('.')
|
||||
try
|
||||
let phpstart = searchpos('<?\(php\|=\)\?', 'bcW')
|
||||
while phpstart[0]
|
||||
let synname = synIDattr(synIDtrans(synID(phpstart[0], phpstart[1], 1)), "name")
|
||||
if synname !~ '\(Comment\|String\)'
|
||||
break
|
||||
endif
|
||||
let phpstart = searchpos('<?\(php\|=\)\?', 'bW')
|
||||
endwhile
|
||||
|
||||
if phpstart[0] > 0
|
||||
call setpos('.', pos)
|
||||
let phpend = searchpos('?>', 'bW')
|
||||
while phpend[0] > phpstart[0]
|
||||
let synname = synIDattr(synIDtrans(synID(phpend[0], phpend[1], 1)), "name")
|
||||
if synname !~ '\(Comment\|String\)'
|
||||
break
|
||||
endif
|
||||
let phpend = searchpos('?>', 'bW')
|
||||
endwhile
|
||||
endif
|
||||
|
||||
return phpstart[0] > 0 && phpstart[0] <= a:lnum && (phpend[0] == 0 || phpend[0] < phpstart[0])
|
||||
finally
|
||||
call setpos('.', pos)
|
||||
endtry
|
||||
endfunction " }}}
|
||||
|
||||
function! eclim#php#util#UpdateSrcFile(on_save) " {{{
|
||||
" Updates the src file on the server w/ the changes made to the current file.
|
||||
|
||||
let validate = !a:on_save || (
|
||||
\ g:EclimPhpValidate &&
|
||||
\ (!exists('g:EclimFileTypeValidate') || g:EclimFileTypeValidate))
|
||||
|
||||
let project = eclim#project#util#GetCurrentProjectName()
|
||||
if project != ""
|
||||
let file = eclim#project#util#GetProjectRelativeFilePath()
|
||||
let command = s:update_command
|
||||
let command = substitute(command, '<project>', project, '')
|
||||
let command = substitute(command, '<file>', file, '')
|
||||
if validate && !eclim#util#WillWrittenBufferClose()
|
||||
let command = command . ' -v'
|
||||
if eclim#project#problems#IsProblemsList()
|
||||
let command = command . ' -b'
|
||||
endif
|
||||
endif
|
||||
let result = eclim#Execute(command)
|
||||
if type(result) != g:LIST_TYPE
|
||||
return
|
||||
endif
|
||||
|
||||
let html_validate = exists('b:EclimPhpHtmlValidate') ?
|
||||
\ b:EclimPhpHtmlValidate : g:EclimPhpHtmlValidate
|
||||
if validate && html_validate && !eclim#util#WillWrittenBufferClose()
|
||||
let command = s:html_validate_command
|
||||
let command = substitute(command, '<project>', project, '')
|
||||
let command = substitute(command, '<file>', file, '')
|
||||
let result_html = eclim#Execute(command)
|
||||
if type(result_html) == g:LIST_TYPE
|
||||
let result += result_html
|
||||
endif
|
||||
endif
|
||||
|
||||
if type(result) == g:LIST_TYPE && len(result) > 0
|
||||
let errors = eclim#util#ParseLocationEntries(
|
||||
\ result, g:EclimValidateSortResults)
|
||||
call eclim#util#SetLocationList(errors)
|
||||
else
|
||||
call eclim#util#ClearLocationList()
|
||||
endif
|
||||
|
||||
call eclim#project#problems#ProblemsUpdate('save')
|
||||
elseif !a:on_save
|
||||
call eclim#project#util#IsCurrentFileInProject()
|
||||
endif
|
||||
endfunction " }}}
|
||||
|
||||
function! eclim#php#util#CommandCompleteProject(argLead, cmdLine, cursorPos) " {{{
|
||||
return eclim#project#util#CommandCompleteProjectByNature(
|
||||
\ a:argLead, a:cmdLine, a:cursorPos, 'php')
|
||||
endfunction " }}}
|
||||
|
||||
" vim:ft=vim:fdm=marker
|
||||
Reference in New Issue
Block a user