Loading ...
Sorry, an error occurred while loading the content.

Plugin: java code completion - vim7 omni complete

Expand Messages
  • Wishi
    Hi! Currently I m trying to install a PlugIn: http://www.vim.org/scripts/script.php?script_id=1785 It does enable code completion for my java files, which I
    Message 1 of 5 , Sep 3, 2007
    • 0 Attachment
      Hi!

      Currently I'm trying to install a PlugIn: http://www.vim.org/scripts/script.php?script_id=1785
      It does enable code completion for my java files, which I edit with
      vim since years.

      Well... I did everything, as said:

      1. I unzipped the .vim-files, put them to /opt/local/share/vim/vim71/
      autoload

      2. Than I edited my .vimrc like that

      syntax on
      set nocompatible
      syntax on
      set tabstop=4
      set backspace=2
      set ai
      set noexpandtab

      filetype plugin on
      filetype plugin indent on
      source $VIMRUNTIME/vimrc_example.vim

      what I'm unsure about, but I don't get an error message:
      autocmd Filetype java setlocal omnifunc=javacomplete#Complete

      3. I restarted vim and opened a *.java File.

      - I dont get any effect. I type i. e. System.out.... nothing happens.
      Normally JavaIDEs would show some sub-classes or so. I think this new
      omni complete-Feature should work the same way, should it?

      Can somebody help me please. I builded vim7 with MacPorts recently.

      btw:
      Has anybody experice with that kind of project?
      http://eclim.sourceforge.net/vim/code_completion.html

      wishi


      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_mac" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Nico Weber
      ... Does it work if you use autocmd BufNewFile,BufRead *.java setlocal omnifunc=javacomplete#Complete If so, try your version with *.java insead of java ,
      Message 2 of 5 , Sep 3, 2007
      • 0 Attachment
        > autocmd Filetype java setlocal omnifunc=javacomplete#Complete

        Does it work if you use

        autocmd BufNewFile,BufRead *.java setlocal
        omnifunc=javacomplete#Complete

        If so, try your version with "*.java" insead of "java", but the above
        version is more common. See `:he autocmd-events-abs` to see a list of
        available autocmd events and their description.

        HTH,
        Nico

        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_mac" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      • wishi
        ... filetypedetect BufNewFile *.java setf java filetypedetect BufRead *.java setf java Press ENTER or type command to continue - After doing this
        Message 3 of 5 , Sep 4, 2007
        • 0 Attachment
          No... vim prompts me, when I edit a .java file:

          --- Auto-Commands ---
          filetypedetect BufNewFile
          *.java setf java
          filetypedetect BufRead
          *.java setf java
          Press ENTER or type command to continue

          - After doing this change it looks like that.


          What's really surprising: in my /opt/local/share/vim/vim7/autoload:
          there're a lot of .vim files, but just one .java file (for the plugin).

          Nevertheless, in the official instructions nothing is mentioned about
          this file:

          "install details

          1. Unzip javacomplete.zip to an autoload directory, e.g. $VIM/
          vimfiles/autoload
          Move javacomplete.txt to help directory, e.g. $VIM/vimfiles/doc.

          2. Set 'omnifunc' option. e.g.
          set omnifunc=javacomplete#Complete
          You can add this command in a ftplugin script like ftplugin/
          java_xxx.vim.
          Or, use autocmd: >
          " Only do this part when compiled with support for autocommands.
          if has("autocmd")
          autocmd Filetype java setlocal omnifunc=javacomplete#Complete
          endif"
          http://www.vim.org/scripts/script.php?script_id=1785

          Do you know whether this file has to somehwere else, maybe?

          wishi

          >
          >> autocmd Filetype java setlocal omnifunc=javacomplete#Complete
          >
          > Does it work if you use
          >
          > autocmd BufNewFile,BufRead *.java setlocal
          > omnifunc=javacomplete#Complete
          >
          > If so, try your version with "*.java" insead of "java", but the above
          > version is more common. See `:he autocmd-events-abs` to see a list of
          > available autocmd events and their description.
          >
          > HTH,
          > Nico
          >
          >

          --~--~---------~--~----~------------~-------~--~----~
          You received this message from the "vim_mac" maillist.
          For more information, visit http://www.vim.org/maillist.php
          -~----------~----~----~----~------~----~------~--~---
        • Nico Weber
          Hi, ... Strange. Do you have a `java` in your path? I.e. if you type `java` in terminal, do you get something else than command not found ? I just installed
          Message 4 of 5 , Sep 4, 2007
          • 0 Attachment
            Hi,

            > No... vim prompts me, when I edit a .java file:
            >
            > --- Auto-Commands ---
            > filetypedetect BufNewFile
            > *.java setf java
            > filetypedetect BufRead
            > *.java setf java
            > Press ENTER or type command to continue
            >
            > - After doing this change it looks like that.

            Strange. Do you have a `java` in your path? I.e. if you type `java`
            in terminal, do you get something else than "command not found"?

            I just installed javacomplete to see if it works for me, it does.
            Here's what I did:

            1. Download zip, extract it to Desktop
            2. Terminal: mkdir -p ~/.vim/autoload
            3. mv ~/Desktop/javacomplete/* ~/.vim/autoload
            4. cd ~/.vim
            5. mkdir doc
            6. mv autoload/javacomplete.txt doc

            After that, ~/.vim/autoload contained the files Reflection.java,
            java_parser.vim and javacomplete.vim and ~/.vim/doc containted
            javacomplete.txt.

            Now I fired up vim (I tested both Carbon vim and MacVim) and executed
            `:helptags ~/.vim/doc` (see `:he add-local-help` for more
            information), opened a java file and typed in manually `:set
            omnifunc=javacomplete#Complete`. After that, when I first used C-x C-
            o, the java file was compiled into a class file, and then it Just
            Worked (it completed System.out.pr successfully. Package name
            completion didn't work for me).

            Then I added

            if has("autocmd")
            autocmd Filetype java setlocal omnifunc=javacomplete#Complete
            endif

            to my ~/_vimrc , and from then on omnicompletion worked without
            problems.

            HTH,
            Nico

            ps: Always put local modifications in your ~/.vim directory, then
            these settings are used by all vim instances you start. (`:he rtp`
            gives a very terse overview).


            >
            > 1. Unzip javacomplete.zip to an autoload directory, e.g. $VIM/
            > vimfiles/autoload
            > Move javacomplete.txt to help directory, e.g. $VIM/vimfiles/doc.

            As said, these are bad suggestions.



            --~--~---------~--~----~------------~-------~--~----~
            You received this message from the "vim_mac" maillist.
            For more information, visit http://www.vim.org/maillist.php
            -~----------~----~----~----~------~----~------~--~---
          • wishi
            Allright, thanks a lot for that. After installing in ~/.vim/ and changing my .vimrc everything works perfectly well. They should replace this to vim.org. wishi
            Message 5 of 5 , Sep 6, 2007
            • 0 Attachment
              Allright, thanks a lot for that. After installing in ~/.vim/ and
              changing my .vimrc everything works perfectly well. They should
              replace this to vim.org.

              wishi


              Am 04.09.2007 um 14:04 schrieb Nico Weber:

              >
              > Strange. Do you have a `java` in your path? I.e. if you type `java`
              > in terminal, do you get something else than "command not found"?
              >
              > I just installed javacomplete to see if it works for me, it does.
              > Here's what I did:
              >
              > 1. Download zip, extract it to Desktop
              > 2. Terminal: mkdir -p ~/.vim/autoload
              > 3. mv ~/Desktop/javacomplete/* ~/.vim/autoload
              > 4. cd ~/.vim
              > 5. mkdir doc
              > 6. mv autoload/javacomplete.txt doc
              >
              > After that, ~/.vim/autoload contained the files Reflection.java,
              > java_parser.vim and javacomplete.vim and ~/.vim/doc containted
              > javacomplete.txt.
              >
              > Now I fired up vim (I tested both Carbon vim and MacVim) and executed
              > `:helptags ~/.vim/doc` (see `:he add-local-help` for more
              > information), opened a java file and typed in manually `:set
              > omnifunc=javacomplete#Complete`. After that, when I first used C-x C-
              > o, the java file was compiled into a class file, and then it Just
              > Worked (it completed System.out.pr successfully. Package name
              > completion didn't work for me).
              >
              > Then I added
              >
              > if has("autocmd")
              > autocmd Filetype java setlocal omnifunc=javacomplete#Complete
              > endif
              >
              > to my ~/_vimrc , and from then on omnicompletion worked without
              > problems.
              >
              > HTH,
              > Nico
              >
              > ps: Always put local modifications in your ~/.vim directory, then
              > these settings are used by all vim instances you start. (`:he rtp`
              > gives a very terse overview).
              >
              >
              >>
              >> 1. Unzip javacomplete.zip to an autoload directory, e.g. $VIM/
              >> vimfiles/autoload
              >> Move javacomplete.txt to help directory, e.g. $VIM/vimfiles/doc.
              >
              > As said, these are bad suggestions.
              >
              >
              >
              >

              --~--~---------~--~----~------------~-------~--~----~
              You received this message from the "vim_mac" maillist.
              For more information, visit http://www.vim.org/maillist.php
              -~----------~----~----~----~------~----~------~--~---
            Your message has been successfully submitted and would be delivered to recipients shortly.