Open ismael-lajaaiti opened 1 year ago
Hello! Thanks for the detailed report. I don't believe there's anything that should be addressed in this plugin. I believe the problem is that nvim-lspconfig
is configured to look for Project.toml
when resolving the workspace folder for the project, so it will end up using directory/
if there's a Project.toml
in there.
The Julia language server seems to look through all registered workspace folders to find a JuliaFormatter config. nvim-lspconfig
will only set a single workspace folder when launching the server.
I see three potential solutions:
1) override nvim-lspconfig's default root_dir setting
2) keep the default nvim-lspconfig settings and manually add workspace folders via :h vim.lsp.buf.add_workspace_folder()
3) use vim.lsp.start()
instead of nvim-lspconfig to set up julials (it gives you greater flexibility)
Thanks for the convincing insight @williamboman :)
IIUC these workarounds will "make it work", but none solves the problem that the formatter is behaving incorrectly with the default installation. Do you think this report (and the associated workarounds) should be moved to nvim-lspconfig then? The problems seems to be that their hypotheses about the idea of a "workspace" are too strong?
Yeah that would probably be a better place. Note that nvim-lspconfig configurations are technically "unsupported" and best-effort. To me it sounds like this relates to project setups that are more complex than what nvim-lspconfig currently is able to support, so I think a good first step would be to iron out what constitutes a "project" and how these can be identified.
Problem description
With the default configuration of
julials
it seems that procedure to find the .JuliaFormatter.toml is different from the one described in the JuliaFormatter documentation:For instance if I have the following tree:
If
directory/
doesn't have a.JuliaFormatter.toml
, the formatting will occur according toJulia/.JuliaFormatter.toml
.However, the behaviour with
julials
formatting is slightly different. From I see, if there is nodirectory/Project.toml
my environment isJulia/
and the formatting is ruled byJulia/.JuliaFormatter.toml
. However, if there is adirectory/Project.toml
, it seems thatjulials
is looking for adirectory/.JuliaFormatter.toml
and if doesn't not exist, default formatting options are applied. Whereas here, I would expect that theJulia/.JuliaFormatter.toml
rules to be applied.Why do you think this is an issue with mason-lspconfig.nvim?
I am new to neovim and not sure who is responsible for the behaviour of the formatting of
julials
. Thus if I'm opened this issue in the wrong repository, I would be happy to be redirected to the right place and sorry for the inconvenience.Neovim version (>= 0.7)
NVIM v0.8.3 Build type: Release LuaJIT 2.1.0-beta3 Compiled by brew@Ventura-arm64.local
Operating system/version
Darwin sk-E22-66-156.local 22.2.0 Darwin Kernel Version 22.2.0: Fri Nov 11 02:03:51 PST 2022; root:xnu-8792.61.2~4/RELEASE_ARM64_T6000 arm64
I've manually reviewed the Nvim LPS client log (
:LspLog
) to find potential errorsI've recently downloaded the latest plugin version of mason.nvim, mason-lspconfig.nvim, and nvim-lspconfig
Affected language servers
julials
Steps to reproduce
$ cd <trash_dir>
to go to a directory to create the temporary files and directory$ mkdir Julia
$ cd Julia
$ julia --project=. -e 'using Pkg; Pkg.add("Random")'
to create aProject.toml
andManifest.toml
$ echo 'indent = 1' > .JuliaFormatter.toml
$ mkdir directory
$ echo 'for i in 1:10\nprintln(i)\nend > test.jl'
$ nvim test.jl
and run the LSP formatter, you should see the inner line of the loop (println(i)
to be indented with 1 space), then save and quit the file$ julia --project=. -e 'using Pkg; Pkg.add("Random")'
to create aProject.toml
andManifest.toml
in thedirectory/
$ nvim test.jl
and run the LSP formatter, the inner loop should no be indented with 4 spaces (the default formatter option).Actual behavior
If an environment (i.e.
Project.toml
) exists in the current directory of the file but there is no.JuliaFormatter.toml
the default formatting options are applied. (In my example, the current directory isdirectory/
and the filetest.jl
)Expected behavior
Whereas we expect that formatter options of the
.JuliaFormatter.toml
of the directory above (Julia/
in my example) to be applied, instead of the defaults.LspInfo
LspLog
No response
Healthcheck
Screenshots or recordings
No response