LunarVim / LunarVim

🌙 LunarVim is an IDE layer for Neovim. Completely free and community driven.
https://www.lunarvim.org
GNU General Public License v3.0
18.47k stars 1.51k forks source link

non-project file when opening a java file #2276

Closed slinky07 closed 2 years ago

slinky07 commented 2 years ago

Problem description

Most of the time i use Intelleji. When I go use lvim I get " ____.java is a non-project file, only syntax errors are reported."

my usual project folders goes like this:

Assignment1 CCCS 301 ├── Assignment1 CCCS 301.iml ├── out │   └── production │   └── Assignment1 CCCS 301 │   └── com │   └── dsa │   └── COVID.class └── src └── com └── dsa ├── COVID.class └── COVID.java

I am aware it is probably a configuration issue. but I get this error even if I am in a lone folder like :

arrTest ├── Array.class └── Array.java

from what I understand, this is from the plugin called projects? I tried to set the configuration to recognize the src folder that is usually created from intelleji. but that doesn't seem to work.

here is my config.lua as of now:

   12 lvim.log.level = "warn"
   13 lvim.format_on_save = true
   14 lvim.colorscheme = "onedarker"

   56 lvim.builtin.dashboard.active = true
   57 lvim.builtin.notify.active = true
   58 lvim.builtin.terminal.active = true
   59 lvim.builtin.nvimtree.setup.view.side = "left"
   60 lvim.builtin.nvimtree.show_icons.git = 0
   61 lvim.builtin.project.detection_methods = { "=src" }

   64 lvim.builtin.treesitter.ensure_installed = {
   65   "bash",
   66   "c",
   67   "javascript",
   68   "json",
   69   "lua",
   70   "python",
   71   "typescript",
   72   "css",
   73   "rust",
   74   "java",
   75   "yaml",
   76 }
   77
   78 lvim.builtin.treesitter.ignore_install = { "haskell" }
   79 lvim.builtin.treesitter.highlight.enabled = true
   80

i only put the lines uncommented.

if anyone can help me understand this I would greatly appreciate it.

I am new to lvim and nvim. I am trying to understand how to set it correctly and understand what I'm doing wrong. been reading documentation everywhere to understand a bit of everything including the plugins. I was reading the documentation of the projects plugin which is why I added the line at 61 in the hope it would solve the issue.

LunarVim version

2fa176f

Neovim version (>= 0.6.1)

NVIM v0.6.1

Operating system/version

macOS 12.2.1

Relevant log output

