Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(java): rename clang_format to clang-format #837

Closed
wants to merge 1 commit into from
Closed

fix(java): rename clang_format to clang-format #837

wants to merge 1 commit into from

Conversation

krzysztofgb
Copy link
Contributor

📑 Description

Update clang_format formatter name with clang-format.

ℹ Additional Information

Example of the error I'm currently getting with the latest version of AstroNvim/astrocommunity. This fixes that.

Error executing vim.schedule lua callback: ...l/share/nvim/lazy/mason.nvim/lua/mason-registry/init.lua:80: Cannot find p
ackage "clang_format".                                                                                                  
stack traceback:                                                                                                        
        [C]: in function 'error'                                                                                        
        ...l/share/nvim/lazy/mason.nvim/lua/mason-registry/init.lua:80: in function 'get_package'                       
        ...on-tool-installer.nvim/lua/mason-tool-installer/init.lua:127: in function 'callback'                         
        ...share/nvim/lazy/mason.nvim/lua/mason-core/async/init.lua:87: in function 'step'                              
        ...share/nvim/lazy/mason.nvim/lua/mason-core/async/init.lua:96: in function 'run'                               
        ...l/share/nvim/lazy/mason.nvim/lua/mason-registry/init.lua:202: in function 'refresh'                          
        ...on-tool-installer.nvim/lua/mason-tool-installer/init.lua:156: in function ''                                 
        vim/_editor.lua: in function ''                                                                                 
        vim/_editor.lua: in function <vim/_editor.lua:0>

Copy link

github-actions bot commented Apr 6, 2024

Review Checklist

Does this PR follow the [Contribution Guidelines](development guidelines)? Following is a partial checklist:

Proper conventional commit scoping:

  • If you are adding a new plugin, the scope would be the name of the category it is being added into. ex. feat(utility): added noice.nvim plugin

  • If you are modifying a pre-existing plugin or pack, the scope would be the name of the plugin folder. ex. fix(noice-nvim): fix LSP handler error

  • Pull request title has the appropriate conventional commit type and scope where the scope is the name of the pre-existing directory in the project as described above

  • README is properly formatted and uses fenced in links with <url> unless they are inside a [title](url)

  • Proper usage of opts table rather than setting things up with the config function.

@Uzaaft
Copy link
Member

Uzaaft commented Apr 6, 2024

Are your plugins up to date? clang-format is a valid source name for me.

@Uzaaft Uzaaft added the invalid This doesn't seem right label Apr 6, 2024
@krzysztofgb
Copy link
Contributor Author

I'm fairly new to this Neovim stuff... but if you mean going in to :Lazy and hitting "Update"... then yeah. They're all up to date. I still get the error - it goes away when I update the name to clang-format.

@Uzaaft
Copy link
Member

Uzaaft commented Apr 6, 2024

I'm fairly new to this Neovim stuff... but if you mean going in to :Lazy and hitting "Update"... then yeah. They're all up to date. I still get the error - it goes away when I update the name to clang-format.

Are you using a custom config? Does it happen with a new astronvim config alongside the java import?

@krzysztofgb
Copy link
Contributor Author

Here's what I did to reproduce:

  1. Clean Neovim install
    • mv ~/.config/nvim ~/.config/nvim.bak
    • rm -rf ~/.local/share/nvim
    • rm -rf ~/.local/state/nvim
    • rm -rf ~/.cache/nvim
  2. Clone AstroNvim template
    • git clone --depth 1 https://github.com/AstroNvim/template ~/.config/nvim
    • rm -rf ~/.config/nvim/.git
    • nvim
  3. Activate all files in ~/.config/nvim/lua/plugins by removing the first line. Make no other changes.
  4. Enable community.lua, use the following config:
