eclim icon indicating copy to clipboard operation
eclim copied to clipboard

MvnRepos issue

Open serzh opened this issue 15 years ago • 18 comments

When I've installed eclim for vim everything works fine. But the maven part forks not properly fine. I only can use the :Mvn an :Maven command, but I can't use :MvnRepo (or :MvnRepos). Vim says the it isn't editor command. I using eclipse 3.7, vim 7.3 and eclim 1.7.2. Help me please.

serzh avatar Nov 16 '11 09:11 serzh

Are you editing a .pom file when you attempt to execute :MvnRepo? If you are, then can you run :EclimValidate to ensure you have ftplugin support enabled and check the result of :echo &ft while editing the .pom file.

ervandew avatar Nov 16 '11 14:11 ervandew

Yes. I was editing pom file while tried to execute :MvnRepo. And it returns "Not an editor command". :EclimValidate returns "Result: OK, required settings are valid." and :echo &ft returns "xml".

serzh avatar Nov 17 '11 16:11 serzh

Ok, it seems that the filetype was not properly detected for your pom file. The filetype should be mvn_pom. What is the name of the file you are editing, something other than pom.xml?

ervandew avatar Nov 17 '11 17:11 ervandew

I just recognize the problem. The problem is in vim plugin xml.vim. It changes filetype to "xml". So when I removed it, the filetype became "mvn_pom". Can you help me please with it? I don't want to delete xml.vim.

serzh avatar Nov 17 '11 17:11 serzh

Can you point me to where this xml.vim plugin resides (vim.org, github.com, etc.)?

ervandew avatar Nov 17 '11 17:11 ervandew

Here it is https://github.com/vim-scripts/xml.vim.

serzh avatar Nov 17 '11 17:11 serzh

I can't reproduce the issue with that plugin installed, nor do I see it setting the filetype in the code. If you run :verbose set ft? is that the file that is printed out? Perhaps the version currently on github no longer messes with the filetype?

ervandew avatar Nov 17 '11 18:11 ervandew

This strange.. When I exec :verbose set ft? it returns me filetype=xml Last set from ~/.vim/eclim/plugin/ftdetect.vim. And I'm using the last version of that plugin from github.

serzh avatar Nov 17 '11 19:11 serzh

Can you run each of the following commands with that file open and the xml.vim plugin enabled:

:echo expand('%:t')
:echo b:xmlroot
:echo b:eclim_xml_filetype

ervandew avatar Nov 17 '11 19:11 ervandew

Yes, of course. :echo expand('%:t') pom.xml and the others cannot find variables: b:xmlroot and b:eclim_xml_filetype.

serzh avatar Nov 17 '11 20:11 serzh

Hmm, are there any errors in :messages when you open that file? Do you mind also posting the content of your pom.xml file? I'm running out of ideas, so I'm hoping having the file will help.

ervandew avatar Nov 17 '11 21:11 ervandew

:messages doesn't have any errors. So here pom.xml is:

   <project xmlns="http://maven.apache.org/POM/4.0.0" 
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
                xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
                http://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <groupId>ua.com.bankophone</groupId>
    <artifactId>ukrtelecom-bills</artifactId>
    <version>1.0</version>
    <packaging>jar</packaging>

    <name>ukrtelecom-bills</name>
    <url>http://maven.apache.org</url>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <JAVA_1_6_HOME>/opt/jdk1.6.0_27</JAVA_1_6_HOME>
    </properties>

    <dependencies>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>3.8.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>ua.kiev.author</groupId>
            <artifactId>cryptolib</artifactId>
            <version>1.0</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.16</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.xmlrpc</groupId>
            <artifactId>xmlrpc-client</artifactId>
            <version>3.1.3</version>
            <scope>compile</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                    <executable>${JAVA_1_6_HOME}/bin/javac</executable>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

But I have this problem with all pom.xml files.

serzh avatar Nov 22 '11 16:11 serzh

I still can't reproduce it, so at this point all I can suggest is opening up ~/.vim/eclim/plugin/ftdetect.vim and debugging the EclimSetXmlFileType and s:GetRootElement functions. Based on the fact that &ft is last set by eclim's ftdectect but the file has no b:eclim_xml_filetype and b:xmlroot variables, I would assume that an error is occurring in s:GetRootElement. But since nothing is showing up in :messages, I'm a bit baffled as to how that function can appear to be called, but b:xmlroot fails to get set.

ervandew avatar Nov 23 '11 15:11 ervandew

I've discovered that the problem occurs only when I'm trying to open pom file from nerdtree plugin. And also, when I've commented 92 line in ~/.vim/eclim/plugin/ftdetect.vim: " set filetype=xml the problem gone.

serzh avatar Nov 24 '11 19:11 serzh

I still can't reproduce this with nerdtree + xml.vim, but since commenting out setting of the filetype resolves the issue for you, perhaps the patch would as well (ignore the line numbers of this diff):

@@ -50,9 +50,11 @@ endfunction " }}}
 " Get the root element name.
 function! s:GetRootElement()
   " handle case where file doesn't have the xml declaration
+  let ft_save = &filetype
   set filetype=xml

   let root = ''
+  try
   let element = '.\{-}<\([a-zA-Z].\{-}\)\(\s\|>\|$\).*'

   " search for usage of root element (first occurence of <[a-zA-Z]).
@@ -92,6 +94,9 @@ function! s:GetRootElement()
       return root != line ? root : ''
     endif
   endif
+  finally
+    let &filetype = ft_save
+  endtry

   return root
 endfunction " }}}

So instead of removing the setting of the filetype, this change will revert it before returning which should hopefully have the same affect without breaking some other eclim provided xml file types.

ervandew avatar Nov 24 '11 20:11 ervandew

This is strange, but your patch hasn't helped me...

serzh avatar Nov 25 '11 18:11 serzh

I was thinking about this some more this morning and perhaps instead using the above patch, try using the following one which will avoid setting the filetype to xml in cases where vim should have taken care of it:

 " GetRootElement() {{{
 " Get the root element name.
 function! s:GetRootElement()
-  " handle case where file doesn't have the xml declaration
-  set filetype=xml
+  " handle case where file doesn't have an xml extension or an xml declaration
+  if expand('%:e') != 'xml' && getline(1) !~ '<?\s*xml.*?>'
+    set filetype=xml
+  endif

   let root = ''
   let element = '.\{-}<\([a-zA-Z].\{-}\)\(\s\|>\|$\).*'

ervandew avatar Dec 05 '11 15:12 ervandew

Closing this ticket w/ the hope that the submitted patch resolves the issue since I haven't gotten any feeback on the most recently proposed solution.

ervandew avatar Jan 30 '12 22:01 ervandew