1
    2 null-ls: require("null-ls.health").check()
    3 ========================================================================
    4   - INFO: no sources registered
    5
    6 nvim: health#nvim#check
    7 ========================================================================
    8 ## Configuration
    9   - OK: no issues found
   10
   11 ## Performance
   12   - OK: Build type: Release
   13
   14 ## Remote Plugins
   15   - OK: Up to date
   16
   17 ## terminal
   18   - INFO: key_backspace (kbs) terminfo entry: key_backspace=^H
   19   - INFO: key_dc (kdch1) terminfo entry: key_dc=\E[3~
   20   - INFO: $TERM_PROGRAM='iTerm.app'
   21   - INFO: $COLORTERM='truecolor'
   22
   23 nvim-lsp-installer: require("nvim-lsp-installer.health").check()
   24 ========================================================================
   25 ## nvim-lsp-installer report
   26   - OK: neovim version >= 0.6.0
   27   - WARNING: Go: not available
   28   - WARNING: Composer: not available
   29   - WARNING: PHP: not available
   30   - WARNING: julia: not available
   31   - ERROR: wget: not available
   32   - OK: bash: `GNU bash, version 3.2.57(1)-release (arm64-apple-darwin21)`
   33   - OK: tar: `bsdtar 3.5.1 - libarchive 3.5.1 zlib/1.2.11 liblzma/5.0.5 bz2lib/1.0.8 `
   34   - OK: gzip: `Apple gzip 352.40.6`
   35   - OK: Ruby: `ruby 2.6.8p205 (2021-07-07 revision 67951) [universal.arm64e-darwin21]`
   36   - OK: sh: `Ok`
   37   - OK: curl: `curl 7.77.0 (x86_64-apple-darwin21.0) libcurl/7.77.0 (SecureTransport) LibreSSL/2.8.3 zlib/1.2.11 nghttp2/1.42.0`
   38   - OK: python3: `Python 3.9.10`
   39   - OK: node: `v17.4.0`
   40   - OK: java: `Ok`
   41   - OK: javac: `javac 17.0.2`
   42   - OK: pip3: `pip 21.3.1 from /opt/homebrew/lib/python3.9/site-packages/pip (python 3.9)`
   43   - OK: npm: `8.3.1`
   44   - OK: RubyGem: `3.0.3.1`
   45
   46 nvim-treesitter: require("nvim-treesitter.health").check()
   47 ========================================================================
   48 ## Installation
   49   - OK: `tree-sitter` found 0.20.4 (714bfd47a744ab44b904375c177a24c0614ef49c) (parser generator, only needed for :TSInstallFromGrammar)
   50   - OK: `node` found v17.4.0 (only needed for :TSInstallFromGrammar)
   51   - OK: `git` executable found.
   52   - OK: `cc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" }
   53     Version: objc[8534]: Class AMSupportURLConnectionDelegate is implemented in both /usr/lib/libamsupport.dylib (0x20bb1b678) and /Library/Apple/System/Library/PrivateFrameworks/MobileDevice.framework/             Versions/A/MobileDevice (0x1063e42c8). One of the two will be used. Which one is undefined.
   54   - OK: Neovim was compiled with tree-sitter runtime ABI version 13 (required >=13). Parsers must be compatible with runtime ABI.
   55
   56 ## Parser/Features H L F I J
   57   - yaml           ✓ ✓ ✓ ✓ ✓
   58   - typescript     ✓ ✓ ✓ ✓ ✓
   59   - rust           ✓ ✓ ✓ ✓ ✓
   60   - c              ✓ ✓ ✓ ✓ ✓
   61   - css            ✓ . ✓ ✓ ✓
   62   - javascript     ✓ ✓ ✓ ✓ ✓
   63   - java           ✓ ✓ . ✓ ✓
   64   - bash           ✓ ✓ ✓ . ✓
   65   - lua            ✓ ✓ ✓ ✓ ✓
   66   - python         ✓ ✓ ✓ ✓ ✓
   67   - json           ✓ ✓ ✓ ✓ .
   68
   69   Legend: H[ighlight], L[ocals], F[olds], I[ndents], In[j]ections
   70          +) multiple parsers found, only one will be used
   71          x) errors found in the query, try to run :TSUpdate {lang}
   72
   73 provider: health#provider#check
   74 ========================================================================
  75 ## Clipboard (optional)
   76   - OK: Clipboard tool found: pbcopy
   77
   78 ## Python 2 provider (optional)
   79   - WARNING: No Python executable found that can `import neovim`. Using the first available executable for diagnostics.
   80   - ERROR: Python provider error:
   81     - ADVICE:
   82       - provider/pythonx: Could not load Python 2:
   83           /usr/bin/python2 does not have the "neovim" module. :help provider-python
   84           /usr/bin/python2.7 does not have the "neovim" module. :help provider-python
   85           python2.6 not found in search path or not executable.
   86           /usr/bin/python does not have the "neovim" module. :help provider-python
   87   - INFO: Executable: Not found
   88
   89 ## Python 3 provider (optional)
   90   - INFO: `g:python3_host_prog` is not set.  Searching for python3 in the environment.
   91   - INFO: Multiple python3 executables found.  Set `g:python3_host_prog` to avoid surprises.
   92   - INFO: Executable: /opt/homebrew/bin/python3
   93   - INFO: Other python executable: /usr/bin/python3
   94   - INFO: Python version: 3.9.10
   95   - INFO: pynvim version: 0.4.3
   96   - OK: Latest pynvim is installed.
   97
   98 ## Python virtualenv
   99   - OK: no $VIRTUAL_ENV
  100
  101 ## Ruby provider (optional)
  102   - INFO: Ruby: ruby 2.6.8p205 (2021-07-07 revision 67951) [universal.arm64e-darwin21]
  103   - WARNING: `neovim-ruby-host` not found.
  104     - ADVICE:
  105       - Run `gem install neovim` to ensure the neovim RubyGem is installed.
  106       - Run `gem environment` to ensure the gem bin directory is in $PATH.
  107       - If you are using rvm/rbenv/chruby, try "rehashing".
  108       - See :help g:ruby_host_prog for non-standard gem installations.
  109
  110 ## Node.js provider (optional)
  111   - INFO: Node.js: v17.4.0
  112   - INFO: Nvim node.js host: /opt/homebrew/lib/node_modules/neovim/bin/cli.js
  113   - OK: Latest "neovim" npm/yarn package is installed: 4.10.1
  114
  115 ## Perl provider (optional)
  116   - ERROR: perl provider error:
  117     - ADVICE:
  118       - "Neovim::Ext" cpan module is not installed
  119
  120 telescope: require("telescope.health").check()
  121 ========================================================================
  122 ## Checking for required plugins
  123   - OK: plenary installed.
  124   - OK: nvim-treesitter installed.
  125
  126 ## Checking external dependencies
  127   - ERROR: rg: not found. `live-grep` finder will not function without [BurntSushi/ripgrep](https://github.com/BurntSushi/ripgrep) installed.
  128   - WARNING: fd: not found. Install [sharkdp/fd](https://github.com/sharkdp/fd) for extended capabilities
  129
  130 ## ===== Installed extensions =====
 131
  132 ## Telescope Extension: `fzf`
  133   - INFO: No healthcheck provided
  134
  135 ## Telescope Extension: `projects`
  136   - INFO: No healthcheck provided
  137
  138 vim.lsp: require("vim.lsp.health").check()
  139 ========================================================================
  140   - INFO: LSP log level : WARN
  141   - INFO: Log path: /Users/godricshollow/.cache/nvim/lsp.log
  142   - INFO: Log size: 86 KB
  143
  144 vim.treesitter: require("vim.treesitter.health").check()
  145 ========================================================================
  146   - INFO: Runtime ABI version : 13
  147   - OK: Loaded parser for bash: ABI version 13
  148   - OK: Loaded parser for c: ABI version 13
  149   - OK: Loaded parser for css: ABI version 13
  150   - OK: Loaded parser for java: ABI version 13
  151   - OK: Loaded parser for javascript: ABI version 13
  152   - OK: Loaded parser for json: ABI version 13
  153   - OK: Loaded parser for lua: ABI version 13
  154   - OK: Loaded parser for python: ABI version 13
  155   - OK: Loaded parser for rust: ABI version 13
  156   - OK: Loaded parser for typescript: ABI version 13
  157   - OK: Loaded parser for yaml: ABI version 13
  158
  159 which_key: health#which_key#check
  160 ========================================================================
  161 ## WhichKey: checking conflicting keymaps
  162

Screenshots

Screen Shot 2022-02-14 at 4 04 35 AM

abzcoding commented 2 years ago

there are a couple of workarounds, one of them is to make sure your project folder is git managed the other one is to override the java lang server to make sure it supports a single file or ...

slinky07 commented 2 years ago

Hello sorry for the long time to answer; my midterms are a bit crazy.

When you say the project would need to be git-managed where is that exactly at the project main folder that contains both out and src? my folder formatting was a bit destroyed when the issue got posted. my project is as follow, for the project mentioned in the issue:

~/dev/Assignment1 CCCS 301/out, src/[...] where the comma dictates 2 folder children of the same parent. both out and src have multiple folders for the java packages. would it need to be under "Assignment1 CCCS 301" which I make a repo? or the folder that contains the code itself? Because the way I was doing things, temporarily for school, is I was just making the dev folder itself a repository for every project I have.

I would gladly change my git workflow if it means making this work.

Uzaaft commented 2 years ago

Let's say that Assignment1 CCCS 301 is the project folder(i.e it contains all the code for the project, the test etc. According to lspconfig, it would require one of the following files to be in the root folder of the project before it runs the LSP: 'build.gradle', 'pom.xml', '.git'.

@slinky07 You can remove the bug label from your issue, this is a user-error.

So to fix the issue, you can do the following:

  1. Change your workflow to include the files above or
  2. Override the Java LSP to support Standalone files.
slinky07 commented 2 years ago

Thanks a lot, @Uzaaft , I modified my workflow accordingly, and after It recognized my maven project correctly with the pom.xml but not .git projects. It took me a while to figure it out but I understand better now. somehow nvim only use jdtls for java, which apparently only uses pom.xml , build.xml , settings.graddle and settings.graddle.kts Idk if that's on purpose .git not being there but after I added it, it recognizes my git projects now.

Little question, I modified the jdtls.lua file directly by adding the git line on the table of root_files. would I have been able to directly add .git in my main config file? I am not sure which syntax to use there to directly modify jdtls instead of project's detection_methods.

I am trying to make java_language_server work but I am okay for now with jdtls I guess. Thanks for the help.

Uzaaft commented 2 years ago

@slinky07 You can directly add .git into your main config file, although I am not sure why it didn't just default to that. Could you paste your config.lua in a gist and provide the link?

Also, I don't think there is a java_language_server LSP, at least I can't seem to find it here https://langserver.org

slinky07 commented 2 years ago

Hello @Uzaaft Thanks again for your patience, I had another midterm this week.

I put here the config.lua you wanted; plus the jdtls.lua that I had actually modified to get LSP to work.

config.lua the git-related lines are lines 61 and 62. There have been more tries of different styles but I deleted them. Nothing I wrote there affected LSP not recognizing .git. I was thinking maybe I did not write the correct syntax but it seems weird as apparently it is supposed to be automatic.

Unless it is jdtls which is why i ended up adding the line there. The jdtls.lua modified line is line 86. included it just in case.

https://gist.github.com/slinky07/e5a4cd5b399f48227e658261160fe20c

Last thing, if I understand how github works, then I cannot remove the bug label as I am not a contributor yet.

Thanks a lot for your time.

Uzaaft commented 2 years ago

@slinky07 No worries, I am a student myself, so I understand that 😂 I'll look into it.