ternjs / tern_for_sublime

Sublime Text package adding Tern support
MIT License
803 stars 54 forks source link

.tern-port files #5

Closed Raynos closed 11 years ago

Raynos commented 11 years ago

If there was a way to not create .tern-port files it would make using this a lot easier.

It's annoying for my git flow to have git status filled with .tern-port files

jkroso commented 11 years ago

git allows you to set a global gitignore file

marijnh commented 11 years ago

Indeed. This is trivially solvable on the git side. Having the files makes it possible for different editor processes to share one Tern process, which I think is an advantage.

Raynos commented 11 years ago

@jkroso I've found that all my repos have local .gitignore files which don't ignore .tern-port and thus ignore my higher up .gitignore files.

@marijnh can we move the file somewhere else like in ~/.tern/ ? One of my projects had 5 different .tern-port files in various nested folders.

jkroso commented 11 years ago

its a setting in your global .gitconfig file. $ git config --global core.excludesfile ~/.gitignore should do it.

Raynos commented 11 years ago

Yeah using a global gitignore does do the trick. It's still ugly to litter my code with files. We should find another way to achieve this

jkroso commented 11 years ago

my editor allowed me to do the same trick so I don't even know they are there

Raynos commented 11 years ago

hiding the problem doesnt solve them. My file system is not a place you can dump junk in.

Rowno commented 11 years ago

SVN made the same mistake and Git got it right. :wink:

marijnh commented 11 years ago

hiding the problem doesnt solve them. My file system is not a place you can dump junk in.

Taking this kind of confrontational approach here doesn't help at all. It makes people less motivated to help, and ruins the atmosphere.

The Tern server should delete the .tern-port file when it exits. If it's not doing that, that's a bug we should investigate. The fact that you're seeing several such files suggests that you didn't create a .tern-project file -- if you do, Tern will consider the directory holding that file to be the root of the project, and keep the port file there, reusing server instances if multiple editors are open for the project.

Using ~/.tern/port does not work, as it is possible for multiple projects, and thus multiple servers, to be open at the same time.

marijnh commented 11 years ago

See attached patch. The new code in the vim plugin that killed the server on exit was indeed preventing the server from cleaning up its port file.

If you're on windows, the problem might still exists, since I'm not really sure what happens to the process when taskkill is called on it.

marijnh commented 11 years ago

Oh, wait, this is about Sublime, not Vim. Ignore my muttering about 'attached patch'. The Sublime mode simply lets the servers shut down on their own after 5 minutes of inactivity.

Raynos commented 11 years ago

@marijnh the attitude doesn't help, sorry.

Can there be an option to opt-in to not using the tern file? I presume sharing only matters if you use multiple editor processes, my work flow generally only involves a single editor.

marijnh commented 11 years ago

See commit b60b72c99bdcc6125b81ada40d973da6221bd1f0 and the past few commits in the Tern repository.

If you upgrade both tern_for_sublime and tern itself (delete tern_for_sublime/node_modules and do npm install again), you can set the option "tern_arguments": ["--no-port-file"] to get rid of the port files.

Raynos commented 11 years ago

Sweet! Am I correct in thinking that as long as I have only one instance of sublime open it only creates a single tern server per tern project?

marijnh commented 11 years ago

Yes, the ST plugin will internally reuse the port.

Raynos commented 11 years ago

@marijnh awesome! Thanks.

evolutionxbox commented 7 years ago

@marijnh Where does one set the option "tern_arguments": ["--no-port-file"]?