Neovim
Example from your real setup in ~/.config/nvim/lsp.
Server config:
.config/nvim/lsp/solidity-language-server.lua
return {
name = "Solidity Language Server",
cmd = { "solidity-language-server", "--stdio" },
filetypes = { "solidity" },
root_markers = { "foundry.toml", ".git" },
settings = {
["solidity-language-server"] = {
inlayHints = {
parameters = true,
gasEstimates = true,
},
lint = {
enabled = true,
severity = {},
only = {},
exclude = { "screaming-snake-case-const" },
},
fileOperations = {
templateOnCreate = true,
updateImportsOnRename = true,
updateImportsOnDelete = true,
},
},
},
on_attach = function(client, bufnr)
vim.lsp.inlay_hint.enable(true, { bufnr = bufnr })
vim.api.nvim_create_autocmd("BufWritePost", {
pattern = { "*.sol" },
callback = function()
vim.lsp.buf.format()
end,
})
vim.lsp.completion.enable(true, client.id, bufnr, {
autotrigger = true,
convert = function(item)
return { abbr = item.label:gsub('%b()', '') }
end,
})
for _, char in ipairs({ "(", ",", "[" }) do
vim.keymap.set("i", char, function()
vim.api.nvim_feedkeys(char, "n", false)
vim.defer_fn(vim.lsp.buf.signature_help, 50)
end, { buffer = bufnr })
end
end,
}LSP capabilities + enable:
.config/nvim/plugin/lsp.lua
vim.lsp.config("*", {
capabilities = {
textDocument = {
semanticTokens = {
multilineTokenSupport = true,
},
},
workspace = {
fileOperations = {
willRename = true,
didRename = true,
},
},
},
root_markers = { ".git" },
})
vim.lsp.enable("solidity-language-server")File manager requirement
For templateOnCreate, rename import updates, and delete import updates to work, your file manager must send LSP file operation events:
workspace/willCreateFilesworkspace/willRenameFilesworkspace/willDeleteFiles
If these events are not sent, the server cannot apply those file-operation edits.
Example (oil.nvim):
.config/nvim/lua/plugins/oil.lua
require("oil").setup({
lsp_file_methods = {
enabled = true,
timeout_ms = 1000,
autosave_changes = "all",
},
})Neovim note for rename flows
After file renames, if your editor leaves updated imports in modified buffers, run:
:waThis writes all modified buffers so tools reading from disk (for example forge) see updated imports.