return {
	"AstroNvim/astrocommunity",
	-- available plugins can be found at https://github.com/AstroNvim/astrocommunity
	{ import = "astrocommunity.bars-and-lines.lualine-nvim" },
	{ import = "astrocommunity.colorscheme.tokyonight-nvim" },
	{ import = "astrocommunity.comment.mini-comment" },
	{ import = "astrocommunity.completion.cmp-cmdline" },
	{ import = "astrocommunity.debugging.nvim-dap-repl-highlights" },
	{ import = "astrocommunity.debugging.nvim-dap-virtual-text" },
	{ import = "astrocommunity.debugging.telescope-dap-nvim" },
	{ import = "astrocommunity.editing-support.conform-nvim" },
	{ import = "astrocommunity.file-explorer.telescope-file-browser-nvim" },
	{ import = "astrocommunity.fuzzy-finder.telescope-zoxide" },
	{ import = "astrocommunity.git.blame-nvim" },
	{ import = "astrocommunity.indent.mini-indentscope" },
	{ import = "astrocommunity.lsp.lsp-signature-nvim" },
	{ import = "astrocommunity.lsp.nvim-lint" },
	{ import = "astrocommunity.lsp.nvim-lsp-file-operations" },
	{ import = "astrocommunity/markdown-and-latex/glow-nvim" },
	{ import = "astrocommunity/markdown-and-latex/markdown-preview-nvim" },
	{ import = "astrocommunity.motion.flash-nvim" },
	{ import = "astrocommunity.motion.harpoon" },
	{ import = "astrocommunity.motion.mini-surround" },
	{ import = "astrocommunity.pack.bash" },
	{ import = "astrocommunity.pack.docker" },
	{ import = "astrocommunity.pack.lua" },
	{ import = "astrocommunity.pack.go" },
	{ import = "astrocommunity.pack.java" },
	{ import = "astrocommunity.pack.json" },
	{ import = "astrocommunity.pack.markdown" },
	{ import = "astrocommunity.pack.proto" },
	{ import = "astrocommunity.pack.python" },
	{ import = "astrocommunity.pack.rust" },
	{ import = "astrocommunity.pack.sql" },
	{ import = "astrocommunity.pack.terraform" },
	{ import = "astrocommunity.pack.toml" },
	{ import = "astrocommunity.pack.yaml" },
	{ import = "astrocommunity/recipes/disable-tabline" },
	{ import = "astrocommunity.test.neotest" },
	{ import = "astrocommunity/utility/mason-tool-installer-nvim" },
	{ import = "astrocommunity/workflow/hardtime-nvim" },
}
  1. Error upon entering nvim (during nvim-treesitter setup)

@Uzaaft
Copy link
Member

Uzaaft commented Apr 6, 2024

Strip your config down to just the java pack import

@krzysztofgb
Copy link
Contributor Author

Just

return {
  "AstroNvim/astrocommunity",
  { import = "astrocommunity.pack.java" },
}

works. I've found that the minimal config to get things to break is the following:

return {
  "AstroNvim/astrocommunity",
  { import = "astrocommunity.pack.java" },
  { import = "astrocommunity/utility/mason-tool-installer-nvim" },
}

@krzysztofgb
Copy link
Contributor Author

krzysztofgb commented Apr 6, 2024

Another thing to note... the Java pack's init.lua already has two references to clang-format, yet this one reference to clang_format remains. I may be ignorant, but is that intentional?

@Uzaaft
Copy link
Member

Uzaaft commented Apr 6, 2024

Another thing to note... the Java pack's init.lua already has two references to clang-format, yet this one reference to clang_format remains. I may be ignorant, but is that intentional?

Yes. The binary is called clang-format. The null-ls source that's being use is clang_format

@krzysztofgb
Copy link
Contributor Author

I see. Thanks for the explanation! Is it expected, then, that the addition of mason-tool-installer would cause this error? If it is, that's totally fine! I didn't see any docs on it so as a new-ish Neovim / AstroNvim user this was a pretty confusing error to debug.

@krzysztofgb
Copy link
Contributor Author

krzysztofgb commented Apr 6, 2024

I've read that (ref)

When passing a list of tools to ensure_installed, mason-tool-installer is expecting Mason package names by default. If mason-lspconfig is installed, mason-tool-installer can accept lspconfig package names instead.

clang_format doesn't seem to be a valid Mason package name - the Mason package name is clang-format.
Understandably, clang_format is the right null-ls source... should I be ignoring/excluding clang_format from the mason-tool-installer somehow?

@Uzaaft
Copy link
Member

Uzaaft commented Apr 6, 2024

yeah, I guess that makes more sense :)

@Uzaaft
Copy link
Member

Uzaaft commented Apr 6, 2024

I'll close this PR for now then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid This doesn't seem right
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants