Skip to content
Browse files

disable temp files on code completion by default

add option to enable the use of temp files.
  • Loading branch information...
1 parent cbcadbb commit 8ec9abc1245ba0a079767d7239cd0b238cf38abc @ervandew committed Apr 10, 2012
Showing with 39 additions and 1 deletion.
  1. +32 −0 doc/content/vim/code_completion.rst
  2. +7 −1 org.eclim.core/vim/eclim/autoload/eclim/lang.vim
View
32 doc/content/vim/code_completion.rst
@@ -66,5 +66,37 @@ To find out more about Vim's insert completion execute
from within Vim.
+Using temp files for code completion
+------------------------------------
+
+By default, when performing code completion, eclim must first save the file to
+disk so that when requesting code completion proposals from eclipse, eclipse
+can pull the current contents from the file system. The downside to this is
+that it alters vim's save state of the file.
+
+Take the scenario where you perform the following steps:
+ #. Open an existing file (vim shows that the file is unmodified)
+ #. Type some code (vim show that the file is modified)
+ #. Perform code completion.
+ #. Undo all changes.
+
+At this point vim will show the file as modified because since eclim had to save
+the file at step 3.
+
+While not much an issue this behavior can be a bit annoying for some users, so
+eclim provides optional support for saving the file contents to a temp file and
+having eclipse provide completion proposals using that file, alleviating the
+need to save your actual file to disk. To enable this simply add the following to your vimrc:
+
+.. code-block:: vim
+
+ let g:EclimUseTempFiles = 1
+
+Please note that this feature is considered beta (I haven't run into any
+problems with it, but at least one user wouldn't always get results on c++
+completion), so if you encounter problems consider disable this and reporting
+the problem to the eclim-user_ mailing list.
+
.. _supertab: http://www.vim.org/scripts/script.php?script_id=1643
.. _autocomplpop: http://www.vim.org/scripts/script.php?script_id=1879
+.. _eclim-user: http://groups.google.com/group/eclim-user
View
8 org.eclim.core/vim/eclim/autoload/eclim/lang.vim
@@ -23,6 +23,12 @@
"
" }}}
+" Global Variables {{{
+ if !exists('g:EclimUseTempFiles')
+ let g:EclimUseTempFiles = 0
+ endif
+" }}}
+
" Script Variables {{{
let s:update_command = '-command <lang>_src_update -p "<project>" -f "<file>"'
let s:validate_command = '-command <type>_validate -p "<project>" -f "<file>"'
@@ -282,7 +288,7 @@ function! eclim#lang#SilentUpdate(...)
let file = eclim#project#util#GetProjectRelativeFilePath()
if file != ''
try
- if a:0 && a:1
+ if a:0 && a:1 && g:EclimUseTempFiles
" don't create temp files if no server is available to clean them up.
let project = eclim#project#util#GetCurrentProjectName()
let workspace = eclim#project#util#GetProjectWorkspace(project)

2 comments on commit 8ec9abc

@genrich

Had same problems with c++ completion: completion works only once per file, subsequent calls, after file is changed, return mess(looks like something is cached in eclipse, although CSourceViewer content is ok before the call to "computeCompletionProposals")
Making a new tmp file name on every complete is a workaround. For example binding global counter increment on each call to <c-x><c-u> and using it in tmp file prefix(lang.vim:296: let prefix = '__eclim_temp_' . g:eclim_prefix_counter . '_')

@ervandew
Owner

I can reproduce the issue now and I've narrowed it down to the deletion of the temp files trigger the issue for the cdt. If I comment out the code on the server side that deletes the temp file then completion works fine. I'll dig into this further as I have time to see what additional massaging cdt needs to cleanup the temp file data when deleting the file.

Please sign in to comment.
Something went wrong with that request. Please try again.