lsp-java icon indicating copy to clipboard operation
lsp-java copied to clipboard

Classpath incomplete

Open iocanel opened this issue 6 years ago • 7 comments

Describe the bug

As soon, as I start adding removing projects into my workspace, I am getting this warning: Classpaht incomplete ....

It seems that each project I open is added to a single workspace. If for some reason I manually delete the project from disc, the workspace is getting broken and I can't use any project in the workspace.

I tried lsp-workspace-folders-remove with no luck. I removed the missing folder, restarted the workspace. No joy! Inside lsp-log I can still see lsp trying to read the folder which I previously removed.

I tried lsp-workspace-folders-switch again nothing changed.

The whole workspace management seems to not work as expected and its also painful to use. Here are some ideas that would possibly improve the experience:

  1. I should be able to completely wipe the current workspace.
  2. I should be able to edit the workspace (similarly to treemacs workspace edit).
  3. It would be nice if I could have lsp and treemacs workspace sync.
  4. It would be nice if I could tell lsp to have workspace per project.

Logs

lsp-log

 Failed to scan /home/iocanel/workspace/src/github.com/iocanel/f2f-demo2[Error]

iocanel avatar Mar 29 '19 16:03 iocanel

lsp-workspace-folders-remove

There is a bug in this function, the folder is not cleared from the other map server-id-folder. I will fix it and then we will see whether anything else will be addressed as part of this bug(for the rest we could open Feature request PRs)

I should be able to completely wipe the current workspace.

(setq lsp--session (make-lsp-session)) 

or deleting the session file should be sufficient.

It would be nice if I could have lsp and treemacs workspace sync.

I am planning to implement this in lsp-treemacs.

I should be able to edit the workspace (similarly to treemacs workspace edit).

Possible but I am not planning to implement it anytime soon.

It would be nice if I could tell lsp to have workspace per project.

I haven't tested but something like + adding dir local variable for that folder might work.

(defun lsp-java-lsp-new-workspace () 
  (interactive)
  (setq-local lsp-workspace-dir "/path/to/workspace")
  ;; passing t will force new language server
  (lsp t))

yyoncho avatar Mar 29 '19 16:03 yyoncho

@yyoncho: thanks for the super fast response. I will experiment with your suggestions and will let you know.

iocanel avatar Mar 29 '19 16:03 iocanel

https://github.com/yyoncho/lsp-mode/tree/better-multi-folder-handling so here it is proposed fix. I will do additional testing tomorrow before committing. I still see some odd "classpath not found" when opening the project for the first time but it works fine after you open another file from the project or if you reopen the file.

yyoncho avatar Mar 29 '19 20:03 yyoncho

Can you retest after getting latest https://github.com/emacs-lsp/lsp-mode/commit/b29e0254f28820653ee834fc17c68aff969841af ?

Note: I noticed that you may get classpath not found depending on whether the JDT LS has imported the folder or not. It autocorrects itself once the project import task si finished. I am considering removing that message (e. g. do not present it to the users but only log it in lsp-log buffer.).

yyoncho avatar Mar 30 '19 07:03 yyoncho

This seems t o work really nice (needs more testing):

(setq lsp--session (make-lsp-session)) 
(lsp-restart-workspace)

I will experiment with the other functions too.

iocanel avatar Mar 31 '19 18:03 iocanel

I also tried lsp-java-lsp-new-workspace, with no luck.

I added soemthing like:

(if idee-lsp-java-workspace-per-project-enabled
      (progn
        (let ((project-workspace (concat (idee-project-root-dir (buffer-file-name)) ".lsp")))
          (setq lsp-workspace-dir project-workspace)
          (lsp t))))

But it doesn't seem to worrk. Maybe my expectations were no right, but I expected to see an .lsp folder in the project root (which I never did). Even after restarting the workspace, no noticable change was seen.

iocanel avatar Mar 31 '19 19:03 iocanel

I also tried lsp-java-lsp-new-workspace, with no luck.

Per project workspace may require more work. Do you have a particular usecase for it? I am asking because jdt ls is consuming 300mb+.

yyoncho avatar Mar 31 '19 19:03 yyoncho