mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-07-25 13:15:04 +02:00
feat(lang): add solidity language support
## Description - Add Solidity language support to `nvim-treesitter` for syntax highlighting and enhanced code understanding. - Configure `nvim-lspconfig` for Solidity LSP support, setting up `solidity_ls` with a root pattern detection for Solidity projects. - Integrate `forge_fmt` as the formatter for Solidity files using `conform.nvim`, with command options for `forge fmt`.
This commit is contained in:
parent
4876d1137d
commit
cccaae0a1b
1 changed files with 47 additions and 0 deletions
47
lua/lazyvim/plugins/extras/lang/solidity.lua
Normal file
47
lua/lazyvim/plugins/extras/lang/solidity.lua
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
return {
|
||||||
|
recommended = function()
|
||||||
|
return LazyVim.extras.wants({
|
||||||
|
ft = "solidity",
|
||||||
|
root = {
|
||||||
|
"foundry.toml",
|
||||||
|
"hardhat.config.js",
|
||||||
|
"hardhat.config.ts",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
end,
|
||||||
|
-- Add Solidity & related to treesitter
|
||||||
|
{
|
||||||
|
"nvim-treesitter/nvim-treesitter",
|
||||||
|
opts = { ensure_installed = { "solidity" } },
|
||||||
|
},
|
||||||
|
|
||||||
|
-- Correctly setup lspconfig for Solidity
|
||||||
|
{
|
||||||
|
"neovim/nvim-lspconfig",
|
||||||
|
opts = {
|
||||||
|
servers = {
|
||||||
|
solidity_ls = {
|
||||||
|
filetypes = { "solidity" },
|
||||||
|
root_dir = function(fname)
|
||||||
|
return require("lspconfig").util.root_pattern("foundry.toml", "hardhat.config.*", ".git")(fname)
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
-- Formatter for Solidity
|
||||||
|
{
|
||||||
|
"conform.nvim",
|
||||||
|
opts = function(_, opts)
|
||||||
|
opts.formatters_by_ft = opts.formatters_by_ft or {}
|
||||||
|
opts.formatters_by_ft.solidity = { "forge_fmt" }
|
||||||
|
|
||||||
|
opts.formatters = {
|
||||||
|
forge_fmt = {
|
||||||
|
command = "forge",
|
||||||
|
args = { "fmt" },
|
||||||
|
},
|
||||||
|
}
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue