liquidz / vim-iced

Clojure Interactive Development Environment for Vim8/Neovim
https://liquidz.github.io/vim-iced/
MIT License
516 stars 35 forks source link

clj-kondo analysis path should be configurable #437

Closed sheluchin closed 1 year ago

sheluchin commented 2 years ago

clj-kondo has been taking up very much memory for me. I found the reason is that the kondo configuration that vim-iced passes sets the analysis path as:

https://github.com/liquidz/vim-iced/blob/597ac01a186992000c57e0eaf36b6311ced1bffa/autoload/iced/component/clj_kondo.vim#L431

https://github.com/liquidz/vim-iced/blob/597ac01a186992000c57e0eaf36b6311ced1bffa/autoload/iced/component/clj_kondo.vim#L59-L68

My project root includes some other Clojure libraries outside of the classpath, so with this config, they were all being analyzed and consuming memory.

Ideally, the analysis path should be configurable.

Outside of this main issue, I think there is also something to think about when using clojure-lsp. If I understand correctly, LSP also runs clj-kondo analysis. I believe that when setting g:iced_enable_clj_kondo_analysis, the analysis operations are unnecessarily duplicated. I can open another issue for this if it sounds correct.

liquidz commented 2 years ago

I'll give it some thought and get back to you.

liquidz commented 2 years ago

@sheluchin

My project root includes some other Clojure libraries outside of the classpath, so with this config, they were all being analyzed and consuming memory. Ideally, the analysis path should be configurable.

I see. Agreed with making it configurable, as it doesn't necessarily have to be fixed.

Outside of this main issue, I think there is also something to think about when using clojure-lsp. If I understand correctly, LSP also runs clj-kondo analysis.

Right.

I believe that when setting g:iced_enable_clj_kondo_analysis, the analysis operations are unnecessarily duplicated.

Sure the analysis operations are duplicated, but it seems difficult to make it one or the other. For example, clojure-lsp uses transit-clj to store analysis data, but it used sqlite in the past. https://github.com/clojure-lsp/clojure-lsp/issues/703

Since the data format may change, or the structure of the analysis data may change, it is not currently planned to use the results of analysis data by clojure-lsp from the vim-iced side.

liquidz commented 2 years ago

@sheluchin Added g:iced_clj_kondo_analysis_dirs option in dev branch. This option is recommended to use thinca/vim-localrc.

e.g. .local.vimrc

let g:iced_clj_kondo_analysis_dirs = [
      \ printf('%s/src', expand('<sfile>:p:h')),
      \ ]

Could you try?

sheluchin commented 2 years ago

@liquidz I don't think it works correctly. I set the variable, confirmed it, and restarted everything. After a short while the clj-kondo process was taking up 8gb or memory and the path it was given was still the project root instead of the src/ within it.

sheluchin commented 2 years ago

Thank you for taking the time to think about the LSP issue and explain some of the underlying complexity.

The reason I raised that point was not just to point out whatever inefficiency could be caused by the duplication, but also because I'm still trying to understand how vim-iced and LSP are to work together. There is lots of overlap in functionality - partly by design - but without clear boundaries it's difficult for me to understand the right way for LSP and vim-iced to complement each other. I was wondering if de-duplicating things might help to simplify, but it sounds like that's not the case at this moment.

liquidz commented 2 years ago

@sheluchin

After a short while

Did you save any files while waiting? In vim-iced, clj-kondo analysis is kicked by BufWritePost autocommand. https://github.com/liquidz/vim-iced/blob/ce08df706cc6e8cbf88dbd2dc8f45b16aa1b0bdd/autoload/iced/repl/auto.vim#L4-L7 So if you do nothing, vim-iced will not start clj-kondo analysis.

I added a debug log to the dev branch just in case. (https://github.com/liquidz/vim-iced/commit/ce08df706cc6e8cbf88dbd2dc8f45b16aa1b0bdd) You can confirm debug log as following steps.

sheluchin commented 1 year ago

Thanks @liquidz. I tried again and it seems to be working this time; there is no massive increase in memory consumption due to clj-kondo linting. I must have made some mistake when testing it the previous time.

Did you save any files while waiting?

Yes, I wasn't just waiting, I was working with files as I normally would.

liquidz commented 1 year ago

@sheluchin Thanks for your confirmation! Just released v3.11.3086