liquidz / vim-iced

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

Unable to eval or run tests when namespace is camelCase #432

Closed lamp closed 2 years ago

lamp commented 2 years ago

Hi,

I'm working in a codebase where I am required to have namespaces in the form:

(ns someName.core)
;; and
(ns someName.core-test)

The folder structure matches the namespace declaration, so src/someName/core.clj and test/someName/core_test.clj

When in these namespaces I am unable to eval or run any tests, when doing so there is no output whatsoever.

After switching the folder structure and namespaces to all be lower case this is no longer an issue, eval and IcedTest* all work as expected.

I have only checked this while using clojure cli, but I don't think there would be any difference with any other tool.

I'm happy to try and fix it myself if I could get some pointers as to where it might be, I did look here but without a little help I am probably going to waste a lot of time.

Many thanks for the project, I find it very useful.

liquidz commented 2 years ago

@lamp Thanks for your reporting! Hmm, I could not reproduce the problem in my environment. With the following files, I could evaluate and run tests.

Could you confirm that you can reproduce the problem or not with minimal configuration? https://liquidz.github.io/vim-iced/#minimal_configuration

lamp commented 2 years ago

Hey @liquidz ,

Thanks for the reply, I did as you asked and created a sample app using clojure -Tnew app :name myUsername/mynewapp with deps-new as this is as close to what was used to build the real application with which I am working.

I was able to reproduce it with:

The only difference I can see is that in one file the namespace starts with myUsername and the other with myusername.

I have attached my sample project for you to take a look, if you need anything else please let me know I will be happy to provide whatever I can.

mynewapp.zip

Additional information

liquidz commented 2 years ago

@lamp Thanks for your confirmation! Reproduced. I'll try to find the cause.

liquidz commented 2 years ago

@lamp I found that ignorecase option is the cause. Just released v3.10.3061, so could you try the latest version?

liquidz commented 2 years ago

I'm happy to try and fix it myself if I could get some pointers as to where it might be

Ah, sorry, I've fixed it here 😣 I don't know if this will be helpful, but here is the process to solve the problem.

When I reprocuded the problem, I tried to check debug messages with :let g:iced#debug = v:true. Debug messages contain requests and responses between nREPL as follows.

DEBUG >>>: {'file': '/private/tmp/bar/mynewapp/src/myUsername/mynewapp.clj', 'id': 6, 'nrepl.middleware.print/stream?': 1, 'verbose': v:true, 'column': 3, 'line': 15, 'code': '(println "test")', 'session':'480cb143-4a4f-4a71-8e55-2a3cbd7c7346', 'ns': 'my', 'op': 'eval', 'callback': function('<80><fd>R66__resolve', [{'_rejections': [], 'then': function('<80><fd>R66__promise_then'), '_state': 0, '_vital_promise': 5, '_children': [], '_result': v:null, 'catch': function('<80><fd>R66__promise_catch'), '_fulfillments': [], '_has_floating_child': v:false, 'finally': function('<80><fd>R66__promise_finally')}])}
DEBUG <<<: d2:idi6e2:ns2:my7:session36:480cb143-4a4f-4a71-8e55-2a3cbd7c73466:statusl19:namespace-not-found4:done5:erroree
DEBUG <<<: d2:idi6e7:session36:480cb143-4a4f-4a71-8e55-2a3cbd7c73466:statusl4:doneee

The response(<<<) contains namespace-not-found error message, and the requested(>>>) namespace is 'ns': 'my'. Thus I assumed that ignorecase option may be affected at this point.

:set ignorecase actually solves the problem, but I don't want to force ignorecase, so I checked the namespace detection process. https://github.com/liquidz/vim-iced/blob/6991e128cafb29ca3cb6f6501ad57fc2989b74fd/autoload/iced/nrepl/ns.vim#L76-L100

The [matchstr](https://vim-jp.org/vimdoc-en/builtin.html#matchstr()) function is using ignorecase like [match](https://vim-jp.org/vimdoc-en/builtin.html#match()) function, I noticed that I forgot to specify A-Z as a pattern. So I fixed the pattern in https://github.com/liquidz/vim-iced/commit/2b6ec69976cf11daa5584d6a471db72ca928364e.

lamp commented 2 years ago

Ah, sorry, I've fixed it here Not a problem, thanks for fixing the bug.

I can confirm it now works perfectly in my demo app and the real one, thank you!

let g:iced#debug = v:true Good to know about this, I did try looking for something in the docs but I must have missed it.

Thanks again

liquidz commented 2 years ago

@lamp Oh sorry, g:iced#debug is not described in documents. I'll add them in #435.