Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

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/willCreateFiles
  • workspace/willRenameFiles
  • workspace/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:

:wa

This writes all modified buffers so tools reading from disk (for example forge) see updated imports.